New submission from Samuel John:

In the `_osx_support.py` module, there seems to be a bug in the method 
`compiler_fixup` which occurs if 

* the `customize_compiler` method from `distutils/sysconfig` has been called 
and after that
* `_compile` from `distutils/unixcompiler.py` is called. The `_compile` method 
uses `_osx_support.compiler_fixup`.

The critical line in compiler_fixup is:

`compiler_so = list(compiler_so)`.

Usually `compiler_so` is a list like `['cc']` but not when `customize_compiler` 
(from sysconfig) has been called. The value returned by 
`sysconfig.get_config_var('LDSHARED')` is a unicode like for example in the 
case of a Python 2.7.5 built via Homebrew: 
  
    "cc -bundle -undefined dynamic_lookup -L/homebrew/lib 
-L/homebrew/opt/sqlite/lib -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk".
When `list()` is applied to the value, it is split at each character and that 
cannot be intended.

I am not sure if I fully understand, but to fix this in `compiler_fixup`, 
instead of `compiler_so = list(compiler_so)`, I'd propose something along the 
lines of:

    if isinstance(compiler_so, (str,unicode)):
        compiler_so = compiler_so.split()

I found this by trying to `pip install cython` (it uses customize_compiler, I 
guess) on a homebrewed python.

To reproduce in an interactive shell we can emulate what is going on by calling 
`compiler_fixup` directly with the values sysconfig has stored. The exact 
string does not matter, because I think the any value returned by 
`sysconfig_get_config_var` is a (unicode) string and not a list:

    import sysconfig
    import _osx_support
    
_osx_support.compiler_fixup(sysconfig.get_config_var('LDSHARED'),sysconfig.get_config_var('CFLAGS'))


Not sure if other python versions are affected. I wasn't aware of 
`_osx_support` at all until now.

----------
assignee: ronaldoussoren
components: Macintosh
messages: 190140
nosy: hynek, ned.deily, ronaldoussoren, samueljohn
priority: normal
severity: normal
status: open
title: _osx_support compiler_fixup
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18071>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to