From 6a3b0eb625b02fab534c65fefc3d651505d45f6f Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 20 May 2024 17:28:23 +0200 Subject: [PATCH] ENH: upgrade to `python-constraint2` (#268) * MAINT: update pip constraints files --- .constraints/py3.10.txt | 3 +-- .constraints/py3.11.txt | 3 +-- .constraints/py3.12.txt | 3 +-- .constraints/py3.7.txt | 1 - .constraints/py3.8.txt | 3 +-- .constraints/py3.9.txt | 3 +-- docs/conf.py | 31 +------------------------------ pyproject.toml | 9 ++------- src/qrules/solving.py | 6 +++--- 9 files changed, 11 insertions(+), 51 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index cce3b3e6..005c554b 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -124,7 +124,7 @@ pytest==8.2.1 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 -python-constraint==1.4.0 +python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 @@ -165,7 +165,6 @@ sphinxcontrib-htmlhelp==2.0.5 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.7 sphinxcontrib-serializinghtml==1.1.10 -sphobjinv==2.3.1 sqlalchemy==2.0.30 stack-data==0.6.3 starlette==0.37.2 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index f6c814ea..9c5d55c2 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -123,7 +123,7 @@ pytest==8.2.1 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 -python-constraint==1.4.0 +python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 @@ -164,7 +164,6 @@ sphinxcontrib-htmlhelp==2.0.5 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.7 sphinxcontrib-serializinghtml==1.1.10 -sphobjinv==2.3.1 sqlalchemy==2.0.30 stack-data==0.6.3 starlette==0.37.2 diff --git a/.constraints/py3.12.txt b/.constraints/py3.12.txt index 5fa9349d..7e6db895 100644 --- a/.constraints/py3.12.txt +++ b/.constraints/py3.12.txt @@ -123,7 +123,7 @@ pytest==8.2.1 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 -python-constraint==1.4.0 +python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 @@ -164,7 +164,6 @@ sphinxcontrib-htmlhelp==2.0.5 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.7 sphinxcontrib-serializinghtml==1.1.10 -sphobjinv==2.3.1 sqlalchemy==2.0.30 stack-data==0.6.3 starlette==0.37.2 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 8b831222..5d598a62 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -171,7 +171,6 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.3.1 sqlalchemy==1.4.52 tabulate==0.9.0 terminado==0.17.1 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index f23e23c3..f7bddc89 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -129,7 +129,7 @@ pytest==8.2.1 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 -python-constraint==1.4.0 +python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 @@ -171,7 +171,6 @@ sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.3.1 sqlalchemy==2.0.30 stack-data==0.6.3 tabulate==0.9.0 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 1f0cae72..1dcbe75c 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -124,7 +124,7 @@ pytest==8.2.1 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 -python-constraint==1.4.0 +python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 @@ -165,7 +165,6 @@ sphinxcontrib-htmlhelp==2.0.5 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.7 sphinxcontrib-serializinghtml==1.1.10 -sphobjinv==2.3.1 sqlalchemy==2.0.30 stack-data==0.6.3 starlette==0.37.2 diff --git a/docs/conf.py b/docs/conf.py index 1935d1fb..971f053c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,7 +3,6 @@ import os import sys -import sphobjinv as soi from sphinx_api_relink.helpers import ( get_branch_name, get_execution_mode, @@ -15,34 +14,6 @@ sys.path.insert(0, os.path.abspath(".")) from _extend_docstrings import extend_docstrings # noqa: PLC2701 - -def create_constraints_inventory() -> None: - inv = soi.Inventory() - inv.project = "constraint" - constraint_object_names = [ - "Constraint", - "Domain", - "Problem", - "Solver", - "Variable", - ] - for object_name in constraint_object_names: - inv.objects.append( - soi.DataObjStr( - name=f"{inv.project}.{object_name}", - domain="py", - role="class", - priority="1", - uri=f"{inv.project}.{object_name}-class.html", - dispname="-", - ) - ) - text = inv.data_file(contract=True) - ztext = soi.compress(text) - soi.writebytes("constraint.inv", ztext) - - -create_constraints_inventory() extend_docstrings() set_intersphinx_version_remapping({ "ipython": { @@ -250,7 +221,7 @@ def create_constraints_inventory() -> None: "ampform": ("https://ampform.readthedocs.io/en/stable", None), "attrs": (f"https://www.attrs.org/en/{pin('attrs')}", None), "compwa": ("https://compwa.github.io", None), - "constraint": ("https://labix.org/doc/constraint/public", "constraint.inv"), + "constraint": ("https://python-constraint.github.io/python-constraint", None), "graphviz": ("https://graphviz.readthedocs.io/en/stable", None), "IPython": (f"https://ipython.readthedocs.io/en/{pin('IPython')}", None), "jsonschema": ("https://python-jsonschema.readthedocs.io/en/stable", None), diff --git a/pyproject.toml b/pyproject.toml index 6208ca13..4d9069e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,8 +31,9 @@ dependencies = [ "attrs >=20.1.0", # on_setattr and https://www.attrs.org/en/stable/api.html#next-gen "jsonschema", "particle", - "python-constraint", "tqdm >=4.24.0", # autonotebook + 'python-constraint2; python_version >="3.8.0"', + 'python-constraint; python_version <"3.8.0"', 'typing-extensions; python_version <"3.8.0"', # Literal, Protocol ] description = "Rule-based particle reaction problem solver on a quantum number level" @@ -77,7 +78,6 @@ doc = [ "sphinx-thebe", "sphinx-togglebutton", "sphinxcontrib-bibtex >=2", - "sphobjinv", 'sphinx-api-relink >=0.0.4', 'sphinx-pybtex-etal-style', ] @@ -114,7 +114,6 @@ types = [ "ipython", "pydot <2", # problem with pydot.graph_from_dot_data "pytest", - "sphobjinv", "types-PyYAML", "types-setuptools", 'sphinx-api-relink >=0.0.4', @@ -200,10 +199,6 @@ module = ["pydot.*"] ignore_missing_imports = true module = ["sphinx.*"] -[[tool.mypy.overrides]] -ignore_missing_imports = true -module = ["sphobjinv.*"] - [[tool.mypy.overrides]] ignore_missing_imports = true module = ["tqdm.*"] diff --git a/src/qrules/solving.py b/src/qrules/solving.py index f42314a4..d2fc315d 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -415,7 +415,7 @@ class _VariableContainer: class CSPSolver(Solver): """Solver reducing the task to a Constraint Satisfaction Problem. - Solving this done with the python-constraint module. + Solving this done with the :doc:`constraint` package. The variables are the quantum numbers of particles/edges, but also some composite quantum numbers which are attributed to the interaction nodes (such as angular @@ -782,7 +782,7 @@ def rule_passes(self) -> dict[tuple[int, Rule], int]: class _GraphElementConstraint(Generic[_QNType], Constraint): - """Wrapper class of the python-constraint Constraint class. + """Wrapper class of the `~constraints.Constraint` class. This allows a customized definition of conservation rules, and hence a cleaner user interface. @@ -903,7 +903,7 @@ def __update_variable_lists( class _ConservationRuleConstraintWrapper( Constraint # pyright: ignore[reportUntypedBaseClass] ): - """Wrapper class of the python-constraint Constraint class. + """Wrapper class of the `~constraints.Constraint` class. This allows a customized definition of conservation rules, and hence a cleaner user interface.