Skip to content

Commit

Permalink
FIX: Hook
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Dec 20, 2024
1 parent 7d585c9 commit 323d48b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
8 changes: 4 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ dependencies:
- joblib
- jupyter
- lazy_loader >=0.3
- matplotlib >=3.6
- matplotlib >=3.7
- mffpy >=0.5.7
- mne-qt-browser
- nibabel
- nilearn
- numba
- numpy >=1.23,<3
- numpy >=1.25,<3
- openmeeg >=2.5.5
- packaging
- pandas
- pandas >=2.0
- pillow
- pip
- pooch >=1.5
Expand All @@ -47,7 +47,7 @@ dependencies:
- qdarkstyle !=3.2.2
- qtpy
- scikit-learn
- scipy >=1.9
- scipy >=1.11.1
- sip
- snirf
- statsmodels
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ dependencies = [
"decorator",
"jinja2",
"lazy_loader >= 0.3",
"matplotlib >= 3.6",
"numpy >= 1.23,<3",
"matplotlib >= 3.7", # 2023/02/13
"numpy >= 1.25,<3", # 2023/06/17
"packaging",
"pooch >= 1.5",
"scipy >= 1.9",
"scipy >= 1.11.1", # 2023/06/25
"tqdm",
]
description = "MNE-Python project for MEG and EEG data analysis."
Expand Down Expand Up @@ -111,7 +111,7 @@ full-no-qt = [
"nilearn",
"numba",
"openmeeg >= 2.5.5",
"pandas", # >= 1.5
"pandas >= 2.0", # 2023/04/03
"pillow", # for `Brain.save_image` and `mne.Report`
"pyarrow", # only needed to avoid a deprecation warning in pandas
"pybv",
Expand Down
19 changes: 10 additions & 9 deletions tools/environment_old.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# THIS FILE IS AUTO-GENERATED BY tools/hooks/update_environment_file.py AND WILL BE OVERWRITTEN
name: mne
channels:
- conda-forge
dependencies:
- python=3.10
- numpy=1.24
- scipy=1.10
- matplotlib=3.6
- pandas=1.5.2
- scikit-learn=1.2
- nibabel # whichever one works
- python =3.10
- numpy =1.25
- scipy =1.11.1
- matplotlib =3.7
- pandas =2.0
- scikit-learn
- nibabel
- tqdm
- pooch
- pooch =1.5
- decorator
- packaging
- jinja2
- lazy_loader
- lazy_loader =0.3
31 changes: 28 additions & 3 deletions tools/hooks/update_environment_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def split_dep(dep):
translations = dict(neo="python-neo")
pip_deps = set()
conda_deps = set()
check_old = (
"numpy scipy matplotlib pandas scikit-learn nibabel tqdm pooch decorator "
"packaging jinja2 lazy_loader"
).split()
old_deps = [None] * len(check_old)
for dep in deps:
package_name, version_spec = split_dep(dep)
# handle package name differences
Expand All @@ -64,6 +69,12 @@ def split_dep(dep):
pip_deps.add(f" {line}")
else:
conda_deps.add(line)
# old deps
if package_name in check_old:
# Pull out >= part, change to =, remove < (which should be after comma)
old_deps[check_old.index(package_name)] = line.replace(">=", "=").split(",")[0]
for di, dep in enumerate(old_deps):
assert dep is not None, f"Missing {check_old[di]}"

# TODO: temporary workaround while we wait for a release containing the fix for
# https://github.com/mamba-org/mamba/issues/3467
Expand All @@ -77,19 +88,33 @@ def split_dep(dep):
"""
pip_section = pip_section if len(pip_deps) else ""
# prepare the env file
env = f"""\
header = f"""\
# THIS FILE IS AUTO-GENERATED BY {'/'.join(Path(__file__).parts[-3:])} AND WILL BE OVERWRITTEN
name: mne
channels:
- conda-forge
dependencies:
dependencies:""" # noqa: E501
env = f"""{header}
- python {req_python}
{newline.join(sorted(conda_deps, key=str.casefold))}
{pip_section}""" # noqa: E501
{pip_section}"""

env_file = repo_root / "environment.yml"
old_env = env_file.read_text("utf-8")
if old_env != env:
diff = "\n".join(difflib.unified_diff(old_env.splitlines(), env.splitlines()))
print(f"Updating {env_file} with diff:\n{diff}")
env_file.write_text(env, encoding="utf-8")

# Now we also updated tools/environment_old.yml
env_file = repo_root / "tools" / "environment_old.yml"
old_env = env_file.read_text("utf-8")
use_python = req_python.replace(">=", "=")
env = f"""{header}
- python {use_python}
{newline.join(old_deps)}
"""
if old_env != env:
diff = "\n".join(difflib.unified_diff(old_env.splitlines(), env.splitlines()))
print(f"Updating {env_file} with diff:\n{diff}")
env_file.write_text(env, encoding="utf-8")

0 comments on commit 323d48b

Please sign in to comment.