|
7 | 7 | """
|
8 | 8 | import os
|
9 | 9 |
|
10 |
| -DEBUG = True |
| 10 | +from distutils.core import setup, Extension |
| 11 | +import os |
| 12 | +import sysconfig |
| 13 | + |
| 14 | +DEBUG = False |
| 15 | +# Generally I write code so that if DEBUG is defined as 0 then all optimisations |
| 16 | +# are off and asserts are enabled. Typically run times of these builds are x2 to x10 |
| 17 | +# release builds. |
| 18 | +# If DEBUG > 0 then extra code paths are introduced such as checking the integrity of |
| 19 | +# internal data structures. In this case the performance is by no means comparable |
| 20 | +# with release builds. |
| 21 | +DEBUG_LEVEL = 0 |
| 22 | + |
| 23 | +# Python stlib requirement: |
| 24 | +LANGUAGE_STANDARD = "c99" |
| 25 | +# Our level of C++ |
| 26 | +#LANGUAGE_STANDARD = "c++11" |
11 | 27 |
|
12 |
| -extra_compile_args=["-std=c99", ] |
| 28 | +# Common flags for both release and debug builds. |
| 29 | +extra_compile_args = sysconfig.get_config_var('CFLAGS').split() |
| 30 | +extra_compile_args += ["-std=%s" % LANGUAGE_STANDARD, "-Wall", "-Wextra"] |
13 | 31 | if DEBUG:
|
14 |
| - extra_compile_args += ["-g3", "-O0", "-DDEBUG=1",] |
| 32 | + extra_compile_args += ["-g3", "-O0", "-DDEBUG=%s" % DEBUG_LEVEL, "-UNDEBUG"] |
15 | 33 | else:
|
16 |
| - extra_compile_args += ["-DNDEBUG", "-Os"] |
| 34 | + extra_compile_args += ["-DNDEBUG", "-O3"] |
17 | 35 |
|
| 36 | +PACKAGE_NAME = 'cPyExtPatt' |
18 | 37 |
|
19 | 38 | from distutils.core import setup, Extension
|
20 | 39 | setup(
|
21 |
| - name = 'cPyExtPatt', |
| 40 | + name = PACKAGE_NAME, |
22 | 41 | version = '0.1.0',
|
23 | 42 | author = 'Paul Ross',
|
24 |
| - author_email = 'cpipdev@gmail.com', |
| 43 | + author_email = 'apaulross@gmail.com', |
25 | 44 | maintainer = 'Paul Ross',
|
26 |
| - maintainer_email = 'cpipdev@gmail.com', |
27 |
| - description = 'Python Extension Patterns.', |
28 |
| - long_description = """Examples of good and bad practice with Python Extensions.""", |
| 45 | + maintainer_email = 'apaulross@gmail.com', |
| 46 | + description = 'Python C Extension Patterns.', |
| 47 | + long_description = """Examples of good and bad practice with Python C Extensions.""", |
29 | 48 | platforms = ['Mac OSX', 'POSIX',],
|
30 | 49 | classifiers = [
|
31 | 50 | 'Development Status :: 3 - Alpha',
|
|
38 | 57 | 'Programming Language :: Python',
|
39 | 58 | 'Topic :: Programming',
|
40 | 59 | ],
|
41 |
| - license = 'GNU General Public License v2 (GPLv2)', |
| 60 | + licence = 'GNU General Public License v2 (GPLv2)', |
42 | 61 | ext_modules=[
|
43 |
| - Extension("cExceptions", sources=['cExceptions.c',], |
| 62 | + Extension(f"{PACKAGE_NAME}.cExceptions", sources=['src/cpy/cExceptions.c',], |
44 | 63 | include_dirs = ['/usr/local/include',], # os.path.join(os.getcwd(), 'include'),],
|
45 | 64 | library_dirs = [os.getcwd(),], # path to .a or .so file(s)
|
46 | 65 | extra_compile_args=extra_compile_args,
|
47 | 66 | ),
|
48 |
| - Extension("cModuleGlobals", sources=['cModuleGlobals.c',], |
| 67 | + Extension(f"{PACKAGE_NAME}.cModuleGlobals", sources=['src/cpy/cModuleGlobals.c',], |
49 | 68 | include_dirs = ['/usr/local/include',], # os.path.join(os.getcwd(), 'include'),],
|
50 | 69 | library_dirs = [os.getcwd(),], # path to .a or .so file(s)
|
51 | 70 | extra_compile_args=extra_compile_args,
|
52 | 71 | ),
|
53 |
| - Extension("cObj", sources=['cObjmodule.c',], |
| 72 | + Extension(f"{PACKAGE_NAME}.cObj", sources=['src/cpy/cObjmodule.c',], |
54 | 73 | include_dirs = ['/usr/local/include',], # os.path.join(os.getcwd(), 'include'),],
|
55 | 74 | library_dirs = [os.getcwd(),], # path to .a or .so file(s)
|
56 | 75 | extra_compile_args=extra_compile_args,
|
57 | 76 | ),
|
58 |
| - Extension("cParseArgs", sources=['cParseArgs.c',], |
| 77 | + Extension(f"{PACKAGE_NAME}.cParseArgs", sources=['src/cpy/cParseArgs.c',], |
59 | 78 | include_dirs = ['/usr/local/include',], # os.path.join(os.getcwd(), 'include'),],
|
60 | 79 | library_dirs = [os.getcwd(),], # path to .a or .so file(s)
|
61 | 80 | extra_compile_args=extra_compile_args,
|
62 | 81 | ),
|
63 |
| - Extension("cPyRefs", sources=['cPyRefs.c',], |
| 82 | + Extension(f"{PACKAGE_NAME}.cPyRefs", sources=['src/cpy/cPyRefs.c',], |
64 | 83 | include_dirs = ['/usr/local/include',], # os.path.join(os.getcwd(), 'include'),],
|
65 | 84 | library_dirs = [os.getcwd(),], # path to .a or .so file(s)
|
66 | 85 | #libraries = ['jpeg',],
|
|
0 commit comments