-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
executable file
·53 lines (38 loc) · 1.04 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
#!/usr/bin/env python3
from typing import Dict
import sys
import os
from setuptools import setup, Extension
# Conditional Cython setup
BUILD_OPTIONAL = os.environ.get('CIBUILDWHEEL', '0') != '1'
CYTHONIZE = False
if '--cythonize' in sys.argv:
CYTHONIZE = True
sys.argv.remove('--cythonize')
elif not BUILD_OPTIONAL:
CYTHONIZE = True
ext = 'pyx' if CYTHONIZE else 'c'
extensions = [
Extension('pe._cy_machine',
[f'pe/_cy_machine.{ext}'],
optional=BUILD_OPTIONAL),
]
if CYTHONIZE:
try:
from Cython.Build import cythonize
except ImportError:
sys.exit('Cython is required for building the extension modules.')
extensions = cythonize(extensions, language_level='3')
# Dynamic project metadata
base_dir = os.path.dirname(__file__)
meta: Dict[str, str] = {}
with open(os.path.join(base_dir, "pe", "_meta.py")) as f:
exec(f.read(), meta)
# Main setup call
setup(
version=meta['__version__'],
ext_modules=extensions,
package_data={
'pe': ['*.pyx', '*.pxd'],
},
)