[Pythonmac-SIG] Python modules that are a PITA
Schollnick, Benjamin
Benjamin.Schollnick@usa.xerox.com
Thu, 20 Mar 2003 12:28:51 -0500
> We're using the following snippet in the setup.py for PyObjC,
> use something like this in PYTHONSTARTUP file when building and
> installing extension modules:
>
> if sys.platform == 'darwin':
> # Apple has used build options that don't work with a
> # Remove '-arch i386' from the LDFLAGS.
> import distutils.sysconfig
> distutils.sysconfig.get_config_vars()
> x = distutils.sysconfig._config_vars['LDSHARED']
> y = x.replace('-arch i386', '')
> if y != x:
> print "Fixing Apple strangeness in Python configuration"
> distutils.sysconfig._config_vars['LDSHARED'] = y
Ron,
The snippet works, but... I think this is a little clearer...
if sys.platform == 'darwin':
# Apple ... blah ...
import distutils.sysconfig
x = distutils.sysconfig._config_vars['LDSHARED']
if x.find ("-arch i386") == 1:
# Fixing Apple config...
print "Fixing Apple strangeness in Python configuration"
distutils.sysconfig._config_vars ['LDSHARED'] = x.replace
("-arch i386", "")
Please don't think your code isn't readable, I just consider the obvious
test statement to be slightly clearer....
- Benjamin