-
Notifications
You must be signed in to change notification settings - Fork 257
deps: Update minimal for sympy and numpy #2605
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| pip>=9.0.1 | ||
| numpy>1.16,<2.3 | ||
| sympy>=1.9,<1.14 | ||
| numpy>=2,<2.2.6 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the max numpy downgrade?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a downgrade. numpy is currently at 2.2.5 and making minor releases so the dependabot is not catching those because they always satisfy the current major release bound. It's just refining it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any systems that we know about where Devito is running and numpy is a system dependency (ie: air-gapped systems) where this might cause an issue?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Colab was yes, but I think they updated recently. Handling the sympy-numpy versions is quite a pain if we allow numpy <2 but will see if can find a way. |
||
| sympy>=1.12.1,<1.14; python_version < '3.10' | ||
| sympy>=1.12.1,<1.15; python_version >= '3.10' | ||
| psutil>=5.1.0,<8.0 | ||
| py-cpuinfo<10 | ||
| cgen>=2020.1,<2021 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,98 +1,29 @@ | ||
| import versioneer | ||
|
|
||
| import os | ||
| try: | ||
| import importlib.metadata as metadata | ||
| get_version = lambda x: metadata.version(x) | ||
| PkgNotFound = metadata.PackageNotFoundError | ||
| parse_version = lambda x: metadata.version(x) | ||
| except ImportError: | ||
| import pkg_resources | ||
| get_version = lambda x: pkg_resources.get_distribution(x).version | ||
| PkgNotFound = pkg_resources.DistributionNotFound | ||
| parse_version = lambda x: pkg_resources.parse_version(x) | ||
|
|
||
| from setuptools import setup, find_packages | ||
| import versioneer | ||
|
|
||
|
|
||
| def min_max(pkgs, pkg_name): | ||
| pkg = [p for p in pkgs if pkg_name in p][0] | ||
| minsign = '>=' if '>=' in pkg else '>' | ||
| maxsign = '<=' if '<=' in pkg else '<' | ||
| vmin = pkg.split(minsign)[1].split(',')[0] | ||
| vmax = pkg.split(maxsign)[-1] | ||
| return vmin, vmax | ||
|
|
||
|
|
||
| def numpy_compat(required): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Ok so basically this was not doing anything because pip runs the build in isolation so sympy is never found and it always default to the |
||
| new_reqs = [r for r in required if "numpy" not in r and "sympy" not in r] | ||
| sympy_lb, sympy_ub = min_max(required, "sympy") | ||
| numpy_lb, numpy_ub = min_max(required, "numpy") | ||
|
|
||
| # Due to api changes in numpy 2.0, it requires sympy 1.12.1 at the minimum | ||
| # Check if sympy is installed and enforce numpy version accordingly. | ||
| # If sympy isn't installed, enforce sympy>=1.12.1 and numpy>=2.0 | ||
| try: | ||
| sympy_version = get_version("sympy") | ||
| min_ver2 = parse_version("1.12.1") | ||
| if parse_version(sympy_version) < min_ver2: | ||
| new_reqs.extend([f"numpy>{numpy_lb},<2.0", f"sympy=={sympy_version}"]) | ||
| else: | ||
| new_reqs.extend([f"numpy>=2.0,<{numpy_ub}", f"sympy=={sympy_version}"]) | ||
| except PkgNotFound: | ||
| new_reqs.extend([f"sympy>=1.12.1,<{sympy_ub}", f"numpy>=2.0,<{numpy_ub}"]) | ||
|
|
||
| return new_reqs | ||
|
|
||
|
|
||
| with open('requirements.txt') as f: | ||
| required = f.read().splitlines() | ||
| required = numpy_compat(required) | ||
|
|
||
| with open('requirements-optional.txt') as f: | ||
| optionals = f.read().splitlines() | ||
|
|
||
| with open('requirements-testing.txt') as f: | ||
| testing = f.read().splitlines() | ||
|
|
||
| with open('requirements-mpi.txt') as f: | ||
| mpis = f.read().splitlines() | ||
|
|
||
| with open('requirements-nvidia.txt') as f: | ||
| nvidias = f.read().splitlines() | ||
| def load_requirements(filename): | ||
| with open(filename) as f: | ||
| lines = f.read().splitlines() | ||
| return lines | ||
|
|
||
| reqs = [] | ||
| for ir in required: | ||
| if ir[0:3] == 'git': | ||
| name = ir.split('/')[-1] | ||
| reqs += ['%s @ %s@main' % (name, ir)] | ||
| else: | ||
| reqs += [ir] | ||
|
|
||
| extras_require = {} | ||
| for mreqs, mode in (zip([optionals, mpis, nvidias, testing], | ||
| ['extras', 'mpi', 'nvidia', 'tests'])): | ||
| opt_reqs = [] | ||
| for ir in mreqs: | ||
| # For conditionals like pytest=2.1; python == 3.6 | ||
| if ';' in ir: | ||
| entries = ir.split(';') | ||
| extras_require[entries[1]] = entries[0] | ||
| # Git repos, install main | ||
| if ir[0:3] == 'git': | ||
| name = ir.split('/')[-1] | ||
| opt_reqs += ['%s @ %s@main' % (name, ir)] | ||
| else: | ||
| opt_reqs += [ir] | ||
| extras_require[mode] = opt_reqs | ||
| reqs = load_requirements('requirements.txt') | ||
| extras_require = { | ||
| 'mpi': load_requirements('requirements-mpi.txt'), | ||
| 'nvidia': load_requirements('requirements-nvidia.txt'), | ||
| 'tests': load_requirements('requirements-testing.txt'), | ||
| 'extras': load_requirements('requirements-optional.txt'), | ||
| } | ||
|
|
||
| # If interested in benchmarking devito, we need the `examples` too | ||
| exclude = ['docs', 'tests'] | ||
| try: | ||
| if not bool(int(os.environ.get('DEVITO_BENCHMARKS', 0))): | ||
| exclude += ['examples'] | ||
| else: | ||
| required += testing | ||
| reqs += extras_require['tests'] | ||
| except (TypeError, ValueError): | ||
| exclude += ['examples'] | ||
|
|
||
|
|
||
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.
since I'm paranoid, could you try a
git grep _cachein SymPy 1.14 to be sure they haven't added any other random caches?