-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
90 lines (71 loc) · 2.33 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
from setuptools import setup
from setuptools import Extension
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError
from distutils.errors import DistutilsExecError
from distutils.errors import DistutilsPlatformError
try:
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False
ext = '.pyx' if USE_CYTHON else '.c'
extensions = [
Extension('atomicl._cy', sources=[
'src/atomicl/_cy' + ext,
'src/atomicl/_atomic.c'
], include_dirs=['src/atomicl/'])
]
if USE_CYTHON:
extensions = cythonize(extensions, annotate=True)
class BuildFailed(BaseException):
pass
class ve_build_ext(build_ext):
def run(self):
try:
build_ext.run(self)
except (DistutilsPlatformError, FileNotFoundError):
raise BuildFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError,
DistutilsPlatformError, ValueError):
raise BuildFailed()
args = dict(
name='atomicl',
version='0.1.1',
keywords='atomiclong',
description='Yet another implementation of AtomicLong',
long_description=open('README.rst').read(),
author='Alex Khomchenko',
author_email='akhomchenko@gmail.com',
url='https://github.com/gagoman/atomicl',
license='MIT',
packages=['atomicl'],
package_dir={'': 'src'},
include_package_data=True,
zip_safe=False,
python_requires='~=3.4',
ext_modules=extensions,
cmdclass=dict(build_ext=ve_build_ext),
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
]
)
try:
setup(**args)
except BuildFailed:
print("************************************************************")
print("Cannot compile C accelerator module, use pure python version")
print("************************************************************")
del args['ext_modules']
del args['cmdclass']
setup(**args)