Skip to content
Merged
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
71 changes: 0 additions & 71 deletions .github/workflows/release_schedule.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Git
shell: bash
run: |
git config user.name "Scientific Python [bot]"
git config user.email "scientific-python@users.noreply.github.com"
- uses: prefix-dev/setup-pixi@v0.9.3
- uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
name: Setup Pixi
with:
pixi-version: v0.49.0
manifest-path: ${{ github.action_path }}/pyproject.toml
- name: Fetch Schedule from release
uses: robinraju/release-downloader@v1.3
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
with:
repository: "savente93/SPEC0-schedule"
latest: true
Expand All @@ -71,7 +71,7 @@ runs:
fi
- name: Create Pull Request
if: ${{ fromJSON(inputs.create_pr) && fromJSON(steps.changes.outputs.changes_detected) }}
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.2
with:
token: ${{ inputs.token }}
commit-message: ${{ inputs.commit_msg }}
Expand Down
6 changes: 3 additions & 3 deletions spec0_action/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def update_pyproject_dependencies(dependencies: dict, schedule: SupportSchedule)
# Iterate by idx because we want to update it inplace
for i in range(len(dependencies)):
dep_str = dependencies[i]
pkg, extras, spec = parse_pep_dependency(dep_str)
pkg, extras, spec, env = parse_pep_dependency(dep_str)

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

if not extras:
new_dep_str = f"{pkg}{repr_spec_set(spec)}"
new_dep_str = f"{pkg}{repr_spec_set(spec)}{env or ''}"
else:
new_dep_str = f"{pkg}{extras}{repr_spec_set(spec)}"
new_dep_str = f"{pkg}{extras}{repr_spec_set(spec)}{env or ''}"

dependencies[i] = new_dep_str

Expand Down
10 changes: 6 additions & 4 deletions spec0_action/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
Url: TypeAlias = ParseResult

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


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

def parse_pep_dependency(
dep_str: str,
) -> Tuple[str, str | None, SpecifierSet | Url | None]:
) -> Tuple[str, str | None, SpecifierSet | Url | None, str | None]:
match = PEP_PACKAGE_IDENT_RE.match(dep_str)
if match is None:
raise ValueError("Could not find any valid python package identifier")

pkg, extras, spec_str = match.groups()
pkg, extras, spec_str, env = match.groups()

extras = extras or None

Expand All @@ -80,7 +82,7 @@ def parse_pep_dependency(
else:
spec = SpecifierSet(spec_str)

return (pkg, extras, spec)
return (pkg, extras, spec, env)


def is_url_spec(str_spec: str | None) -> bool:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_data/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ build-backend = "setuptools.build_meta"

[project]
name = "setuptools_test"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
'numpy>=1.20.0,<2',
'pandas>=1.0.0,<3',
'xarray>=2021.1.0',
"ipython>=8.7.0,<4",
"numpy[foo,bar]>=1.10.0,<2",
"scikit-learn>1.2,<1.4;sys_platform=='win32'",
"scikit-learn>1.2;sys_platform!='win32'"
]
7 changes: 6 additions & 1 deletion tests/test_data/pyproject_pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ name = "tests"
description = "This is just a dummy package for testing the spec 0 update github action and should not be used"
requires-python = ">=3.10"
version = "0.1.0"
dependencies = ["ipython>=8.7.0,<4", "numpy[foo,bar]>=1.10.0,<2"]
dependencies = [
"ipython>=8.7.0,<4",
"numpy[foo,bar]>=1.10.0,<2",
"scikit-learn>1.2,<1.4;sys_platform=='win32'",
"scikit-learn>1.2;sys_platform!='win32'"
]

[build-system]
build-backend = "hatchling.build"
Expand Down
8 changes: 6 additions & 2 deletions tests/test_data/pyproject_pixi_updated.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ name = "tests"
description = "This is just a dummy package for testing the spec 0 update github action and should not be used"
requires-python = ">=3.11"
version = "0.1.0"
dependencies = ["ipython>=8.8.0,<4", "numpy[foo,bar]>=1.25.0,<2"]

dependencies = [
"ipython>=8.8.0,<4",
"numpy[foo,bar]>=1.25.0,<2",
"scikit-learn>=1.3.0,<1.4;sys_platform=='win32'",
"scikit-learn>=1.3.0;sys_platform!='win32'"
]
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]
Expand Down
6 changes: 5 additions & 1 deletion tests/test_data/pyproject_updated.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ build-backend = "setuptools.build_meta"

[project]
name = "setuptools_test"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
'numpy>=1.25.0,<2',
'pandas>=1.0.0,<3',
'xarray>=2023.1.0',
"ipython>=8.8.0,<4",
"numpy[foo,bar]>=1.25.0,<2",
"scikit-learn>=1.3.0,<1.4;sys_platform=='win32'",
"scikit-learn>=1.3.0;sys_platform!='win32'"
]
25 changes: 20 additions & 5 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,61 @@ def test_parsing_incorrect():

def test_pep_dependency_parsing():
matplotlib_str = "matplotlib"
pkg, features, spec = parse_pep_dependency(matplotlib_str)
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)

assert pkg == "matplotlib", pkg
assert features is None, features
assert spec is None, spec
assert env is None, env


def test_pep_dependency_parsing_with_spec_and_optional_dep():
matplotlib_str = "matplotlib[foo,bar]>=3.7.0,<4"
pkg, features, spec = parse_pep_dependency(matplotlib_str)
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)

assert pkg == "matplotlib", pkg
assert features == "[foo,bar]", features
assert spec == SpecifierSet(">=3.7.0,<4"), spec
assert env is None, env


def test_pep_dependency_parsing_with_spec():
matplotlib_str = "matplotlib>=3.7.0,<4"
pkg, features, spec = parse_pep_dependency(matplotlib_str)
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)

assert pkg == "matplotlib", pkg
assert features is None, features
assert spec == SpecifierSet(">=3.7.0,<4"), spec
assert env is None, env


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

assert pkg == "matplotlib", pkg
assert features is None, features
assert spec == urlparse(
" https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686"
), spec
assert env is None, env


def test_pep_dependency_parsing_extra_restrictions():
matplotlib_str = "matplotlib>=3.7.0,<4,!=3.8.14"
pkg, features, spec = parse_pep_dependency(matplotlib_str)
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)

assert pkg == "matplotlib", pkg
assert features is None, features
assert spec == SpecifierSet("!=3.8.14,<4,>=3.7.0"), spec
assert env is None, env


def test_pep_dependency_parsing_with_environment_marker():
matplotlib_str = "matplotlib>=3.7.0,<4;sys_platform != 'win32'"
pkg, features, spec, env = parse_pep_dependency(matplotlib_str)

assert pkg == "matplotlib", pkg
assert features is None, features
assert spec == SpecifierSet(">=3.7.0,<4"), spec
assert env == ";sys_platform != 'win32'", env