-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsetup.py
executable file
·109 lines (96 loc) · 3.65 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
#! /usr/bin/env python3
import os
import platform
from distutils.sysconfig import get_config_vars
from setuptools import setup
from setuptools.extension import Extension
PKG_DIR = 'pyroaring'
PLATFORM_WINDOWS = (platform.system() == 'Windows')
PLATFORM_MACOSX = (platform.system() == 'Darwin')
# Read version file from the src
with open("pyroaring/version.pxi") as fp:
exec(fp.read())
VERSION = __version__ # noqa: F821
# Remove -Wstrict-prototypes option
# See http://stackoverflow.com/a/29634231/4110059
if not PLATFORM_WINDOWS:
cfg_vars = get_config_vars()
for key, value in cfg_vars.items():
if type(value) is str:
cfg_vars[key] = value.replace("-Wstrict-prototypes", "")
try:
with open('README.rst') as f:
long_description = ''.join(f.readlines())
except (IOError, ImportError, RuntimeError):
print('Could not generate long description.')
long_description = ''
if PLATFORM_WINDOWS:
pyroaring_module = Extension(
'pyroaring',
sources=[os.path.join(PKG_DIR, 'pyroaring.pyx'), os.path.join(PKG_DIR, 'roaring.c')],
language='c++',
)
libraries = None
else:
compile_args = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D _GLIBCXX_ASSERTIONS']
if PLATFORM_MACOSX:
compile_args.append('-mmacosx-version-min=10.14')
if 'DEBUG' in os.environ:
compile_args.extend(['-O0', '-g'])
else:
compile_args.append('-O3')
if 'ARCHI' in os.environ:
if os.environ['ARCHI'] != "generic":
compile_args.extend(['-march=%s' % os.environ['ARCHI']])
# The '-march=native' flag is not universally allowed. In particular, it
# will systematically fail on aarch64 systems (like the new Apple M1 systems). It
# also creates troubles under macOS with pip installs and requires ugly workarounds.
# The best way to handle people who want to use -march=native is to ask them
# to pass ARCHI=native to their build process.
# else:
# compile_args.append('-march=native')
pyroaring_module = Extension(
'pyroaring',
sources=[os.path.join(PKG_DIR, 'pyroaring.pyx')],
extra_compile_args=compile_args + ["-std=c++11"],
language='c++',
)
# Because we compile croaring with a c compiler with sometimes incompatible arguments,
# define croaring compilation with an extra argument for the c11 standard, which is
# required for atomic support.
croaring = (
'croaring',
{
'sources': [os.path.join(PKG_DIR, 'roaring.c')],
"extra_compile_args": compile_args + ["-std=c11"],
},
)
libraries = [croaring]
setup(
name='pyroaring',
ext_modules=[pyroaring_module],
libraries=libraries,
package_data={'pyroaring': ['py.typed', '__init__.pyi']},
packages=['pyroaring'],
version=VERSION,
description='Library for handling efficiently sorted integer sets.',
long_description=long_description,
setup_requires=['cython'],
url='https://github.com/Ezibenroc/PyRoaringBitMap',
author='Tom Cornebize',
author_email='[email protected]',
license='MIT',
classifiers=[
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
],
)