Skip to content

Commit 91b4089

Browse files
author
tarek.ziade
committed
fixed #1520877: now distutils reads Read from the environment/Makefile
git-svn-id: http://svn.python.org/projects/python/trunk@69342 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 9e4e2fe commit 91b4089

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

Lib/distutils/sysconfig.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ def customize_compiler(compiler):
165165
varies across Unices and is stored in Python's Makefile.
166166
"""
167167
if compiler.compiler_type == "unix":
168-
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
168+
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar) = \
169169
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
170-
'CCSHARED', 'LDSHARED', 'SO')
170+
'CCSHARED', 'LDSHARED', 'SO', 'AR')
171171

172172
if 'CC' in os.environ:
173173
cc = os.environ['CC']
@@ -188,6 +188,8 @@ def customize_compiler(compiler):
188188
cpp = cpp + ' ' + os.environ['CPPFLAGS']
189189
cflags = cflags + ' ' + os.environ['CPPFLAGS']
190190
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
191+
if 'AR' in os.environ:
192+
ar = os.environ['AR']
191193

192194
cc_cmd = cc + ' ' + cflags
193195
compiler.set_executables(
@@ -196,7 +198,8 @@ def customize_compiler(compiler):
196198
compiler_so=cc_cmd + ' ' + ccshared,
197199
compiler_cxx=cxx,
198200
linker_so=ldshared,
199-
linker_exe=cc)
201+
linker_exe=cc,
202+
archiver=ar)
200203

201204
compiler.shared_lib_extension = so_ext
202205

Lib/distutils/tests/test_sysconfig.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
class SysconfigTestCase(unittest.TestCase):
1010

11+
def setUp(self):
12+
self.old_AR = os.environ.get('AR')
13+
14+
def tearDown(self):
15+
if self.old_AR is not None:
16+
os.environ['AR'] = self.old_AR
17+
1118
def test_get_config_h_filename(self):
1219
config_h = sysconfig.get_config_h_filename()
1320
self.assert_(os.path.isfile(config_h), config_h)
@@ -32,6 +39,21 @@ def test_get_config_vars(self):
3239
self.assert_(isinstance(cvars, dict))
3340
self.assert_(cvars)
3441

42+
def test_customize_compiler(self):
43+
44+
os.environ['AR'] = 'xxx'
45+
46+
# make sure AR gets caught
47+
class compiler:
48+
compiler_type = 'unix'
49+
50+
def set_executables(self, **kw):
51+
self.exes = kw
52+
53+
comp = compiler()
54+
sysconfig.customize_compiler(comp)
55+
self.assertEquals(comp.exes['archiver'], 'xxx')
56+
3557

3658
def test_suite():
3759
suite = unittest.TestSuite()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ Core and Builtins
149149
Library
150150
-------
151151

152+
- Issue #1520877: Now distutils.sysconfig reads $AR from the
153+
environment/Makefile. Patch by Douglas Greiman.
154+
152155
- Issue #4285: Change sys.version_info to be a named tuple. Patch by
153156
Ross Light.
154157

0 commit comments

Comments
 (0)