[issue9047] Python 2.7rc2 includes -isysroot twice on each gcc command line

Ronald Oussoren report at bugs.python.org
Sat Jul 24 14:10:55 CEST 2010


Ronald Oussoren <ronaldoussoren at mac.com> added the comment:

The root cause of having the flags twice is that the Makefile explicitly sets LDFLAGS in the environment before when running setup.py, and that distutils appens the value of $(LDFLAGS) to $(LDSHARED) when LDFLAGS is set in the environment.

Line from the makefile:
    $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;

And in Lib/distutils/ccompiler.py (in customize_compiler):

        if 'LDFLAGS' in os.environ:
            ldshared = ldshared + ' ' + os.environ['LDFLAGS']

A quick workaround to remove the duplicate flags is to explictly remove the related values from os.environ before calling main in setup.py:


# --install-platlib
if __name__ == '__main__':
    import os
    del os.environ['LDFLAGS']
    main()

I've attached a patch that implements this behavior. I'm not 100% sure this is the right solution because sysconfig._parse_makefile also looks at the environment and it may be better to remove the code from ccompiler.customize_compiler instead.

----------
keywords: +patch
nosy: +tarek
Added file: http://bugs.python.org/file18181/setup.py.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9047>
_______________________________________


More information about the Python-bugs-list mailing list