-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
123 lines (114 loc) · 4.39 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
import platform
import os
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
ON_WINDOWS = platform.system() == 'Windows'
_comp_args = ["DSHARED=1"]
sources = ['src/gmpy2.c']
# Utility function to read the contents of the README file.
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
class Gmpy2Build(build_ext):
description = "Build gmpy2 with custom build options"
user_options = build_ext.user_options + [
('fast', None,
"Depend on MPFR and MPC internal implementations details"
"(even more than the standard build)"),
('gcov', None, "Enable GCC code coverage collection"),
('vector', None, "Include the vector_XXX() functions;"
"they are unstable and under active development"),
('static', None, "Enable static linking compile time options."),
('static-dir=', None, "Enable static linking and specify location."),
('gdb', None, "Build with debug symbols."),
]
def initialize_options(self):
build_ext.initialize_options(self)
self.fast = False
self.gcov = False
self.vector = False
self.static = False
self.static_dir = False
self.gdb = False
def finalize_options(self):
build_ext.finalize_options(self)
if self.fast:
_comp_args.append('DFAST=1')
if self.gcov:
if ON_WINDOWS:
raise ValueError("Cannot enable GCC code coverage on Windows")
_comp_args.append('DGCOV=1')
_comp_args.append('O0')
_comp_args.append('-coverage')
self.libraries.append('gcov')
if self.vector:
_comp_args.append('DVECTOR=1')
if self.static:
_comp_args.remove('DSHARED=1')
_comp_args.append('DSTATIC=1')
if self.gdb:
_comp_args.append('ggdb')
if self.static_dir:
_comp_args.remove('DSHARED=1')
_comp_args.append('DSTATIC=1')
self.include_dirs.append(self.static_dir + '/include')
self.library_dirs.append(self.static_dir + '/lib')
def build_extensions(self):
compiler = self.compiler.compiler_type
_prefix = '-' if compiler != 'msvc' else '/'
for i in range(len(_comp_args)):
_comp_args[i] = ''.join([_prefix, _comp_args[i]])
build_ext.build_extensions(self)
extensions = [
Extension('gmpy2.gmpy2',
sources=sources,
include_dirs=['./src'],
libraries=['mpc','mpfr','gmp'] + ([] if ON_WINDOWS else ['m']),
extra_compile_args=_comp_args,
)
]
cmdclass = {'build_ext': Gmpy2Build}
setup(
name="gmpy2",
version="2.1.3",
author="Case Van Horsen",
author_email="[email protected]",
cmdclass=cmdclass,
license="LGPL-3.0+",
url="https://github.com/aleaxit/gmpy",
description="gmpy2 interface to GMP/MPIR, MPFR, "
"and MPC for Python 2.7 and 3.5+",
long_description=read('README'),
zip_safe=False,
include_package_data=True,
package_data={'gmpy2': [
'*.pxd',
'gmpy2.h',
'*.dll',
]},
packages=find_packages(),
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: C',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords="gmp mpfr mpc multiple-precision arbitrary-precision precision bignum",
ext_modules=extensions,
)