Skip to content

Commit 85e5cd0

Browse files
authored
Merge pull request #18 from scientific-python/ci
2 parents 870132e + ed9bd29 commit 85e5cd0

File tree

9 files changed

+55
-92
lines changed

9 files changed

+55
-92
lines changed

.github/workflows/release_schedule.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.

action.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ runs:
3535
using: "composite"
3636
steps:
3737
- name: Checkout code
38-
uses: actions/checkout@v6
38+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3939
- name: Set up Git
4040
shell: bash
4141
run: |
4242
git config user.name "Scientific Python [bot]"
4343
git config user.email "[email protected]"
44-
- uses: prefix-dev/[email protected]
44+
- uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
4545
name: Setup Pixi
4646
with:
4747
pixi-version: v0.49.0
4848
manifest-path: ${{ github.action_path }}/pyproject.toml
4949
- name: Fetch Schedule from release
50-
uses: robinraju/release-downloader@v1.3
50+
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
5151
with:
5252
repository: "savente93/SPEC0-schedule"
5353
latest: true
@@ -71,7 +71,7 @@ runs:
7171
fi
7272
- name: Create Pull Request
7373
if: ${{ fromJSON(inputs.create_pr) && fromJSON(steps.changes.outputs.changes_detected) }}
74-
uses: peter-evans/create-pull-request@v7
74+
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.2
7575
with:
7676
token: ${{ inputs.token }}
7777
commit-message: ${{ inputs.commit_msg }}

spec0_action/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule)
2323
# Iterate by idx because we want to update it inplace
2424
for i in range(len(dependencies)):
2525
dep_str = dependencies[i]
26-
pkg, extras, spec = parse_pep_dependency(dep_str)
26+
pkg, extras, spec, env = parse_pep_dependency(dep_str)
2727

2828
if isinstance(spec, Url) or pkg not in schedule["packages"]:
2929
continue
@@ -36,9 +36,9 @@ def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule)
3636
continue
3737

3838
if not extras:
39-
new_dep_str = f"{pkg}{repr_spec_set(spec)}"
39+
new_dep_str = f"{pkg}{repr_spec_set(spec)}{env or ''}"
4040
else:
41-
new_dep_str = f"{pkg}{extras}{repr_spec_set(spec)}"
41+
new_dep_str = f"{pkg}{extras}{repr_spec_set(spec)}{env or ''}"
4242

4343
dependencies[i] = new_dep_str
4444

spec0_action/parsing.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
Url: TypeAlias = ParseResult
1313

1414
# Slightly modified version of https://packaging.python.org/en/latest/specifications/dependency-specifiers/#names
15-
PEP_PACKAGE_IDENT_RE = compile(r"(?im)^([A-Z0-9][A-Z0-9._-]*)(\[[A-Z0-9._,-]+\])?(.*)$")
15+
PEP_PACKAGE_IDENT_RE = compile(
16+
r"(?im)^([A-Z0-9][A-Z0-9._-]*)(\[[A-Z0-9._,-]+\])?([^;]*)(;.*)?$"
17+
)
1618

1719

1820
class SupportSchedule(TypedDict):
@@ -64,12 +66,12 @@ def read_schedule(path: Path | str) -> Sequence[SupportSchedule]:
6466

6567
def parse_pep_dependency(
6668
dep_str: str,
67-
) -> Tuple[str, str | None, SpecifierSet | Url | None]:
69+
) -> Tuple[str, str | None, SpecifierSet | Url | None, str | None]:
6870
match = PEP_PACKAGE_IDENT_RE.match(dep_str)
6971
if match is None:
7072
raise ValueError("Could not find any valid python package identifier")
7173

72-
pkg, extras, spec_str = match.groups()
74+
pkg, extras, spec_str, env = match.groups()
7375

7476
extras = extras or None
7577

