From 55d21ff4005dadd0ab840209066b7f98a0c892bd Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 19:31:12 -0600 Subject: [PATCH 1/7] clean up create constraints --- .github/actions/install-minimums/action.yml | 2 +- .../create_constraints_file.py | 23 ++++++++++++++----- pyproject.toml | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/actions/install-minimums/action.yml b/.github/actions/install-minimums/action.yml index fb809a9..69802a8 100644 --- a/.github/actions/install-minimums/action.yml +++ b/.github/actions/install-minimums/action.yml @@ -24,7 +24,7 @@ runs: echo "::group::Create Constraints file" CONSTRAINTS_FILE=${{inputs.constraints_file_path}} - python -m pip install -U pip build pkginfo packaging + python -m pip install -U pip build packaging cd ${{ inputs.working-directory }} python -m build --wheel . python ${{ github.action_path }}/create_constraints_file.py $CONSTRAINTS_FILE dist/*.whl diff --git a/.github/actions/install-minimums/create_constraints_file.py b/.github/actions/install-minimums/create_constraints_file.py index 7b9069d..540cdb5 100644 --- a/.github/actions/install-minimums/create_constraints_file.py +++ b/.github/actions/install-minimums/create_constraints_file.py @@ -1,22 +1,33 @@ import sys +from zipfile import ZipFile from packaging.requirements import Requirement -from pkginfo import Wheel output_file = sys.argv[-2] fname = sys.argv[-1] -constraints = set() +constraints = {} -# Extract the minimum versions from the requirements in the wheel. -w = Wheel(fname) -for req in w.requires_dist: +archive = ZipFile(fname) +reqs = [] +for f in archive.namelist(): + if f.endswith("METADATA"): + for li in archive.open(f).read().decode("utf-8").split("\n"): + if li.startswith("Requires-Dist"): + reqs.append(li.replace("Requires-Dist: ", "")) +archive.close() + +for req in reqs: r = Requirement(req) for specifier in r.specifier: + if "!" in specifier: + continue if "~" in specifier.operator or ">" in specifier.operator: spec = str(specifier).replace("~", "=") spec = spec.replace(">=", "==") spec = spec.replace(">", "==") - constraints.add(f"{r.name}{spec}\n") + constraints[r.name] = spec + +constraints = [f"{key}{value}\n" for (key, value) in constraints.items()] # Write the constraints to to a pip constraints file. with open(output_file, "w") as fid: diff --git a/pyproject.toml b/pyproject.toml index 58f1482..ea04c1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "foobar" authors = [{name = "Sir Robin", email = "robin@camelot.uk"}] dynamic = ["description", "version"] readme = "README.md" -dependencies = ["jupyter_core>=4.10.0"] +dependencies = ["jupyter_core>=4.12.0!~=5.0"] optional-dependencies.test = ["pytest"] [tool.jupyter-releaser] From e58693f29b7ff6fc127691e441a14dc79de607a5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 19:33:23 -0600 Subject: [PATCH 2/7] fix constraint --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ea04c1e..6883bf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "foobar" authors = [{name = "Sir Robin", email = "robin@camelot.uk"}] dynamic = ["description", "version"] readme = "README.md" -dependencies = ["jupyter_core>=4.12.0!~=5.0"] +dependencies = ["jupyter_core>=4.12,!~=5.0"] optional-dependencies.test = ["pytest"] [tool.jupyter-releaser] From 6cb2bc3e232aba2fda1d54a782b281808baf5c20 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 19:39:47 -0600 Subject: [PATCH 3/7] fix constraint --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6883bf7..e14fc21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "foobar" authors = [{name = "Sir Robin", email = "robin@camelot.uk"}] dynamic = ["description", "version"] readme = "README.md" -dependencies = ["jupyter_core>=4.12,!~=5.0"] +dependencies = ["jupyter_core>=4.12,!=~5.0"] optional-dependencies.test = ["pytest"] [tool.jupyter-releaser] From 29e727bc2c1901ffeeaaa57bc0a8d5c2f3e8bd8a Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 19:43:55 -0600 Subject: [PATCH 4/7] fix test --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25759d4..27a6a2f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,7 @@ jobs: python --version | grep "3.8" cat $PIP_CONSTRAINT cat $PIP_CONSTRAINT | grep "jupyter-core==" - pip list | grep "jupyter-core" | grep "4.10.0" + pip list | grep "jupyter-core" | grep "4.12" hatch run check_minimum From 2f03542db581d151bb5db5a40332a08b8bce30e6 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 19:55:40 -0600 Subject: [PATCH 5/7] debug --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 27a6a2f..294d618 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,6 +41,7 @@ jobs: python --version | grep "3.8" cat $PIP_CONSTRAINT cat $PIP_CONSTRAINT | grep "jupyter-core==" + pip list pip list | grep "jupyter-core" | grep "4.12" hatch run check_minimum From 4aa9a7fcb6919149669016ee7d08e74f5da5f3dd Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 19:57:03 -0600 Subject: [PATCH 6/7] try again --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 294d618..57071c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,7 +42,7 @@ jobs: cat $PIP_CONSTRAINT cat $PIP_CONSTRAINT | grep "jupyter-core==" pip list - pip list | grep "jupyter-core" | grep "4.12" + pip list | grep "jupyter" | grep "4.12" hatch run check_minimum From 94645d05b04f350c7c5f227ad8c500869b80351c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Nov 2022 20:02:25 -0600 Subject: [PATCH 7/7] try again --- .github/workflows/tests.yml | 7 +------ pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 57071c2..11bf78f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,16 +36,11 @@ jobs: dependency_type: minimum - run: | pip install -e ".[test]" - # NOTE: keep this version in sync with README + # NOTE: keep the python version in sync with README python --version python --version | grep "3.8" - cat $PIP_CONSTRAINT - cat $PIP_CONSTRAINT | grep "jupyter-core==" - pip list - pip list | grep "jupyter" | grep "4.12" hatch run check_minimum - base_setup_pre: runs-on: ubuntu-latest steps: diff --git a/pyproject.toml b/pyproject.toml index e14fc21..5b6ab2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ hooks.after-populate-release = ["bash ./.github/scripts/bump_tag.sh"] source = "nodejs" [tool.hatch.envs.default.scripts] -check_minimum = "python -c 'from jupyter_core import __version__; assert __version__ == \"4.10.0\"'" +check_minimum = "python -c 'from jupyter_core import __version__; assert __version__ == \"4.12.0\"'" check_pre = "python -c 'import os; assert os.environ[\"PIP_PRE\"] == \"1\"'" [tool.pytest.ini_options]