forked from pymor/pymor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies.py
executable file
·137 lines (126 loc) · 6.8 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
#!/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'
def _pymess(rev, major, minor, marker=True):
url = 'https://www.mpi-magdeburg.mpg.de/mpcsc/software/cmess/{rev}/pymess-{rev}-cp{major}{minor}-cp{major}{minor}m-manylinux1_x86_64.whl'
# tmp workaround till next release
url = 'https://pymor.github.io/wheels/pymess-{rev}-cp{major}{minor}-cp{major}{minor}m-manylinux1_x86_64.whl'
url = url.format(rev=rev, major=major, minor=minor)
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>={};python_version != "3.6" and python_version != "3.7" and python_version != "3.8"'.format(NUMPY),]
other = ['setuptools>=40.8.0', 'wheel', 'pytest-runner>=2.9', 'cython>=0.28', 'packaging',]
return numpys + other
install_requires = ['scipy>=1.1;python_version < "3.8"','scipy>=1.3.3;python_version >= "3.8"', 'Qt.py>=1.2.4', 'packaging','diskcache', 'docopt-ng'] + 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',
'meshio==3.3.1': 'needed to import Gmsh grids',
'pyopengl': 'fast solution visualization for builtin discretizations (PySide also required)',
'pyamg': 'algebraic multigrid solvers',
'pyevtk>=1.1': 'writing vtk output',
'pygmsh==6.0.2': 'python frontend for gmsh',
'sympy': 'symbolic mathematics',
'pythreejs': 'threejs bindings for python notebook visualization',
_PYTEST: 'testing framework required to execute unit tests',
'PySide2': 'solution visualization for builtin discretizations',
'ipywidgets': 'notebook GUI elements',
'nbresuse': 'resource usage indicator for notebooks',
'jupyter_contrib_nbextensions': 'modular collection of jupyter extensions',
'pillow': 'image library used for bitmap data functions'}
doc_requires = ['sphinx>=1.7', 'pymor-nb2plots>=0.7', 'matplotlib', 'PySide2', 'ipyparallel>=6.2.5',
'ipywidgets', 'sphinx-qt-documentation'] + install_requires
ci_requires = [_PYTEST, 'pytest-cov', 'pytest-xdist', 'check-manifest', 'nbconvert', 'pytest-parallel', 'virtualenv',
'readme_renderer[md]', 'rstcheck', 'codecov', 'twine', 'pytest-memprof', 'pytest-timeout',
'testipynb', "pypi-oldest-requirements>=2020.2", 'hypothesis[numpy,pytest]', ]
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',
'pyopengl': 'OpenGL'}
# Slycot is pinned due to buildsystem changes + missing wheels
optional_requirements_file_only = [_pymess('1.0.0', 3, 6),_pymess('1.0.0', 3, 7),
'slycot==0.3.3', '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(blacklist):
# 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 blacklist:
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
# blacklisted packages need a (minimal) compiler setup
# - nbresuse, pytest-memprof depend on psutil which has no wheels
# - slycot directly needs a compiler setup with BLAS
# - pymess is better installed from source (see README.md)
return {
'full': list(_candidates(blacklist=['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())))