@@ -80,7 +82,7 @@ def parse_pep_dependency(
8082
else:
8183
spec = SpecifierSet(spec_str)
8284

83-
return (pkg, extras, spec)
85+
return (pkg, extras, spec, env)
8486

8587

8688
def is_url_spec(str_spec: str | None) -> bool:

tests/test_data/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "setuptools_test"
11+
version = "0.1.0"
1112
requires-python = ">=3.11"
1213
dependencies = [
13-
'numpy>=1.20.0,<2',
1414
'pandas>=1.0.0,<3',
1515
'xarray>=2021.1.0',
16+
"ipython>=8.7.0,<4",
17+
"numpy[foo,bar]>=1.10.0,<2",
18+
"scikit-learn>1.2,<1.4;sys_platform=='win32'",
19+
"scikit-learn>1.2;sys_platform!='win32'"
1620
]

tests/test_data/pyproject_pixi.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ name = "tests"
44
description = "This is just a dummy package for testing the spec 0 update github action and should not be used"
55
requires-python = ">=3.10"
66
version = "0.1.0"
7-
dependencies = ["ipython>=8.7.0,<4", "numpy[foo,bar]>=1.10.0,<2"]
7+
dependencies = [
8+
"ipython>=8.7.0,<4",
9+
"numpy[foo,bar]>=1.10.0,<2",
10+
"scikit-learn>1.2,<1.4;sys_platform=='win32'",
11+
"scikit-learn>1.2;sys_platform!='win32'"
12+
]
813

914
[build-system]
1015
build-backend = "hatchling.build"

tests/test_data/pyproject_pixi_updated.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ name = "tests"
44
description = "This is just a dummy package for testing the spec 0 update github action and should not be used"
55
requires-python = ">=3.11"
66
version = "0.1.0"
7-
dependencies = ["ipython>=8.8.0,<4", "numpy[foo,bar]>=1.25.0,<2"]
8-
7+
dependencies = [
8+
"ipython>=8.8.0,<4",
9+
"numpy[foo,bar]>=1.25.0,<2",
10+
"scikit-learn>=1.3.0,<1.4;sys_platform=='win32'",
11+
"scikit-learn>=1.3.0;sys_platform!='win32'"
12+
]
913
[build-system]
1014
build-backend = "hatchling.build"
1115
requires = ["hatchling"]

tests/test_data/pyproject_updated.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "setuptools_test"
11+
version = "0.1.0"
1112
requires-python = ">=3.11"
1213
dependencies = [
13-
'numpy>=1.25.0,<2',
1414
'pandas>=1.0.0,<3',
1515
'xarray>=2023.1.0',
16+
"ipython>=8.8.0,<4",
17+
"numpy[foo,bar]>=1.25.0,<2",
18+
"scikit-learn>=1.3.0,<1.4;sys_platform=='win32'",
19+
"scikit-learn>=1.3.0;sys_platform!='win32'"
1620
]

tests/test_parsing.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,61 @@ def test_parsing_incorrect():
2222

2323
def test_pep_dependency_parsing():
2424
matplotlib_str = "matplotlib"
25-
pkg, features, spec = parse_pep_dependency(matplotlib_str)
25+
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)
2626

2727
assert pkg == "matplotlib", pkg
2828
assert features is None, features
2929
assert spec is None, spec
30+
assert env is None, env
3031

3132

3233
def test_pep_dependency_parsing_with_spec_and_optional_dep():
3334
matplotlib_str = "matplotlib[foo,bar]>=3.7.0,<4"
34-
pkg, features, spec = parse_pep_dependency(matplotlib_str)
35+
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)
3536

3637
assert pkg == "matplotlib", pkg
3738
assert features == "[foo,bar]", features
3839
assert spec == SpecifierSet(">=3.7.0,<4"), spec
40+
assert env is None, env
3941

4042

4143
def test_pep_dependency_parsing_with_spec():
4244
matplotlib_str = "matplotlib>=3.7.0,<4"
43-
pkg, features, spec = parse_pep_dependency(matplotlib_str)
45+
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)
4446

4547
assert pkg == "matplotlib", pkg
4648
assert features is None, features
4749
assert spec == SpecifierSet(">=3.7.0,<4"), spec
50+
assert env is None, env
4851

4952

5053
def test_pep_dependency_parsing_with_url_spec():
5154
dep_str = "matplotlib @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686"
52-
pkg, features, spec = parse_pep_dependency(dep_str)
55+
pkg, features, spec, env = parse_pep_dependency(dep_str)
5356

5457
assert pkg == "matplotlib", pkg
5558
assert features is None, features
5659
assert spec == urlparse(
5760
" https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686"
5861
), spec
62+
assert env is None, env
5963

6064

6165
def test_pep_dependency_parsing_extra_restrictions():
6266
matplotlib_str = "matplotlib>=3.7.0,<4,!=3.8.14"
63-
pkg, features, spec = parse_pep_dependency(matplotlib_str)
67+
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)
6468

6569
assert pkg == "matplotlib", pkg
6670
assert features is None, features
6771
assert spec == SpecifierSet("!=3.8.14,<4,>=3.7.0"), spec
72+
assert env is None, env
73+
74+
75+
def test_pep_dependency_parsing_with_environment_marker():
76+
matplotlib_str = "matplotlib>=3.7.0,<4;sys_platform != 'win32'"
77+
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)
78+
79+
assert pkg == "matplotlib", pkg
80+
assert features is None, features
81+
assert spec == SpecifierSet(">=3.7.0,<4"), spec
82+
assert env == ";sys_platform != 'win32'", env

0 commit comments

Comments
 (0)