| 1 | #! /usr/bin/python |
| 2 | |
| 3 | import os as OS |
| 4 | import sys as SYS |
| 5 | import distutils.core as DC |
| 6 | import Cython.Build as CB |
| 7 | import mdwsetup as MS |
| 8 | |
| 9 | MS.pkg_config('mLib', '2.4.99~') |
| 10 | |
| 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 | ], |
| 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 | |
| 22 | ## The `cythonize' function generates the C sources immediately, so we have |
| 23 | ## to generate its inputs even earlier. |
| 24 | genfiles = [ |
| 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'}) |
| 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") |
| 36 | CB.cythonize("mLib.pyx", |
| 37 | compile_time_env = dict(PYVERSION = PYVERSION), |
| 38 | compiler_directives = dict(c_string_encoding = 'utf8')) |
| 39 | OS.rename("mLib.c", pyxc) |
| 40 | |
| 41 | MS.setup(name = 'mLib-python', |
| 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], |
| 47 | genfiles = genfiles, |
| 48 | cleanfiles = [pyxc]) |