forked from pymor/pymor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies.py
executable file
·144 lines (133 loc) · 7.4 KB
/
dependencies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python3
# This file is part of the pyMOR project (http://www.pymor.org).
# Copyright 2013-2020 pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
# DO NOT use any python features here that require 3.6 or newer
_PYTEST = 'pytest>=4.4'
_PYSIDE='PySide2!=5.15.2,!=5.15.2.*,!=5.11.*'
def _pymess(rev, major, minor, marker=True):
cpm = 'm' if minor < 8 else ''
url = 'https://www.mpi-magdeburg.mpg.de/mpcsc/software/cmess/{rev}/pymess-{rev}-cp{major}{minor}-cp{major}{minor}{cpm}-manylinux2014_x86_64.whl'
url = url.format(rev=rev, major=major, minor=minor, cpm=cpm)
if marker:
return '{url} ; python_version == "{major}.{minor}" and "linux" in sys_platform'.format(url=url, major=major, minor=minor)
return url
def setup_requires():
NUMPY = '1.16.0'
# numpy versions with filters according to minimal version with a wheel
numpys = ['numpy>={};python_version <= "3.6"'.format(NUMPY),
'numpy>=1.15.4;python_version == "3.7"',
'numpy>=1.17.5;python_version == "3.8"',
'numpy>=1.19.4;python_version >= "3.9"']
scipys = ['scipy>=1.1;python_version < "3.8"','scipy>=1.3.3;python_version == "3.8"', 'scipy>=1.5.4;python_version >= "3.9"']
# setuptools pin in accordance with numpy: https://github.com/numpy/numpy/pull/17000, see also https://github.com/pypa/setuptools/pull/2260 https://github.com/pypa/setuptools/pull/2259
other = ['setuptools>=40.8.0,<49.2.0', 'wheel', 'pytest-runner>=2.9', 'cython>=0.28', 'packaging',]
return numpys + other + scipys
# Qt bindings selectors are a woraround for https://bugreports.qt.io/browse/QTBUG-88688
install_requires = ['Qt.py>=1.2.4', 'packaging','diskcache', 'typer'] + setup_requires()
install_suggests = {'ipython>=5.0': 'an enhanced interactive python shell',
'ipyparallel>=6.2.5': 'required for pymor.parallel.ipython',
'matplotlib': 'needed for error plots in demo scipts',
'gmsh': 'this downloads the proper Gmsh binary',
'meshio==4.2.0': 'needed to import Gmsh grids',
'pyopengl': 'fast solution visualization for builtin discretizations (PySide also required)',
'pyamg;python_version<"3.8"': 'algebraic multigrid solvers',
'pyevtk>=1.1': 'writing vtk output',
'sympy': 'symbolic mathematics',
'pygments': 'highlighting code',
'pythreejs': 'threejs bindings for python notebook visualization',
_PYTEST: 'testing framework required to execute unit tests',
_PYSIDE: 'solution visualization for builtin discretizations',
'ipywidgets': 'notebook GUI elements',
'nbresuse': 'resource usage indicator for notebooks',
'torch;python_version<"3.9"': 'PyTorch open source machine learning framework',
'jupyter_contrib_nbextensions': 'modular collection of jupyter extensions',
'pillow': 'image library used for bitmap data functions'}
doc_requires = ['sphinx>=1.7', 'jupyter_sphinx', 'matplotlib', _PYSIDE, 'ipyparallel>=6.2.5', 'python-slugify',
'ipywidgets', 'sphinx-qt-documentation', 'bash_kernel', 'sphinx-material'] + install_requires
ci_requires = [_PYTEST, 'pytest-cov', 'pytest-xdist', 'check-manifest', 'nbconvert', 'pytest-parallel',
'readme_renderer[md]', 'rstcheck', 'codecov', 'twine', 'pytest-memprof', 'pytest-timeout',
'docutils', "pypi-oldest-requirements>=2020.2", 'hypothesis[numpy,pytest]>=5.19', 'PyQt5!=5.15.2,>5.7,!=5.15.2.*']
import_names = {'ipython': 'IPython',
'pytest-cache': 'pytest_cache',
'pytest-instafail': 'pytest_instafail',
'pytest-xdist': 'xdist',
'pytest-cov': 'pytest_cov',
'pytest-flakes': 'pytest_flakes',
'pytest-pep8': 'pytest_pep8',
_pymess('1.0.0', 3, 6, False): 'pymess',
_pymess('1.0.0', 3, 7, False): 'pymess',
_pymess('1.0.0', 3, 8, False): 'pymess',
_pymess('1.0.0', 3, 9, False): 'pymess',
'pyopengl': 'OpenGL'}
# Slycot is pinned due to buildsystem changes + missing wheels
optional_requirements_file_only = [_pymess('1.0.0', 3, i) for i in range(6,10)] + \
['slycot>=0.4.0', 'mpi4py']
def strip_markers(name):
for m in ';<>=':
try:
i = name.index(m)
name = name[:i].strip()
except ValueError:
continue
return name
def extras():
import pkg_resources
import itertools
def _candidates(blocklist):
# skip those which aren't needed in our current environment (py ver, platform)
for pkg in set(itertools.chain(doc_requires, install_suggests.keys())):
if pkg in blocklist:
continue
try:
marker = next(pkg_resources.parse_requirements(pkg)).marker
if marker is None or marker.evaluate():
yield pkg
except pkg_resources.RequirementParseError:
# try to fake a package to get the marker parsed
stripped = strip_markers(pkg)
fake_pkg = 'pip ' + pkg.replace(stripped, '')
try:
marker = next(pkg_resources.parse_requirements(fake_pkg)).marker
if marker is None or marker.evaluate():
yield pkg
except pkg_resources.RequirementParseError:
continue
# blocklisted packages need a (minimal) compiler setup
# - nbresuse, pytest-memprof depend on psutil which has no wheels
# - slycot directly needs a compiler setup with BLAS, plus scikit-build + cmake
# - pymess is better installed from source (see README.md)
return {
'full': list(_candidates(blocklist=['slycot', 'pymess', 'nbresuse', 'pytest-memprof'])),
'ci': ci_requires,
'docs': doc_requires,
}
toml_tpl = '''
[build-system]
requires = {0}
build-backend = "setuptools.build_meta"
'''
if __name__ == '__main__':
note = '# This file is autogenerated. Edit dependencies.py instead'
print(' '.join([i for i in install_requires + list(install_suggests.keys())]))
import os
import itertools
with open(os.path.join(os.path.dirname(__file__), 'requirements.txt'), 'wt') as req:
req.write(note+'\n')
for module in sorted(set(itertools.chain(install_requires, setup_requires()))):
req.write(module+'\n')
with open(os.path.join(os.path.dirname(__file__), 'requirements-optional.txt'), 'wt') as req:
req.write(note+'\n')
req.write('-r requirements.txt\n')
req.write('-r requirements-ci.txt\n')
for module in sorted(set(itertools.chain(optional_requirements_file_only,
doc_requires, install_suggests.keys()))):
req.write(module+'\n')
with open(os.path.join(os.path.dirname(__file__), 'requirements-ci.txt'), 'wt') as req:
req.write('-r requirements.txt\n')
req.write(note+'\n')
for module in sorted(ci_requires):
req.write(module+'\n')
with open(os.path.join(os.path.dirname(__file__), 'pyproject.toml'), 'wt') as toml:
toml.write(note)
toml.write(toml_tpl.format(str(setup_requires())))