X-Git-Url: https://git.distorted.org.uk/~mdw/mLib-python/blobdiff_plain/a510e264770430077bb4dbacd104c6aae19bcdd6..efb0bf0ea231f3c53c4ac9c68405d511ec582ccb:/setup.py?ds=sidebyside diff --git a/setup.py b/setup.py index 34ea95f..1ec65dc 100755 --- a/setup.py +++ b/setup.py @@ -1,30 +1,46 @@ #! /usr/bin/python +import os as OS +import sys as SYS import distutils.core as DC -import Pyrex.Distutils as PXD +import Cython.Build as CB import mdwsetup as MS -MS.pkg_config('catacomb', '2.1.0') -MS.pkg_config('mLib', '2.1.0') +MS.pkg_config('mLib', '2.4.99~') -MS.derive('base64.pyx', 'codec.pyx.in', - {'CLASS': 'Base64', 'PREFIX': 'base64'}) -MS.derive('base32.pyx', 'codec.pyx.in', - {'CLASS': 'Base32', 'PREFIX': 'base32'}) -MS.derive('hex.pyx', 'codec.pyx.in', - {'CLASS': 'Hex', 'PREFIX': 'hex'}) - -mLib = DC.Extension('mLib', ['mLib.pyx', 'atom-base.c', 'array.c'], +PYVERSION = SYS.version_info[0:3] +pyxc = 'mLib-py%d.%d.%d.c' % PYVERSION +mLib = DC.Extension('mLib', [pyxc, + 'atom-base.c', + ##'array.c' + ], ##extra_compile_args = ['-O0'], include_dirs = MS.uniquify(MS.INCLUDEDIRS), library_dirs = MS.uniquify(MS.LIBDIRS), libraries = MS.uniquify(MS.LIBS)) -DC.setup(name = 'mLib-python', - version = MS.auto_version(), +## The `cythonize' function generates the C sources immediately, so we have +## to generate its inputs even earlier. +genfiles = [ +# MS.Derive('base64.pyx', 'codec.pyx.in', +# {'CLASS': 'Base64', 'PREFIX': 'base64'}), +# MS.Derive('base32.pyx', 'codec.pyx.in', +# {'CLASS': 'Base32', 'PREFIX': 'base32'}), +# MS.Derive('hex.pyx', 'codec.pyx.in', +# {'CLASS': 'Hex', 'PREFIX': 'hex'}) +] +for g in genfiles: g.gen() + +## Generate the main C code. +if OS.path.exists(pyxc): OS.rename(pyxc, "mLib.c") +CB.cythonize("mLib.pyx", compile_time_env = dict(PYVERSION = PYVERSION)) +OS.rename("mLib.c", pyxc) + +MS.setup(name = 'mLib-python', description = 'Python interface to mLib utilities library', author = 'Straylight/Edgeware', author_email = 'mdw@distorted.org.uk', license = 'GNU General Public License', ext_modules = [mLib], - cmdclass = { 'build_ext': PXD.build_ext }) + genfiles = genfiles, + cleanfiles = [pyxc])