classification
Title: Be more careful about selecting the compiler in distutils
Type: Stage:
Components: Distutils Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: merwok Nosy List: Arfrever, djc, dnozay, jcea, merwok
Priority: normal Keywords:

Created on 2012-02-16 09:37 by djc, last changed 2013-06-17 18:48 by dnozay.

Messages (5)
msg153471 - (view) Author: Dirkjan Ochtman (djc) * (Python committer) Date: 2012-02-16 09:37
distutils incorrectly handles CFLAGS as 1 argument instead of
space-separated list of arguments. distutils should respect environment
variables, which set compiler, linker etc.

--- Lib/distutils/unixccompiler.py
+++ Lib/distutils/unixccompiler.py
@@ -297,7 +297,7 @@
        # this time, there's no way to determine this information from
        # the configuration data stored in the Python installation, so
        # we use this hack.
-        compiler = os.path.basename(sysconfig.get_config_var("CC"))
+        compiler = os.path.basename(self.compiler[0])
        if sys.platform[:6] == "darwin":
            # MacOSX's linker doesn't understand the -R flag at all
            return "-L" + dir

Patch was created by Arfrever Frehtes Taifersar Arahesis (arfrever.fta@gmail.com). It was originally written for PyPy, but it seems like it should actually apply to the stdlib. This patch is for 2.7, I'm hoping it could be taken as a bug fix.
msg153569 - (view) Author: Éric Araujo (merwok) * (Python committer) Date: 2012-02-17 16:52
Could you explain more about what the bug is?
msg153585 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * Date: 2012-02-17 17:47
The bug is specific to PyPy. PyPy has no Makefile, so sysconfig.get_config_var("CC") returns None in PyPy. The first paragraph in message #153471 is about a different patch, not this patch.
msg153625 - (view) Author: Éric Araujo (merwok) * (Python committer) Date: 2012-02-18 02:03
> PyPy has no Makefile, so sysconfig.get_config_var("CC") returns None in PyPy.
Do you think the stdlib sysconfig could be changed to make this call return something meaningful, or should the code use another method to find the compiler to use?

(Getting config vars for 'SO' is one of the (surprisingly few) issues I’ve found when trying to run distutils2 tests with PyPy, I’d love to fix it.)
msg191358 - (view) Author: (dnozay) Date: 2013-06-17 18:48
affects PyPy, here are the downstream issues:
- https://bugs.pypy.org/issue662
- https://bugs.pypy.org/issue674
- https://bugs.pypy.org/issue1057
History
Date User Action Args
2013-06-17 18:48:05dnozaysetnosy: + dnozay
messages: + msg191358
2012-02-19 04:30:50jceasetnosy: + jcea
2012-02-18 02:03:06merwoksetmessages: + msg153625
2012-02-17 17:47:05Arfreversetmessages: + msg153585
2012-02-17 16:52:06merwoksetnosy: + Arfrever, merwok
messages: + msg153569

assignee: merwok
components: + Distutils
2012-02-16 09:37:19djcsetversions: + Python 2.7
2012-02-16 09:37:14djccreate