summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/ccompiler.py6
-rw-r--r--Lib/distutils/command/bdist_msi.py16
-rw-r--r--Lib/distutils/command/build_ext.py5
-rw-r--r--Lib/distutils/command/upload.py2
-rw-r--r--Lib/distutils/msvccompiler.py2
-rw-r--r--Lib/distutils/sysconfig.py19
-rw-r--r--Lib/distutils/unixccompiler.py64
-rw-r--r--Lib/distutils/util.py49
8 files changed, 145 insertions, 18 deletions
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index 6dad757..1349abe 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -15,7 +15,6 @@ from distutils.spawn import spawn
from distutils.file_util import move_file
from distutils.dir_util import mkpath
from distutils.dep_util import newer_pairwise, newer_group
-from distutils.sysconfig import python_build
from distutils.util import split_quoted, execute
from distutils import log
@@ -368,7 +367,7 @@ class CCompiler:
# Get the list of expected output (object) files
objects = self.object_filenames(sources,
- strip_dir=python_build,
+ strip_dir=0,
output_dir=outdir)
assert len(objects) == len(sources)
@@ -475,8 +474,7 @@ class CCompiler:
which source files can be skipped.
"""
# Get the list of expected output (object) files
- objects = self.object_filenames(sources, strip_dir=python_build,
- output_dir=output_dir)
+ objects = self.object_filenames(sources, output_dir=output_dir)
assert len(objects) == len(sources)
if self.force:
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index f05d66c..75db877 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -1,5 +1,5 @@
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2005 Martin v. Löwis
+# Copyright (C) 2005, 2006 Martin v. Löwis
# Licensed to PSF under a Contributor Agreement.
# The bdist_wininst command proper
# based on bdist_wininst
@@ -16,7 +16,7 @@ from distutils.version import StrictVersion
from distutils.errors import DistutilsOptionError
from distutils import log
import msilib
-from msilib import schema, sequence, uisample
+from msilib import schema, sequence, text
from msilib import Directory, Feature, Dialog, add_data
class PyDialog(Dialog):
@@ -374,8 +374,8 @@ class bdist_msi (Command):
("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
("ProgressDlg", None, 1280)])
- add_data(db, 'ActionText', uisample.ActionText)
- add_data(db, 'UIText', uisample.UIText)
+ add_data(db, 'ActionText', text.ActionText)
+ add_data(db, 'UIText', text.UIText)
#####################################################################
# Standard dialogs: FatalError, UserExit, ExitDialog
fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
@@ -502,9 +502,9 @@ class bdist_msi (Command):
seldlg.back("< Back", None, active=0)
c = seldlg.next("Next >", "Cancel")
- c.event("SetTargetPath", "TARGETDIR", order=1)
- c.event("SpawnWaitDialog", "WaitForCostingDlg", order=2)
- c.event("EndDialog", "Return", order=3)
+ c.event("SetTargetPath", "TARGETDIR", ordering=1)
+ c.event("SpawnWaitDialog", "WaitForCostingDlg", ordering=2)
+ c.event("EndDialog", "Return", ordering=3)
c = seldlg.cancel("Cancel", "DirectoryCombo")
c.event("SpawnDialog", "CancelDlg")
@@ -561,7 +561,7 @@ class bdist_msi (Command):
c = whichusers.next("Next >", "Cancel")
c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
- c.event("EndDialog", "Return", order = 2)
+ c.event("EndDialog", "Return", ordering = 2)
c = whichusers.cancel("Cancel", "AdminInstall")
c.event("SpawnDialog", "CancelDlg")
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 5771252..9626710 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -689,6 +689,11 @@ class build_ext (Command):
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib, "m"] + extra
+
+ elif sys.platform == 'darwin':
+ # Don't use the default code below
+ return ext.libraries
+
else:
from distutils import sysconfig
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 6f4ce81..4a9ed39 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -6,7 +6,7 @@ from distutils.errors import *
from distutils.core import Command
from distutils.spawn import spawn
from distutils import log
-from md5 import md5
+from hashlib import md5
import os
import socket
import platform
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index f88f365..d24d0ac 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -618,7 +618,7 @@ class MSVCCompiler (CCompiler) :
"but the expected registry settings are not present.\n"
"You must at least run the Visual Studio GUI once "
"so that these entries are created.")
- break
+ break
return []
def set_path_env_var(self, name):
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 49536f0..e1397a1 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -366,8 +366,8 @@ def _init_posix():
# MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
# it needs to be compatible.
# If it isn't set we set it to the configure-time value
- if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'):
- cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET']
+ if sys.platform == 'darwin' and g.has_key('MACOSX_DEPLOYMENT_TARGET'):
+ cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
if cur_target == '':
cur_target = cfg_target
@@ -500,6 +500,21 @@ def get_config_vars(*args):
_config_vars['prefix'] = PREFIX
_config_vars['exec_prefix'] = EXEC_PREFIX
+ if sys.platform == 'darwin':
+ kernel_version = os.uname()[2] # Kernel version (8.4.3)
+ major_version = int(kernel_version.split('.')[0])
+
+ if major_version < 8:
+ # On Mac OS X before 10.4, check if -arch and -isysroot
+ # are in CFLAGS or LDFLAGS and remove them if they are.
+ # This is needed when building extensions on a 10.3 system
+ # using a universal build of python.
+ for key in ('LDFLAGS', 'BASECFLAGS'):
+ flags = _config_vars[key]
+ flags = re.sub('-arch\s+\w+\s', ' ', flags)
+ flags = re.sub('-isysroot [^ \t]* ', ' ', flags)
+ _config_vars[key] = flags
+
if args:
vals = []
for name in args:
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index 56998c3..324819d 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -42,6 +42,48 @@ from distutils import log
# should just happily stuff them into the preprocessor/compiler/linker
# options and carry on.
+def _darwin_compiler_fixup(compiler_so, cc_args):
+ """
+ This function will strip '-isysroot PATH' and '-arch ARCH' from the
+ compile flags if the user has specified one them in extra_compile_flags.
+
+ This is needed because '-arch ARCH' adds another architecture to the
+ build, without a way to remove an architecture. Furthermore GCC will
+ barf if multiple '-isysroot' arguments are present.
+ """
+ stripArch = stripSysroot = 0
+
+ compiler_so = list(compiler_so)
+ kernel_version = os.uname()[2] # 8.4.3
+ major_version = int(kernel_version.split('.')[0])
+
+ if major_version < 8:
+ # OSX before 10.4.0, these don't support -arch and -isysroot at
+ # all.
+ stripArch = stripSysroot = True
+ else:
+ stripArch = '-arch' in cc_args
+ stripSysroot = '-isysroot' in cc_args
+
+ if stripArch:
+ while 1:
+ try:
+ index = compiler_so.index('-arch')
+ # Strip this argument and the next one:
+ del compiler_so[index:index+2]
+ except ValueError:
+ break
+
+ if stripSysroot:
+ try:
+ index = compiler_so.index('-isysroot')
+ # Strip this argument and the next one:
+ del compiler_so[index:index+1]
+ except ValueError:
+ pass
+
+ return compiler_so
+
class UnixCCompiler(CCompiler):
compiler_type = 'unix'
@@ -108,8 +150,11 @@ class UnixCCompiler(CCompiler):
raise CompileError, msg
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
+ compiler_so = self.compiler_so
+ if sys.platform == 'darwin':
+ compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs)
try:
- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
+ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
except DistutilsExecError, msg:
raise CompileError, msg
@@ -172,7 +217,22 @@ class UnixCCompiler(CCompiler):
else:
linker = self.linker_so[:]
if target_lang == "c++" and self.compiler_cxx:
- linker[0] = self.compiler_cxx[0]
+ # skip over environment variable settings if /usr/bin/env
+ # is used to set up the linker's environment.
+ # This is needed on OSX. Note: this assumes that the
+ # normal and C++ compiler have the same environment
+ # settings.
+ i = 0
+ if os.path.basename(linker[0]) == "env":
+ i = 1
+ while '=' in linker[i]:
+ i = i + 1
+
+ linker[i] = self.compiler_cxx[i]
+
+ if sys.platform == 'darwin':
+ linker = _darwin_compiler_fixup(linker, ld_args)
+
self.spawn(linker + ld_args)
except DistutilsExecError, msg:
raise LinkError, msg
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 889bf13..1265f4c 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -45,6 +45,7 @@ def get_platform ():
osname = string.lower(osname)
osname = string.replace(osname, '/', '')
machine = string.replace(machine, ' ', '_')
+ machine = string.replace(machine, '/', '-')
if osname[:5] == "linux":
# At least on Linux/Intel, 'machine' is the processor --
@@ -66,6 +67,54 @@ def get_platform ():
m = rel_re.match(release)
if m:
release = m.group()
+ elif osname[:6] == "darwin":
+ #
+ # For our purposes, we'll assume that the system version from
+ # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set
+ # to. This makes the compatibility story a bit more sane because the
+ # machine is going to compile and link as if it were
+ # MACOSX_DEPLOYMENT_TARGET.
+ from distutils.sysconfig import get_config_vars
+ cfgvars = get_config_vars()
+
+ macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET')
+ if not macver:
+ macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET')
+
+ if not macver:
+ # Get the system version. Reading this plist is a documented
+ # way to get the system version (see the documentation for
+ # the Gestalt Manager)
+ try:
+ f = open('/System/Library/CoreServices/SystemVersion.plist')
+ except IOError:
+ # We're on a plain darwin box, fall back to the default
+ # behaviour.
+ pass
+ else:
+ m = re.search(
+ r'<key>ProductUserVisibleVersion</key>\s*' +
+ r'<string>(.*?)</string>', f.read())
+ f.close()
+ if m is not None:
+ macver = '.'.join(m.group(1).split('.')[:2])
+ # else: fall back to the default behaviour
+
+ if macver:
+ from distutils.sysconfig import get_config_vars
+ release = macver
+ osname = "macosx"
+
+
+ if (release + '.') < '10.4.' and \
+ get_config_vars().get('UNIVERSALSDK', '').strip():
+ # The universal build will build fat binaries, but not on
+ # systems before 10.4
+ machine = 'fat'
+
+ elif machine in ('PowerPC', 'Power_Macintosh'):
+ # Pick a sane name for the PPC architecture.
+ machine = 'ppc'
return "%s-%s-%s" % (osname, release, machine)