Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Install package and dependencies
run: |
python -m pip install uv
uv pip install --system "$(ls dist/*.whl)[dev,solvers,oetc]"
uv pip install --system "$(ls dist/*.whl)[dev,solvers,oetc]" --group spec

- name: Test with pytest
env:
Expand Down
9 changes: 9 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Root pytest configuration for ``--doctest-modules`` collection of ``linopy/``."""

from __future__ import annotations

from importlib.util import find_spec

collect_ignore: list[str] = []
if find_spec("math_spec") is None:
collect_ignore.append("linopy/spec")
3 changes: 3 additions & 0 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ To run the test suite:
# Install development dependencies
uv sync --extra dev --extra solvers

# Also run the math-spec binder tests (needs Python >= 3.12)
uv sync --extra dev --extra solvers --group spec

# Run all tests
pytest

Expand Down
22 changes: 22 additions & 0 deletions linopy/spec/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Build linopy models from math-spec programs.

The package needs the ``math-spec`` distribution (import name ``math_spec``,
Python >= 3.12). It is imported here and nowhere else in linopy, so
``import linopy`` never pulls it in.
"""

from __future__ import annotations

from importlib.util import find_spec

if find_spec("math_spec") is None:
raise ImportError(
"linopy.spec needs the math-spec package. Install it with "
"`pip install math-spec` (Python >= 3.12) and try again."
)

from linopy.spec.binder import Bound, Retain, bind
from linopy.spec.errors import SpecDataError

__all__ = ["Bound", "Retain", "SpecDataError", "bind"]
Loading
Loading