-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsetup.py
180 lines (166 loc) · 6.01 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
import io
import os
import platform
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import relpath
from os.path import splitext
from setuptools import Extension
from setuptools import find_packages
from setuptools import setup
import numpy as np
try:
from setuptools_scm import get_version
except Exception:
try:
import pip
package='setuptools_scm'
if hasattr(pip, 'main'):
pip.main(['install', package])
else:
pip._internal.main(['install', package])
from setuptools_scm import get_version
except Exception:
print("**could not install pip or setuptools_scm, version is defaulted")
def myversion():
version = '2.0.23'
try:
mversion = get_version()
s = mversion.split('.')
if len(s) >=3:
# see if we can parse the current version
if int(s[0])==2 and int(s[1])==0:
version = '2.0.'
lastnum = s[2]
for i in lastnum:
if i >='0' and i <= '9':
version = version + i
except Exception:
pass
return version
thisversion=myversion()
def writeversion():
text_file = open("src/pnumpy/_version.py", "w")
strver = f"__version__='{thisversion}'"
n = text_file.write(strver)
text_file.close()
return thisversion
# Enable code coverage for C code: we can't use CFLAGS=-coverage in tox.ini, since that may mess with compiling
# dependencies (e.g. numpy). Therefore we set SETUP_PY_EXT_COVERAGE after deps have been safely installed).
if os.environ.get('SETUP_PY_EXT_COVERAGE') == 'yes' and platform.system() == 'Linux':
CFLAGS = os.environ['CFLAGS'] = '-fprofile-arcs -ftest-coverage -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION'
LFLAGS = os.environ['LFLAGS'] = '-lgcov'
else:
CFLAGS = '-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION'
LFLAGS = ''
if platform.system() == 'Windows':
CFLAGS += ' /Ox /Ob2 /Oi /Ot /d2FH4- /GS- /arch:AVX2'
else:
CFLAGS += ' -mavx2 -fpermissive -Wno-unused-variable -Wno-unused-function -std=c++11 -pthread -falign-functions=32'
if platform.system() == 'Linux':
LFLAGS += ' -lm'
def read(*names, **kwargs):
with io.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
) as fh:
return fh.read()
with open("README.md") as readme:
long_description = readme.read()
import _add_newdocs
_add_newdocs.main()
setup(
name='pnumpy',
#version=get_git_version(), #'0.0.0',
version=writeversion(),
license='MIT',
description='Faster loops for NumPy using multithreading and other tricks',
long_description=long_description,
long_description_content_type="text/markdown",
author='Quansight',
author_email='[email protected]',
url='https://quansight.github.io/pnumpy/stable/index.html',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
"Development Status :: 4 - Beta",
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Utilities',
],
project_urls={
'Changelog': 'https://github.com/Quansight/pnumpy/blob/master/CHANGELOG.rst',
'Issue Tracker': 'https://github.com/Quansight/pnumpy/issues',
},
keywords=[
# eg: 'keyword1', 'keyword2', 'keyword3',
],
#setup_requires=['setuptools_scm'],
#use_scm_version = {
# 'version_scheme': 'post-release',
# 'local_scheme': 'no-local-version',
# 'write_to': 'src/pnumpy/_version.py',
# 'write_to_template': '__version__ = "{version}"',
#},
python_requires='>=3.6',
install_requires=[
# eg: 'aspectlib==1.1.1', 'six>=1.7',
'numpy>=1.18.0', # has ufunc hooks
],
extras_require={
# eg:
# 'rst': ['docutils>=0.11'],
# ':python_version=="2.6"': ['argparse'],
},
ext_modules=[
Extension(
'pnumpy._pnumpy',
sources=['src/pnumpy/_pnumpy.cpp',
'src/pnumpy/module_init.cpp',
'src/pnumpy/common.cpp',
'src/pnumpy/ledger.cpp',
'src/pnumpy/getitem.cpp',
'src/pnumpy/conversions.cpp',
'src/pnumpy/recycler.cpp',
'src/pnumpy/sorting.cpp',
#'src/pnumpy/arange.cpp',
#'src/pnumpy/item_selection.cpp',
'src/atop/atop.cpp',
'src/atop/threads.cpp',
'src/atop/recarray.cpp',
'src/atop/sort.cpp',
'src/atop/fill.cpp',
'src/atop/ops_binary.cpp',
'src/atop/ops_compare.cpp',
'src/atop/ops_unary.cpp',
'src/atop/ops_trig.cpp',
'src/atop/ops_log.cpp',
],
extra_compile_args=CFLAGS.split(),
extra_link_args=LFLAGS.split(),
include_dirs=['src/pnumpy', 'src/atop', np.get_include()],
py_limited_api=True,
)
],
)