-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[MAINT] Automatic SPEC0 dependency version management #13451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
import warnings | ||
from datetime import timedelta | ||
|
||
import pandas as pd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pandas is a bit overkill, I just carried it over from the SPEC0 example scripts. I can refine this once everything's working.
Workflow is failing because the permissions aren't right to push the changes to this PR. I've been reading up on this, but can't seem to figure a solution out without adding a new PAT secret to the repo. |
xref to a couple things that (1) this might break (?) and (2) might have some code you could steal: pre-commit hooks that parse
|
# dependencies | |
- repo: local | |
hooks: | |
- id: update-env-file | |
name: Copy dependency changes from pyproject.toml to environment.yml | |
language: python | |
entry: ./tools/hooks/update_environment_file.py | |
files: '^(pyproject.toml|tools/hooks/update_environment_file.py)$' | |
- repo: local | |
hooks: | |
- id: dependency-sync | |
name: Copy core dependencies from pyproject.toml to README.rst | |
language: python | |
entry: ./tools/hooks/sync_dependencies.py | |
files: '^(pyproject.toml|tools/hooks/sync_dependencies.py)$' | |
additional_dependencies: ["mne==1.10.0"] |
In particular, for our README we re-write the pins to look pretty, this could be adapted maybe:
mne-python/tools/hooks/sync_dependencies.py
Lines 36 to 49 in 3cfac64
def _prettify_pin(pin): | |
if pin is None: | |
return "" | |
pins = pin.split(",") | |
replacements = { | |
"<=": " ≤ ", | |
">=": " ≥ ", | |
"<": " < ", | |
">": " > ", | |
} | |
for old, new in replacements.items(): | |
pins = [p.replace(old, new) for p in pins] | |
pins = reversed(pins) | |
return ",".join(pins) |
Reference issue (if any)
Fixes #13449
What does this implement/fix?
Adds a script that updates version specifiers for selected dependencies according to SPEC0 compliance.
Also adds a workflow that runs this script on PRs and just pushes the changes. End goal would be for the workflow to run on schedule and create a PR with any changes.
Additional information
Right now is only handling dependencies, not Python versions.
Am using
tomlkit
rather than the built-intomllib
due to requiring writing capabilities.The specifier parsing using the
packaging
tools works really nicely, but unfortunately spaces are not preserved, e.g.,numpy >= 1.26
becomesnumpy>=1.26
. For consistency, the script is applying this formatting to all pinned dependencies, even if they are not being changed. I'm open to changing/refining this.Had to do some roundabout way to find the target branch to push to, as the zizmor pre-commit check was warning of code injection via template expansion with
TARGET_BRANCH="${{ github.head_ref }}"
.Also had to update the yamllint rules for the pre-commit check to pass on my Windows machine (had the same issue in MNE-Connectivity before: mne-tools/mne-connectivity#198).