Commit | Line | Data |
---|---|---|
a510e264 MW |
1 | #! /usr/bin/python |
2 | ||
efb0bf0e MW |
3 | import os as OS |
4 | import sys as SYS | |
a510e264 | 5 | import distutils.core as DC |
efb0bf0e | 6 | import Cython.Build as CB |
a510e264 MW |
7 | import mdwsetup as MS |
8 | ||
efb0bf0e | 9 | MS.pkg_config('mLib', '2.4.99~') |
a510e264 | 10 | |
efb0bf0e MW |
11 | PYVERSION = SYS.version_info[0:3] |
12 | pyxc = 'mLib-py%d.%d.%d.c' % PYVERSION | |
13 | mLib = DC.Extension('mLib', [pyxc, | |
14 | 'atom-base.c', | |
15 | ##'array.c' | |
16 | ], | |
a510e264 MW |
17 | ##extra_compile_args = ['-O0'], |
18 | include_dirs = MS.uniquify(MS.INCLUDEDIRS), | |
19 | library_dirs = MS.uniquify(MS.LIBDIRS), | |
20 | libraries = MS.uniquify(MS.LIBS)) | |
21 | ||
efb0bf0e MW |
22 | ## The `cythonize' function generates the C sources immediately, so we have |
23 | ## to generate its inputs even earlier. | |
24 | genfiles = [ | |
965caf5f MW |
25 | MS.Derive('base64.pyx', 'codec.pyx.in', |
26 | {'CLASS': 'Base64', 'PREFIX': 'base64'}), | |
27 | MS.Derive('base32.pyx', 'codec.pyx.in', | |
28 | {'CLASS': 'Base32', 'PREFIX': 'base32'}), | |
29 | MS.Derive('hex.pyx', 'codec.pyx.in', | |
30 | {'CLASS': 'Hex', 'PREFIX': 'hex'}) | |
efb0bf0e MW |
31 | ] |
32 | for g in genfiles: g.gen() | |
33 | ||
34 | ## Generate the main C code. | |
35 | if OS.path.exists(pyxc): OS.rename(pyxc, "mLib.c") | |
965caf5f MW |
36 | CB.cythonize("mLib.pyx", |
37 | compile_time_env = dict(PYVERSION = PYVERSION), | |
38 | compiler_directives = dict(c_string_encoding = 'utf8')) | |
efb0bf0e MW |
39 | OS.rename("mLib.c", pyxc) |
40 | ||
976d8e49 | 41 | MS.setup(name = 'mLib-python', |
a510e264 MW |
42 | description = 'Python interface to mLib utilities library', |
43 | author = 'Straylight/Edgeware', | |
44 | author_email = 'mdw@distorted.org.uk', | |
45 | license = 'GNU General Public License', | |
46 | ext_modules = [mLib], | |
efb0bf0e MW |
47 | genfiles = genfiles, |
48 | cleanfiles = [pyxc]) |