I'm currently trying to start looking into auto-configuration...
is there a way to access the parsed config.h file from within
the "config" command instance ?
Also, the config class doesn't allow defining macros (e.g. to
enable full __GNU__ support in gcc). Is there a way to define
per-compiler define symbols in the setup() constructor or by
subclassing compiler classes ?
Python Pages: http://www.lemburg.com/python/
some of you may have noticed that the Distutils allow customized command
classes by inheriting them. This is extremely powerful especially when
it comes to compatibility fixes.
I'll summarize all of my custom functions which will work around a
number of unknown/known/fixed bugs in the Distutils.
If you want to be compatible with older versions of the Distutils, you
can include them in your setup.py file.
1) Distutils traceback when DISTUTILS_DEBUG is set. This is a known
but unfixed bug.
Just override the dump_dirs function in install.py with your own:
from distutils.core import DEBUG
def dump_dirs (self, msg):
from distutils.fancy_getopt import longopt_xlate
print msg + ":"
for opt in self.user_options:
opt_name = opt
if opt_name[-1] == "=":
opt_name = opt_name[0:-1]
opt_name = string.translate(self.negative_opt[opt_name],
val = not getattr(self, opt_name)
opt_name = string.translate(opt_name, longopt_xlate)
val = getattr(self, opt_name)
print " %s: %s" % (opt_name, val)
2) the 'config' target does not initialize all values. This is a known
and fixed bug (fixed in version 1.0.1):
from types import StringType
"""fix up types of option values. This is cut'n'paste from
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or 
elif type(self.include_dirs) is StringType:
self.include_dirs = string.split(self.include_dirs, os.pathsep)
if self.libraries is None:
self.libraries = 
elif type(self.libraries) is StringType:
self.libraries = [self.libraries]
if self.library_dirs is None:
self.library_dirs = 
elif type(self.library_dirs) is StringType:
self.library_dirs = string.split(self.library_dirs, os.pathsep)
3) Use this only if you have man(1) files and you want to build RPM
The bdist_rpm command cannot handle man pages.
Whats happening here? The rpm command calls
python setup.py install --root=... --record=INSTALLED_FILES
In INSTALLED_FILES are now all installed files listed inclusive a
man page, for example ./usr/man/man1/myprog.1
But this man page gets compressed by rpm and we have now
This makes subsequent 'rpm' commands fail which are based on the
filenames found in INSTALLED_FILES.
Below you see a quick and very dirty hack: just append ".gz" to all
man file names in the INSTALLED_FILES index.
Of course the proper solution would be to define multiple handler
classes for all kinds of documentation (man pages, info pages, html
pages ...). But thats a long way to go.
from types import StringType
"""My own data installer to handle .man pages"""
def run (self):
for f in self.data_files:
if type(f) == StringType:
# it's a simple file, so copy it
self.warn("setup script did not provide a directory for "
"'%s' -- installing right in '%s'" %
# it's a tuple with path to install to and a list of files
dir = f
if not os.path.isabs(dir):
dir = os.path.join(self.install_dir, dir)
dir = change_root(self.root, dir)
for data in f:
def _install_file(self, filename, dirname):
(out, _) = self.copy_file(filename, dirname)
# match for man pages .[0-9]
if re.search(r'/man/.+\.\d$', out):
out = out+".gz"
is there an easy way to pass swig a -I option? Or maybe run the
preprocessor over the main .i file before calling swig on it?
thanks for any insights :)
I speak for me and myself, but not my shadow.
How can I say distutils to build a python interpreter with my own
extension module linked statically. I must do some malloc debugging im
my module and want to link dmalloc with the module, but there seems to
be no success, I guess there are some initializations missing. I can't
find any hint in their documentation.
) tel. : +49 (40) 3 61 49 - 73 74
C[_] These opinions might be mine, but never those of my employer.
On 01 December 2000, Thomas Heller said:
> Distutils currently only supports build_*** commands for
> C-libraries and Python extensions.
> Shouldn't there also be build commands for shared libraries,
> executable programs and static Python binaries?
Andrew and I talked about this a bit yesterday, and the proposed
interface is as follows:
python setup.py build_ext --static
will compile all extensions in the current module distribution, but
instead of creating a .so (.pyd) file for each one, will create a new
python binary in build/bin.<plat>.
Issue to be resolved: what to call the new python binary, especially
when installing it (presumably we *don't* want to clobber the stock
binary, but supplement it with (eg.) "foopython").
Note that there is no provision for selectively building some extensions
as shared. This means that Andrew's Distutil-ization of the standard
library will have to override the build_ext command and have some extra
way to select extensions for shared/static. Neither of us considered
this a problem.
> BTW: Distutils-sig seems pretty dead these days...
Yeah, that's a combination of me playing on other things and python.net
email being dead for over a week. I'll cc the sig on this and see if
this interface proposal gets anyone's attention.
I've managed to get a PIL setup mostly working with the new
Imaging-1.1.1 but I fail to see how to automate the
libImaging/libImaging build. I see there is a build_clib command, but
how should clibs be specified in the setup.py?
I looked for the sig archives, but got a server down message.