Skip to content

Commit 4e42e2d

Browse files
authored
Pin meta-package dependencies (#460)
* Pin versions in meta package * Pin to 0.3.0 * Add bump to lite * Add methods
1 parent 8163619 commit 4e42e2d

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed

python/jupytergis/pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
build-backend = "hatchling.build"
3-
requires = ["hatchling>=1.5.0,<2"]
3+
requires = ["hatchling>=1.5.0,<2", "tomlkit>=0.13.2,<0.14"]
44

55
[project]
66
classifiers = [
@@ -19,9 +19,9 @@ classifiers = [
1919
"Programming Language :: Python :: 3.12",
2020
]
2121
dependencies = [
22-
"jupytergis_core>=0.1.0,<1",
23-
"jupytergis_lab>=0.1.0,<1",
24-
"jupytergis_qgis>=0.1.0,<1",
22+
"jupytergis_core==0.3.0",
23+
"jupytergis_lab==0.3.0",
24+
"jupytergis_qgis==0.3.0",
2525
"jupyter-collaboration>=3,<4",
2626
"jupyterlab>=4.3,<5",
2727
]

python/jupytergis/scripts/bump-version.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
import argparse
77
import json
8+
from typing import List
89
from packaging.version import parse as parse_version
910
from pathlib import Path
1011
from subprocess import run
11-
12+
import tomlkit
1213

1314
ENC = dict(encoding="utf-8")
1415
HATCH_VERSION = "hatch version"
@@ -27,6 +28,20 @@ def next_version():
2728
return f"{v.major}.{v.minor}.{v.micro + 1}"
2829

2930

31+
def bump_jupytergis_deps(py_version: str):
32+
with open(ROOT / "pyproject.toml", "r") as f:
33+
data = tomlkit.load(f)
34+
dependencies: List[str] = data["project"]["dependencies"]
35+
36+
for index, value in enumerate(dependencies):
37+
if value.startswith("jupytergis"):
38+
lib = value.split("==")[0]
39+
dependencies[index] = f"{lib}=={py_version}"
40+
41+
with open(ROOT / "pyproject.toml", "w") as f:
42+
tomlkit.dump(data, f)
43+
44+
3045
def bump():
3146
parser = argparse.ArgumentParser()
3247
parser.add_argument("version")
@@ -51,6 +66,8 @@ def bump():
5166
)
5267
# bump the Python version with hatch
5368
run(f"{HATCH_VERSION} {py_version}", shell=True, check=True, cwd=ROOT)
69+
# pin jupytergis_* package to the same version
70+
bump_jupytergis_deps(py_version)
5471
# bump the JS version with lerna
5572
run(f"yarn run bump:js:version {js_version}", shell=True, check=True)
5673

python/jupytergis_lite/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ classifiers = [
1919
"Programming Language :: Python :: 3.12",
2020
]
2121
dependencies = [
22-
"jupytergis_core>=0.1.0,<1",
23-
"jupytergis_lab>=0.1.0,<1",
22+
"jupytergis_core==0.3.0",
23+
"jupytergis_lab==0.3.0",
2424
"my-jupyter-shared-drive",
2525
]
2626
dynamic = ["version"]

python/jupytergis_lite/scripts/bump-version.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
11
from pathlib import Path
22
from subprocess import run
3+
from typing import List
4+
from packaging.version import parse as parse_version
5+
import tomlkit
6+
import argparse
37

48
HATCH_VERSION = "hatch version"
59
ROOT = Path(__file__).parent.parent
610

711

12+
def get_version():
13+
cmd = run([HATCH_VERSION], capture_output=True, shell=True, check=True, cwd=ROOT)
14+
return cmd.stdout.decode("utf-8").strip().split("\n")[-1]
15+
16+
17+
def next_version():
18+
v = parse_version(get_version())
19+
if v.is_prerelease:
20+
return f"{v.major}.{v.minor}.{v.micro}{v.pre[0]}{v.pre[1] + 1}"
21+
return f"{v.major}.{v.minor}.{v.micro + 1}"
22+
23+
24+
def bump_jupytergis_deps(py_version: str):
25+
with open(ROOT / "pyproject.toml", "r") as f:
26+
data = tomlkit.load(f)
27+
dependencies: List[str] = data["project"]["dependencies"]
28+
29+
for index, value in enumerate(dependencies):
30+
if value.startswith("jupytergis"):
31+
lib = value.split("==")[0]
32+
dependencies[index] = f"{lib}=={py_version}"
33+
34+
with open(ROOT / "pyproject.toml", "w") as f:
35+
tomlkit.dump(data, f)
36+
37+
838
def bump():
39+
parser = argparse.ArgumentParser()
40+
parser.add_argument("version")
41+
args = parser.parse_args()
42+
py_version = next_version() if args.version == "next" else args.version
943
# bump the Python version with hatch
1044
run(f"{HATCH_VERSION}", shell=True, check=True, cwd=ROOT)
45+
# pin jupytergis_* package to the same version
46+
bump_jupytergis_deps(py_version)
1147

1248

1349
if __name__ == "__main__":

0 commit comments

Comments
 (0)