Hi,
I'm trying to package a python module that has a C extension that has a special preprocessor that turns protocol definition files into C.
Currently, I have a makefile that calls the rxgen program[*]:
./rxgen/rxgen.pl rpc-api/*
which produces four C files (afs_xg.[ch] and afs_py.[ch]) that then get compiled and linked together with some other sources into an extension module:
from distutils.core import setup, Extension
setup(name = "kafs", version = "0.1", description = "AFS filesystem management scripting and commands", author = "David Howells", author_email = "dhowells@redhat.com", license = "GPLv2", ext_modules = [Extension("kafs", sources = [ "afs_xg.c", "kafs.c", "afs_py.c", "py_passwd.c", "py_rxgen.c", "py_rxconn.c", "py_rxsplit.c", "af_rxrpc.c" ], extra_compile_args = [ "-O0", "-Wp,-U_FORTIFY_SOURCE", ], libraries = [ "k5crypto", "krb5" ] )])
Is there any way of making the Extension module do the rxgen step? It would be possible to convert the rxgen perl scripts into python and call it directly - it's just that I find it easier to write a file parser in perl, at least initially.
David
[*] yes, I know, it's written in perl
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 09/03/2015 05:36 AM, David Howells wrote:
Hi,
I'm trying to package a python module that has a C extension that has a special preprocessor that turns protocol definition files into C.
Currently, I have a makefile that calls the rxgen program[*]:
./rxgen/rxgen.pl rpc-api/*
which produces four C files (afs_xg.[ch] and afs_py.[ch]) that then get compiled and linked together with some other sources into an extension module:
from distutils.core import setup, Extension
setup(name = "kafs", version = "0.1", description = "AFS filesystem management scripting and commands", author = "David Howells", author_email = "dhowells@redhat.com", license = "GPLv2", ext_modules = [Extension("kafs", sources = [ "afs_xg.c", "kafs.c", "afs_py.c", "py_passwd.c", "py_rxgen.c", "py_rxconn.c", "py_rxsplit.c", "af_rxrpc.c" ], extra_compile_args = [ "-O0", "-Wp,-U_FORTIFY_SOURCE", ], libraries = [ "k5crypto", "krb5" ] )])
Is there any way of making the Extension module do the rxgen step? It would be possible to convert the rxgen perl scripts into python and call it directly - it's just that I find it easier to write a file parser in perl, at least initially.
David
[*] yes, I know, it's written in perl
See the setup.py in this package:
https://git.fedorahosted.org/cgit/python-libnuma.git/
It runs msgfmt on the provided message catalog files at build time.
- --Guy
Guy Streeter streeter@redhat.com wrote:
I'm trying to package a python module that has a C extension that has a special preprocessor that turns protocol definition files into C.
... See the setup.py in this package:
https://git.fedorahosted.org/cgit/python-libnuma.git/
It runs msgfmt on the provided message catalog files at build time.
Okay, thanks for the reference. That takes me part the way there - but as I understand it, message catalogue files aren't then compiled with the C compiler and built into the extension module, right?
David
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 09/03/2015 10:36 AM, David Howells wrote:
Guy Streeter streeter@redhat.com wrote:
I'm trying to package a python module that has a C extension that has a special preprocessor that turns protocol definition files into C.
... See the setup.py in this package:
https://git.fedorahosted.org/cgit/python-libnuma.git/
It runs msgfmt on the provided message catalog files at build time.
Okay, thanks for the reference. That takes me part the way there - but as I understand it, message catalogue files aren't then compiled with the C compiler and built into the extension module, right?
No, they are just installed with the package.
Do you just need to control the build order, so your preprocessor runs first? You can over-ride "build" to make that happen. Or use something like
./setup.py build_prep build_ext build
- --Guy
Guy Streeter streeter@redhat.com wrote:
Do you just need to control the build order, so your preprocessor runs first?
Yes.
You can over-ride "build" to make that happen.
Okay.
Or use something like
./setup.py build_prep build_ext build
I'd rather not do that - I'd rather 'build' built everything.
David