-
Notifications
You must be signed in to change notification settings - Fork 13
/
setup.py
139 lines (115 loc) · 4.47 KB
/
setup.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
import setuptools
from Cython.Build import cythonize
import sys
import os
import numpy as np
with open("README.md", "r") as fh:
long_description = fh.read()
def no_cythonize(extensions, **_ignore):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in ('.pyx', '.py'):
if extension.language == 'c++':
ext = '.cpp'
else:
ext = '.c'
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions
USE_CYTHON = True
print('CYTHONIZING')
extensions = cythonize(
["pyapprox/cython/*.pyx"],
compiler_directives={'language_level': 3},
annotate=True)
setuptools.setup(
name="pyapprox",
version="1.0.3",
author="John D. Jakeman",
author_email="[email protected]",
description="High-dimensional function approximation and estimation",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/sandialabs/pyapprox",
packages=setuptools.find_packages(),
python_requires='>=3.7',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
include_dirs=[np.get_include()],
setup_requires=['numpy >= 1.16.4', 'Cython', 'scipy >= 1.0.0'],
install_requires=[
'numpy >= 1.16.4',
'matplotlib',
'scipy >= 1.0.0',
'Cython',
'sympy',
'torch',
'scikit-learn',
'coverage>=6.4',
'pytest-cov',
'pytest>=4.6',
'networkx',
# 'tqdm',
'numba',
'scikit-fem',
'umbridge',
],
extras_require={
'docs': ['numpydoc', 'sphinx', 'sphinx_automodapi', 'sphinx_rtd_theme',
'sphinx-gallery', 'jupyter']
},
ext_modules=extensions,
license='MIT',
)
#TODO see https://pytest-cov.readthedocs.io/en/latest/config.html
# to add config file for coverage tests to exclude certain files from coverage tests
# to install using specific version of python use, e.g.
# conda env create -f environment.yml python=3.9 --name pyapprox-base-3-9
# to run all tests use
# python -m unittest discover pyapprox
# run a doctest of a single module
# pytest -v --doctest-modules path/to/module.py
# run a doctest of a single function in a module
# pytest -v --doctest-modules path/to/module.py::path.to.module.Class.method
# The loading times of modules that depend on torch can
# increase if torch install from pip
# to install packages needed to compile docs run
# pip install -e .[docs]
# To test pyapprox on test.pypi use the following.
# Note the use of extra-index-url
# python -m pip install --extra-index-url=https://test.pypi.org/simple/ pyapprox==1.0.3
# To build wheel locally use
# python -m build
#to create from empty environment use from directory contatining setup
#pip install twine wheel setuptools numpy scipy cython && python setup.py sdist --format=gztar bdist_wheel
# To test wheel locally create virtual environment and install using
# pip install mypackage-0.31.0-py2.py3-none-any.whl
# with docs use (quotes are important)
# pip install 'mypackage-0.31.0-py2.py3-none-any.whl[docs]'
# When uploading to test.pypi.org if the last wheel is broken, e.g.
# mypackage-0.31.0-py2.py3-none-any.whl
# then add a build number, e.g. -1
# mypackage-0.31.0-1-py2.py3-none-any.whl
# or -2
# mypackage-0.31.0-2-py2.py3-none-any.whl
# and upload
# python -m twine upload --repository testpypi dist/*
# to catch warnings as errors from command, e.g. to run a unittest use
# python -W error -m unittest pyapprox.surrogates.tests.test_approximate.TestApproximate.test_approximate_fixed_pce
# to run a single test with pytest use
# pytest pyapprox/surrogates/tests/test_approximate.py -k test_cross_validate_pce_degree
# To ignore certain warnings use
# pytest pyapprox/surrogates/tests/test_approximate.py -k test_cross_validate_pce_degree -W ignore:FutureWarning
# However to isolate 3rd party warnings edit pypest.ini, e.g.
# [pytest]
# filterwarnings = ignore::FutureWarning:sklearn.*:
# "Individual warnings filters are specified as a sequence of fields separated by colons:"
# action:message:category:module:line
# run pytest coverage on a single test
# coverage run -m pytest -v tests/test_stats.py && coverage html && open htmlcov/index.html