How to package python extensions that need a special preprocessor?

David Howells dhowells at redhat.com
Thu Sep 3 10:36:23 UTC 2015


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 at 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


More information about the devel mailing list