From 323d48b98d703988d88b508e297219d7302cf4b7 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 20 Dec 2024 10:50:45 -0500 Subject: [PATCH] FIX: Hook --- environment.yml | 8 +++---- pyproject.toml | 8 +++---- tools/environment_old.yml | 19 ++++++++-------- tools/hooks/update_environment_file.py | 31 +++++++++++++++++++++++--- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/environment.yml b/environment.yml index 898132bc0a4..172a5ed9748 100644 --- a/environment.yml +++ b/environment.yml @@ -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 @@ -47,7 +47,7 @@ dependencies: - qdarkstyle !=3.2.2 - qtpy - scikit-learn - - scipy >=1.9 + - scipy >=1.11.1 - sip - snirf - statsmodels diff --git a/pyproject.toml b/pyproject.toml index 3626da6f3df..dd29118fb3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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." @@ -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", diff --git a/tools/environment_old.yml b/tools/environment_old.yml index 4515f9cd611..de79d26eed6 100644 --- a/tools/environment_old.yml +++ b/tools/environment_old.yml @@ -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 diff --git a/tools/hooks/update_environment_file.py b/tools/hooks/update_environment_file.py index b88308e20db..98fbe530267 100755 --- a/tools/hooks/update_environment_file.py +++ b/tools/hooks/update_environment_file.py @@ -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 @@ -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 @@ -77,15 +88,16 @@ 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") @@ -93,3 +105,16 @@ def split_dep(dep): 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")