|
7 | 7 | from multiprocessing import cpu_count |
8 | 8 |
|
9 | 9 | import versioneer |
10 | | -from setuptools import setup, find_packages, Extension |
| 10 | +from setuptools import setup, find_packages |
11 | 11 |
|
12 | 12 | cpython = platform.python_implementation() == 'CPython' |
13 | 13 |
|
14 | 14 | try: |
15 | 15 | from Cython.Build import cythonize |
| 16 | + from Cython.Distutils.extension import Extension |
| 17 | + from Cython.Distutils import build_ext |
16 | 18 | except ImportError: |
| 19 | + from setuptools import Extension |
17 | 20 | USING_CYTHON = False |
18 | 21 | else: |
19 | 22 | USING_CYTHON = True |
20 | 23 |
|
21 | 24 | ext = 'pyx' if USING_CYTHON else 'c' |
22 | | -sources = ['ssh2/*.%s' % (ext,)] |
| 25 | +sources = glob('ssh2/*.%s' % (ext,)) |
23 | 26 | _libs = ['ssh2'] |
24 | 27 | _comp_args = ["-ggdb"] # , "-O3"] |
| 28 | +_embedded_lib = bool(os.environ.get('EMBEDDED_LIB')) |
| 29 | +cython_args = {'cython_compile_time_env': {'EMBEDDED_LIB': _embedded_lib}} \ |
| 30 | + if USING_CYTHON else {} |
25 | 31 |
|
| 32 | +extensions = [ |
| 33 | + Extension(sources[i].split('.')[0].replace('/', '.'), |
| 34 | + sources=[sources[i]], |
| 35 | + libraries=_libs, |
| 36 | + extra_compile_args=_comp_args, |
| 37 | + **cython_args |
| 38 | + # For conditional compilation |
| 39 | + # pyrex_compile_time_env |
| 40 | + ) |
| 41 | + for i in range(len(sources))] |
| 42 | + |
| 43 | +cmdclass = versioneer.get_cmdclass() |
26 | 44 | if USING_CYTHON: |
27 | | - extensions = [ |
28 | | - Extension('ssh2/*', |
29 | | - sources=sources, |
30 | | - libraries=_libs, |
31 | | - extra_compile_args=_comp_args, |
32 | | - # For conditional compilation |
33 | | - # pyrex_compile_time_env |
34 | | - ) |
35 | | - ] |
36 | | - extensions = cythonize( |
37 | | - extensions, |
38 | | - compiler_directives={'embedsignature': True, |
39 | | - 'optimize.use_switch': True, |
40 | | - 'boundscheck': False, |
41 | | - 'wraparound': False, |
42 | | - }, |
43 | | - nthreads=cpu_count()) |
44 | | -else: |
45 | | - sources = glob(sources[0]) |
46 | | - extensions = [ |
47 | | - Extension(sources[i].split('.')[0].replace('/', '.'), |
48 | | - sources=[sources[i]], |
49 | | - libraries=_libs, |
50 | | - extra_compile_args=_comp_args, |
51 | | - # For conditional compilation |
52 | | - # pyrex_compile_time_env |
53 | | - ) |
54 | | - for i in range(len(sources))] |
| 45 | + cmdclass['build_ext'] = build_ext |
55 | 46 |
|
56 | 47 | setup( |
57 | 48 | name='ssh2-python', |
58 | 49 | version=versioneer.get_version(), |
59 | | - cmdclass=versioneer.get_cmdclass(), |
| 50 | + cmdclass=cmdclass, |
60 | 51 | url='https://github.com/ParallelSSH/ssh2-python', |
61 | 52 | license='LGPLv2', |
62 | 53 | author='Panos Kittenis', |
|
0 commit comments