[Python-checkins] r83053 - in python/branches/py3k: Lib/distutils/archive_util.py Lib/distutils/bcppcompiler.py Lib/distutils/ccompiler.py Lib/distutils/cmd.py Lib/distutils/command/bdist.py Lib/distutils/command/bdist_dumb.py Lib/distutils/command/bdist_msi.py Lib/distutils/command/bdist_rpm.py Lib/distutils/command/bdist_wininst.py Lib/distutils/command/build.py Lib/distutils/command/build_clib.py Lib/distutils/command/build_ext.py Lib/distutils/command/build_py.py Lib/distutils/command/build_scripts.py Lib/distutils/command/config.py Lib/distutils/command/install.py Lib/distutils/command/register.py Lib/distutils/command/sdist.py Lib/distutils/command/upload.py Lib/distutils/config.py Lib/distutils/core.py Lib/distutils/cygwinccompiler.py Lib/distutils/dep_util.py Lib/distutils/dir_util.py Lib/distutils/dist.py Lib/distutils/emxccompiler.py Lib/distutils/errors.py Lib/distutils/extension.py Lib/distutils/fancy_getopt.py Lib/distutils/file_util.py Lib/distutils/filelist.py Lib/distutils/msvc9compiler.py Lib/distutils/msvccompiler.py Lib/distutils/sysconfig.py Lib/distutils/tests/support.py Lib/distutils/tests/test_archive_util.py Lib/distutils/tests/test_bdist.py Lib/distutils/tests/test_bdist_dumb.py Lib/distutils/tests/test_bdist_rpm.py Lib/distutils/tests/test_bdist_wininst.py Lib/distutils/tests/test_build_clib.py Lib/distutils/tests/test_build_ext.py Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_build_scripts.py Lib/distutils/tests/test_ccompiler.py Lib/distutils/tests/test_cmd.py Lib/distutils/tests/test_cygwinccompiler.py Lib/distutils/tests/test_dist.py Lib/distutils/tests/test_emxccompiler.py Lib/distutils/tests/test_extension.py Lib/distutils/tests/test_file_util.py Lib/distutils/tests/test_filelist.py Lib/distutils/tests/test_install.py Lib/distutils/tests/test_install_lib.py Lib/distutils/tests/test_register.py Lib/distutils/tests/test_sdist.py Lib/distutils/tests/test_sysconfig.py Lib/distutils/tests/test_unixccompiler.py Lib/distutils/tests/test_upload.py Lib/distutils/tests/test_util.py Lib/distutils/text_file.py Lib/distutils/unixccompiler.py Lib/distutils/util.py setup.py

tarek.ziade python-checkins at python.org
Thu Jul 22 14:50:06 CEST 2010


Author: tarek.ziade
Date: Thu Jul 22 14:50:05 2010
New Revision: 83053

Log:
reverted distutils its 3.1 state. All new work is now happening in disutils2, and distutils is now feature-frozen.

Removed:
   python/branches/py3k/Lib/distutils/tests/test_ccompiler.py
   python/branches/py3k/Lib/distutils/tests/test_emxccompiler.py
Modified:
   python/branches/py3k/Lib/distutils/archive_util.py
   python/branches/py3k/Lib/distutils/bcppcompiler.py
   python/branches/py3k/Lib/distutils/ccompiler.py
   python/branches/py3k/Lib/distutils/cmd.py
   python/branches/py3k/Lib/distutils/command/bdist.py
   python/branches/py3k/Lib/distutils/command/bdist_dumb.py
   python/branches/py3k/Lib/distutils/command/bdist_msi.py
   python/branches/py3k/Lib/distutils/command/bdist_rpm.py
   python/branches/py3k/Lib/distutils/command/bdist_wininst.py
   python/branches/py3k/Lib/distutils/command/build.py
   python/branches/py3k/Lib/distutils/command/build_clib.py
   python/branches/py3k/Lib/distutils/command/build_ext.py
   python/branches/py3k/Lib/distutils/command/build_py.py
   python/branches/py3k/Lib/distutils/command/build_scripts.py
   python/branches/py3k/Lib/distutils/command/config.py
   python/branches/py3k/Lib/distutils/command/install.py
   python/branches/py3k/Lib/distutils/command/register.py
   python/branches/py3k/Lib/distutils/command/sdist.py
   python/branches/py3k/Lib/distutils/command/upload.py
   python/branches/py3k/Lib/distutils/config.py
   python/branches/py3k/Lib/distutils/core.py
   python/branches/py3k/Lib/distutils/cygwinccompiler.py
   python/branches/py3k/Lib/distutils/dep_util.py
   python/branches/py3k/Lib/distutils/dir_util.py
   python/branches/py3k/Lib/distutils/dist.py
   python/branches/py3k/Lib/distutils/emxccompiler.py
   python/branches/py3k/Lib/distutils/errors.py
   python/branches/py3k/Lib/distutils/extension.py
   python/branches/py3k/Lib/distutils/fancy_getopt.py
   python/branches/py3k/Lib/distutils/file_util.py
   python/branches/py3k/Lib/distutils/filelist.py
   python/branches/py3k/Lib/distutils/msvc9compiler.py
   python/branches/py3k/Lib/distutils/msvccompiler.py
   python/branches/py3k/Lib/distutils/sysconfig.py
   python/branches/py3k/Lib/distutils/tests/support.py
   python/branches/py3k/Lib/distutils/tests/test_archive_util.py
   python/branches/py3k/Lib/distutils/tests/test_bdist.py
   python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py
   python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py
   python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py
   python/branches/py3k/Lib/distutils/tests/test_build_clib.py
   python/branches/py3k/Lib/distutils/tests/test_build_ext.py
   python/branches/py3k/Lib/distutils/tests/test_build_py.py
   python/branches/py3k/Lib/distutils/tests/test_build_scripts.py
   python/branches/py3k/Lib/distutils/tests/test_cmd.py
   python/branches/py3k/Lib/distutils/tests/test_cygwinccompiler.py
   python/branches/py3k/Lib/distutils/tests/test_dist.py
   python/branches/py3k/Lib/distutils/tests/test_extension.py
   python/branches/py3k/Lib/distutils/tests/test_file_util.py
   python/branches/py3k/Lib/distutils/tests/test_filelist.py
   python/branches/py3k/Lib/distutils/tests/test_install.py
   python/branches/py3k/Lib/distutils/tests/test_install_lib.py
   python/branches/py3k/Lib/distutils/tests/test_register.py
   python/branches/py3k/Lib/distutils/tests/test_sdist.py
   python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
   python/branches/py3k/Lib/distutils/tests/test_unixccompiler.py
   python/branches/py3k/Lib/distutils/tests/test_upload.py
   python/branches/py3k/Lib/distutils/tests/test_util.py
   python/branches/py3k/Lib/distutils/text_file.py
   python/branches/py3k/Lib/distutils/unixccompiler.py
   python/branches/py3k/Lib/distutils/util.py
   python/branches/py3k/setup.py

Modified: python/branches/py3k/Lib/distutils/archive_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/archive_util.py	(original)
+++ python/branches/py3k/Lib/distutils/archive_util.py	Thu Jul 22 14:50:05 2010
@@ -14,55 +14,15 @@
 from distutils.dir_util import mkpath
 from distutils import log
 
-try:
-    from pwd import getpwnam
-except ImportError:
-    getpwnam = None
-
-try:
-    from grp import getgrnam
-except ImportError:
-    getgrnam = None
-
-def _get_gid(name):
-    """Returns a gid, given a group name."""
-    if getgrnam is None or name is None:
-        return None
-    try:
-        result = getgrnam(name)
-    except KeyError:
-        result = None
-    if result is not None:
-        return result[2]
-    return None
-
-def _get_uid(name):
-    """Returns an uid, given a user name."""
-    if getpwnam is None or name is None:
-        return None
-    try:
-        result = getpwnam(name)
-    except KeyError:
-        result = None
-    if result is not None:
-        return result[2]
-    return None
-
-def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
-                 owner=None, group=None):
+def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0):
     """Create a (possibly compressed) tar file from all the files under
     'base_dir'.
 
     'compress' must be "gzip" (the default), "compress", "bzip2", or None.
-    (compress will be deprecated in Python 3.2)
-
-    'owner' and 'group' can be used to define an owner and a group for the
-    archive that is being built. If not provided, the current owner and group
-    will be used.
-
+    Both "tar" and the compression utility named by 'compress' must be on
+    the default program search path, so this is probably Unix-specific.
     The output tar file will be named 'base_dir' +  ".tar", possibly plus
     the appropriate compression extension (".gz", ".bz2" or ".Z").
-
     Returns the output filename.
     """
     tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: '', 'compress': ''}
@@ -84,23 +44,10 @@
     import tarfile  # late import so Python build itself doesn't break
 
     log.info('Creating tar archive')
-
-    uid = _get_uid(owner)
-    gid = _get_gid(group)
-
-    def _set_uid_gid(tarinfo):
-        if gid is not None:
-            tarinfo.gid = gid
-            tarinfo.gname = group
-        if uid is not None:
-            tarinfo.uid = uid
-            tarinfo.uname = owner
-        return tarinfo
-
     if not dry_run:
         tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
         try:
-            tar.add(base_dir, filter=_set_uid_gid)
+            tar.add(base_dir)
         finally:
             tar.close()
 
@@ -190,7 +137,7 @@
     return None
 
 def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
-                 dry_run=0, owner=None, group=None):
+                 dry_run=0):
     """Create an archive file (eg. zip or tar).
 
     'base_name' is the name of the file to create, minus any format-specific
@@ -203,9 +150,6 @@
     ie. 'base_dir' will be the common prefix of all files and
     directories in the archive.  'root_dir' and 'base_dir' both default
     to the current directory.  Returns the name of the archive file.
-
-    'owner' and 'group' are used when creating a tar archive. By default,
-    uses the current owner and group.
     """
     save_cwd = os.getcwd()
     if root_dir is not None:
@@ -227,11 +171,6 @@
     func = format_info[0]
     for arg, val in format_info[1]:
         kwargs[arg] = val
-
-    if format != 'zip':
-        kwargs['owner'] = owner
-        kwargs['group'] = group
-
     try:
         filename = func(base_name, base_dir, **kwargs)
     finally:

Modified: python/branches/py3k/Lib/distutils/bcppcompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/bcppcompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/bcppcompiler.py	Thu Jul 22 14:50:05 2010
@@ -13,11 +13,13 @@
 
 __revision__ = "$Id$"
 
-import os
 
-from distutils.errors import (DistutilsExecError, CompileError, LibError,
-                              LinkError, UnknownFileError)
-from distutils.ccompiler import CCompiler, gen_preprocess_options
+import os
+from distutils.errors import \
+     DistutilsExecError, DistutilsPlatformError, \
+     CompileError, LibError, LinkError, UnknownFileError
+from distutils.ccompiler import \
+     CCompiler, gen_preprocess_options, gen_lib_options
 from distutils.file_util import write_file
 from distutils.dep_util import newer
 from distutils import log

Modified: python/branches/py3k/Lib/distutils/ccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/ccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/ccompiler.py	Thu Jul 22 14:50:05 2010
@@ -5,71 +5,15 @@
 
 __revision__ = "$Id$"
 
-import sys
-import os
-import re
-
-from distutils.errors import (CompileError, LinkError, UnknownFileError,
-                              DistutilsPlatformError, DistutilsModuleError)
+import sys, os, re
+from distutils.errors import *
 from distutils.spawn import spawn
 from distutils.file_util import move_file
 from distutils.dir_util import mkpath
-from distutils.dep_util import newer_group
+from distutils.dep_util import newer_pairwise, newer_group
 from distutils.util import split_quoted, execute
 from distutils import log
 
-_sysconfig = __import__('sysconfig')
-
-def customize_compiler(compiler):
-    """Do any platform-specific customization of a CCompiler instance.
-
-    Mainly needed on Unix, so we can plug in the information that
-    varies across Unices and is stored in Python's Makefile.
-    """
-    if compiler.compiler_type == "unix":
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
-            _sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-                                       'CCSHARED', 'LDSHARED', 'SO', 'AR',
-                                       'ARFLAGS')
-
-        if 'CC' in os.environ:
-            cc = os.environ['CC']
-        if 'CXX' in os.environ:
-            cxx = os.environ['CXX']
-        if 'LDSHARED' in os.environ:
-            ldshared = os.environ['LDSHARED']
-        if 'CPP' in os.environ:
-            cpp = os.environ['CPP']
-        else:
-            cpp = cc + " -E"           # not always
-        if 'LDFLAGS' in os.environ:
-            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
-        if 'CFLAGS' in os.environ:
-            cflags = opt + ' ' + os.environ['CFLAGS']
-            ldshared = ldshared + ' ' + os.environ['CFLAGS']
-        if 'CPPFLAGS' in os.environ:
-            cpp = cpp + ' ' + os.environ['CPPFLAGS']
-            cflags = cflags + ' ' + os.environ['CPPFLAGS']
-            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
-        if 'AR' in os.environ:
-            ar = os.environ['AR']
-        if 'ARFLAGS' in os.environ:
-            archiver = ar + ' ' + os.environ['ARFLAGS']
-        else:
-            archiver = ar + ' ' + ar_flags
-
-        cc_cmd = cc + ' ' + cflags
-        compiler.set_executables(
-            preprocessor=cpp,
-            compiler=cc_cmd,
-            compiler_so=cc_cmd + ' ' + ccshared,
-            compiler_cxx=cxx,
-            linker_so=ldshared,
-            linker_exe=cc,
-            archiver=archiver)
-
-        compiler.shared_lib_extension = so_ext
-
 class CCompiler:
     """Abstract base class to define the interface that must be implemented
     by real compiler classes.  Also has some utility methods used by
@@ -449,6 +393,22 @@
 
         return output_dir, macros, include_dirs
 
+    def _prep_compile(self, sources, output_dir, depends=None):
+        """Decide which souce files must be recompiled.
+
+        Determine the list of object files corresponding to 'sources',
+        and figure out which ones really need to be recompiled.
+        Return a list of all object files and a dictionary telling
+        which source files can be skipped.
+        """
+        # Get the list of expected output (object) files
+        objects = self.object_filenames(sources, output_dir=output_dir)
+        assert len(objects) == len(sources)
+
+        # Return an empty dict for the "which source files can be skipped"
+        # return value to preserve API compatibility.
+        return objects, {}
+
     def _fix_object_args(self, objects, output_dir):
         """Typecheck and fix up some arguments supplied to various methods.
         Specifically: ensure that 'objects' is a list; if output_dir is
@@ -650,15 +610,26 @@
         """
         pass
 
+
     # values for target_desc parameter in link()
     SHARED_OBJECT = "shared_object"
     SHARED_LIBRARY = "shared_library"
     EXECUTABLE = "executable"
 
-    def link(self, target_desc, objects, output_filename, output_dir=None,
-             libraries=None, library_dirs=None, runtime_library_dirs=None,
-             export_symbols=None, debug=0, extra_preargs=None,
-             extra_postargs=None, build_temp=None, target_lang=None):
+    def link(self,
+             target_desc,
+             objects,
+             output_filename,
+             output_dir=None,
+             libraries=None,
+             library_dirs=None,
+             runtime_library_dirs=None,
+             export_symbols=None,
+             debug=0,
+             extra_preargs=None,
+             extra_postargs=None,
+             build_temp=None,
+             target_lang=None):
         """Link a bunch of stuff together to create an executable or
         shared library file.
 
@@ -707,11 +678,19 @@
 
     # Old 'link_*()' methods, rewritten to use the new 'link()' method.
 
-    def link_shared_lib(self, objects, output_libname, output_dir=None,
-                        libraries=None, library_dirs=None,
-                        runtime_library_dirs=None, export_symbols=None,
-                        debug=0, extra_preargs=None, extra_postargs=None,
-                        build_temp=None, target_lang=None):
+    def link_shared_lib(self,
+                        objects,
+                        output_libname,
+                        output_dir=None,
+                        libraries=None,
+                        library_dirs=None,
+                        runtime_library_dirs=None,
+                        export_symbols=None,
+                        debug=0,
+                        extra_preargs=None,
+                        extra_postargs=None,
+                        build_temp=None,
+                        target_lang=None):
         self.link(CCompiler.SHARED_LIBRARY, objects,
                   self.library_filename(output_libname, lib_type='shared'),
                   output_dir,
@@ -720,11 +699,19 @@
                   extra_preargs, extra_postargs, build_temp, target_lang)
 
 
-    def link_shared_object(self, objects, output_filename, output_dir=None,
-                           libraries=None, library_dirs=None,
-                           runtime_library_dirs=None, export_symbols=None,
-                           debug=0, extra_preargs=None, extra_postargs=None,
-                           build_temp=None, target_lang=None):
+    def link_shared_object(self,
+                           objects,
+                           output_filename,
+                           output_dir=None,
+                           libraries=None,
+                           library_dirs=None,
+                           runtime_library_dirs=None,
+                           export_symbols=None,
+                           debug=0,
+                           extra_preargs=None,
+                           extra_postargs=None,
+                           build_temp=None,
+                           target_lang=None):
         self.link(CCompiler.SHARED_OBJECT, objects,
                   output_filename, output_dir,
                   libraries, library_dirs, runtime_library_dirs,
@@ -732,10 +719,17 @@
                   extra_preargs, extra_postargs, build_temp, target_lang)
 
 
-    def link_executable(self, objects, output_progname, output_dir=None,
-                        libraries=None, library_dirs=None,
-                        runtime_library_dirs=None, debug=0, extra_preargs=None,
-                        extra_postargs=None, target_lang=None):
+    def link_executable(self,
+                        objects,
+                        output_progname,
+                        output_dir=None,
+                        libraries=None,
+                        library_dirs=None,
+                        runtime_library_dirs=None,
+                        debug=0,
+                        extra_preargs=None,
+                        extra_postargs=None,
+                        target_lang=None):
         self.link(CCompiler.EXECUTABLE, objects,
                   self.executable_filename(output_progname), output_dir,
                   libraries, library_dirs, runtime_library_dirs, None,
@@ -917,7 +911,7 @@
     def move_file(self, src, dst):
         return move_file(src, dst, dry_run=self.dry_run)
 
-    def mkpath(self, name, mode=0o777):
+    def mkpath (self, name, mode=0o777):
         mkpath(name, mode, dry_run=self.dry_run)
 
 
@@ -1085,14 +1079,12 @@
     return pp_opts
 
 
-def gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries):
+def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
     """Generate linker options for searching library directories and
-    linking with specific libraries.
-
-    'libraries' and 'library_dirs' are, respectively, lists of library names
-    (not filenames!) and search directories.  Returns a list of command-line
-    options suitable for use with some compiler (depending on the two format
-    strings passed in).
+    linking with specific libraries.  'libraries' and 'library_dirs' are,
+    respectively, lists of library names (not filenames!) and search
+    directories.  Returns a list of command-line options suitable for use
+    with some compiler (depending on the two format strings passed in).
     """
     lib_opts = []
 
@@ -1102,7 +1094,7 @@
     for dir in runtime_library_dirs:
         opt = compiler.runtime_library_dir_option(dir)
         if isinstance(opt, list):
-            lib_opts.extend(opt)
+            lib_opts = lib_opts + opt
         else:
             lib_opts.append(opt)
 
@@ -1113,14 +1105,14 @@
     # pretty nasty way to arrange your C code.
 
     for lib in libraries:
-        lib_dir, lib_name = os.path.split(lib)
-        if lib_dir != '':
+        (lib_dir, lib_name) = os.path.split(lib)
+        if lib_dir:
             lib_file = compiler.find_library_file([lib_dir], lib_name)
-            if lib_file is not None:
+            if lib_file:
                 lib_opts.append(lib_file)
             else:
                 compiler.warn("no library file corresponding to "
                               "'%s' found (skipping)" % lib)
         else:
-            lib_opts.append(compiler.library_option(lib))
+            lib_opts.append(compiler.library_option (lib))
     return lib_opts

Modified: python/branches/py3k/Lib/distutils/cmd.py
==============================================================================
--- python/branches/py3k/Lib/distutils/cmd.py	(original)
+++ python/branches/py3k/Lib/distutils/cmd.py	Thu Jul 22 14:50:05 2010
@@ -367,11 +367,9 @@
         from distutils.spawn import spawn
         spawn(cmd, search_path, dry_run=self.dry_run)
 
-    def make_archive(self, base_name, format, root_dir=None, base_dir=None,
-                     owner=None, group=None):
-        return archive_util.make_archive(base_name, format, root_dir,
-                                         base_dir, dry_run=self.dry_run,
-                                         owner=owner, group=group)
+    def make_archive(self, base_name, format, root_dir=None, base_dir=None):
+        return archive_util.make_archive(base_name, format, root_dir, base_dir,
+                                         dry_run=self.dry_run)
 
     def make_file(self, infiles, outfile, func, args,
                   exec_msg=None, skip_msg=None, level=1):

Modified: python/branches/py3k/Lib/distutils/command/bdist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/bdist.py	(original)
+++ python/branches/py3k/Lib/distutils/command/bdist.py	Thu Jul 22 14:50:05 2010
@@ -6,10 +6,9 @@
 __revision__ = "$Id$"
 
 import os
-
-from distutils.util import get_platform
 from distutils.core import Command
-from distutils.errors import DistutilsPlatformError, DistutilsOptionError
+from distutils.errors import *
+from distutils.util import get_platform
 
 
 def show_formats():
@@ -40,12 +39,6 @@
                      "[default: dist]"),
                     ('skip-build', None,
                      "skip rebuilding everything (for testing/debugging)"),
-                    ('owner=', 'u',
-                     "Owner name used when creating a tar file"
-                     " [default: current user]"),
-                    ('group=', 'g',
-                     "Group name used when creating a tar file"
-                     " [default: current group]"),
                    ]
 
     boolean_options = ['skip-build']
@@ -87,8 +80,6 @@
         self.formats = None
         self.dist_dir = None
         self.skip_build = 0
-        self.group = None
-        self.owner = None
 
     def finalize_options(self):
         # have to finalize 'plat_name' before 'bdist_base'
@@ -134,11 +125,6 @@
             if cmd_name not in self.no_format_option:
                 sub_cmd.format = self.formats[i]
 
-            # passing the owner and group names for tar archiving
-            if cmd_name == 'bdist_dumb':
-                sub_cmd.owner = self.owner
-                sub_cmd.group = self.group
-
             # If we're going to need to run this command again, tell it to
             # keep its temporary files around so subsequent runs go faster.
             if cmd_name in commands[i+1:]:

Modified: python/branches/py3k/Lib/distutils/command/bdist_dumb.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/bdist_dumb.py	(original)
+++ python/branches/py3k/Lib/distutils/command/bdist_dumb.py	Thu Jul 22 14:50:05 2010
@@ -7,18 +7,16 @@
 __revision__ = "$Id$"
 
 import os
-
-from sysconfig import get_python_version
-
-from distutils.util import get_platform
 from distutils.core import Command
+from distutils.util import get_platform
 from distutils.dir_util import remove_tree, ensure_relative
-from distutils.errors import DistutilsPlatformError
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
 from distutils import log
 
 class bdist_dumb(Command):
 
-    description = 'create a "dumb" built distribution'
+    description = "create a \"dumb\" built distribution"
 
     user_options = [('bdist-dir=', 'd',
                      "temporary directory for creating the distribution"),
@@ -37,12 +35,6 @@
                     ('relative', None,
                      "build the archive using relative paths"
                      "(default: false)"),
-                    ('owner=', 'u',
-                     "Owner name used when creating a tar file"
-                     " [default: current user]"),
-                    ('group=', 'g',
-                     "Group name used when creating a tar file"
-                     " [default: current group]"),
                    ]
 
     boolean_options = ['keep-temp', 'skip-build', 'relative']
@@ -59,8 +51,6 @@
         self.dist_dir = None
         self.skip_build = 0
         self.relative = 0
-        self.owner = None
-        self.group = None
 
     def finalize_options(self):
         if self.bdist_dir is None:
@@ -118,8 +108,7 @@
 
         # Make the archive
         filename = self.make_archive(pseudoinstall_root,
-                                     self.format, root_dir=archive_root,
-                                     owner=self.owner, group=self.group)
+                                     self.format, root_dir=archive_root)
         if self.distribution.has_ext_modules():
             pyversion = get_python_version()
         else:

Modified: python/branches/py3k/Lib/distutils/command/bdist_msi.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/bdist_msi.py	(original)
+++ python/branches/py3k/Lib/distutils/command/bdist_msi.py	Thu Jul 22 14:50:05 2010
@@ -6,15 +6,15 @@
 """
 Implements the bdist_msi command.
 """
-import sys, os
-from sysconfig import get_python_version, get_platform
 
+import sys, os
 from distutils.core import Command
 from distutils.dir_util import remove_tree
+from distutils.sysconfig import get_python_version
 from distutils.version import StrictVersion
 from distutils.errors import DistutilsOptionError
+from distutils.util import get_platform
 from distutils import log
-
 import msilib
 from msilib import schema, sequence, text
 from msilib import Directory, Feature, Dialog, add_data
@@ -28,6 +28,7 @@
         default, cancel, bitmap=true)"""
         Dialog.__init__(self, *args)
         ruler = self.h - 36
+        bmwidth = 152*ruler/328
         #if kw.get("bitmap", True):
         #    self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
         self.line("BottomLine", 0, ruler, self.w, 0)
@@ -418,6 +419,7 @@
         # see "Dialog Style Bits"
         modal = 3      # visible | modal
         modeless = 1   # visible
+        track_disk_space = 32
 
         # UI customization properties
         add_data(db, "Property",

Modified: python/branches/py3k/Lib/distutils/command/bdist_rpm.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/bdist_rpm.py	(original)
+++ python/branches/py3k/Lib/distutils/command/bdist_rpm.py	Thu Jul 22 14:50:05 2010
@@ -5,14 +5,13 @@
 
 __revision__ = "$Id$"
 
-import sys
-import os
-
+import sys, os
 from distutils.core import Command
 from distutils.debug import DEBUG
+from distutils.util import get_platform
 from distutils.file_util import write_file
-from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
-                              DistutilsFileError, DistutilsExecError)
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
 from distutils import log
 
 class bdist_rpm(Command):

Modified: python/branches/py3k/Lib/distutils/command/bdist_wininst.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/bdist_wininst.py	(original)
+++ python/branches/py3k/Lib/distutils/command/bdist_wininst.py	Thu Jul 22 14:50:05 2010
@@ -5,16 +5,13 @@
 
 __revision__ = "$Id$"
 
-import sys
-import os
-
-from sysconfig import get_python_version
-
+import sys, os
 from distutils.core import Command
-from distutils.dir_util import remove_tree
-from distutils.errors import DistutilsOptionError, DistutilsPlatformError
-from distutils import log
 from distutils.util import get_platform
+from distutils.dir_util import create_tree, remove_tree
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
+from distutils import log
 
 class bdist_wininst(Command):
 

Modified: python/branches/py3k/Lib/distutils/command/build.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/build.py	(original)
+++ python/branches/py3k/Lib/distutils/command/build.py	Thu Jul 22 14:50:05 2010
@@ -5,15 +5,16 @@
 __revision__ = "$Id$"
 
 import sys, os
-
-from distutils.util import get_platform
 from distutils.core import Command
 from distutils.errors import DistutilsOptionError
+from distutils.util import get_platform
+
 
 def show_compilers():
     from distutils.ccompiler import show_compilers
     show_compilers()
 
+
 class build(Command):
 
     description = "build everything needed to install"
@@ -126,6 +127,7 @@
         for cmd_name in self.get_sub_commands():
             self.run_command(cmd_name)
 
+
     # -- Predicates for the sub-command list ---------------------------
 
     def has_pure_modules(self):
@@ -140,6 +142,7 @@
     def has_scripts(self):
         return self.distribution.has_scripts()
 
+
     sub_commands = [('build_py',      has_pure_modules),
                     ('build_clib',    has_c_libraries),
                     ('build_ext',     has_ext_modules),

Modified: python/branches/py3k/Lib/distutils/command/build_clib.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/build_clib.py	(original)
+++ python/branches/py3k/Lib/distutils/command/build_clib.py	Thu Jul 22 14:50:05 2010
@@ -18,8 +18,8 @@
 
 import os
 from distutils.core import Command
-from distutils.errors import DistutilsSetupError
-from distutils.ccompiler import customize_compiler
+from distutils.errors import *
+from distutils.sysconfig import customize_compiler
 from distutils import log
 
 def show_compilers():

Modified: python/branches/py3k/Lib/distutils/command/build_ext.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/build_ext.py	(original)
+++ python/branches/py3k/Lib/distutils/command/build_ext.py	Thu Jul 22 14:50:05 2010
@@ -7,14 +7,12 @@
 __revision__ = "$Id$"
 
 import sys, os, re
-from warnings import warn
-
-from distutils.util import get_platform
 from distutils.core import Command
 from distutils.errors import *
-from distutils.ccompiler import customize_compiler
+from distutils.sysconfig import customize_compiler, get_python_version
 from distutils.dep_util import newer_group
 from distutils.extension import Extension
+from distutils.util import get_platform
 from distutils import log
 
 # this keeps compatibility from 2.3 to 2.5
@@ -114,39 +112,6 @@
          "list available compilers", show_compilers),
         ]
 
-    # making 'compiler' a property to deprecate
-    # its usage as something else than a compiler type
-    # e.g. like a compiler instance
-    def __init__(self, dist):
-        self._compiler = None
-        Command.__init__(self, dist)
-
-    def __setattr__(self, name, value):
-        # need this to make sure setattr() (used in distutils)
-        # doesn't kill our property
-        if name == 'compiler':
-            self._set_compiler(value)
-        else:
-            self.__dict__[name] = value
-
-    def _set_compiler(self, compiler):
-        if not isinstance(compiler, str) and compiler is not None:
-            # we don't want to allow that anymore in the future
-            warn("'compiler' specifies the compiler type in build_ext. "
-                 "If you want to get the compiler object itself, "
-                 "use 'compiler_obj'", DeprecationWarning)
-        self._compiler = compiler
-
-    def _get_compiler(self):
-        if not isinstance(self._compiler, str) and self._compiler is not None:
-            # we don't want to allow that anymore in the future
-            warn("'compiler' specifies the compiler type in build_ext. "
-                 "If you want to get the compiler object itself, "
-                 "use 'compiler_obj'", DeprecationWarning)
-        return self._compiler
-
-    compiler = property(_get_compiler, _set_compiler)
-
     def initialize_options(self):
         self.extensions = None
         self.build_lib = None
@@ -171,7 +136,8 @@
         self.user = None
 
     def finalize_options(self):
-        _sysconfig = __import__('sysconfig')
+        from distutils import sysconfig
+
         self.set_undefined_options('build',
                                    ('build_lib', 'build_lib'),
                                    ('build_temp', 'build_temp'),
@@ -188,8 +154,8 @@
 
         # Make sure Python's include directories (for Python.h, pyconfig.h,
         # etc.) are in the include search path.
-        py_include = _sysconfig.get_path('include')
-        plat_py_include = _sysconfig.get_path('platinclude')
+        py_include = sysconfig.get_python_inc()
+        plat_py_include = sysconfig.get_python_inc(plat_specific=1)
         if self.include_dirs is None:
             self.include_dirs = self.distribution.include_dirs or []
         if isinstance(self.include_dirs, str):
@@ -261,13 +227,13 @@
         if os.name == 'os2':
             self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config'))
 
-        # for extensions under Cygwin Python's library directory must be
+        # for extensions under Cygwin and AtheOS Python's library directory must be
         # appended to library_dirs
-        if sys.platform[:6] == 'cygwin':
+        if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos':
             if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
                 # building third party extensions
                 self.library_dirs.append(os.path.join(sys.prefix, "lib",
-                                  "python" + _sysconfig.get_python_version(),
+                                                      "python" + get_python_version(),
                                                       "config"))
             else:
                 # building python standard extensions
@@ -275,13 +241,13 @@
 
         # for extensions under Linux or Solaris with a shared Python library,
         # Python's library directory must be appended to library_dirs
-        _sysconfig.get_config_var('Py_ENABLE_SHARED')
+        sysconfig.get_config_var('Py_ENABLE_SHARED')
         if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')
              or sys.platform.startswith('sunos'))
-            and _sysconfig.get_config_var('Py_ENABLE_SHARED')):
+            and sysconfig.get_config_var('Py_ENABLE_SHARED')):
             if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
                 # building third party extensions
-                self.library_dirs.append(_sysconfig.get_config_var('LIBDIR'))
+                self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
             else:
                 # building python standard extensions
                 self.library_dirs.append('.')
@@ -344,50 +310,38 @@
 
         # Setup the CCompiler object that we'll use to do all the
         # compiling and linking
-
-        # used to prevent the usage of an existing compiler for the
-        # compiler option when calling new_compiler()
-        # this will be removed in 3.3 and 2.8
-        if not isinstance(self._compiler, str):
-            self._compiler = None
-
-        self.compiler_obj = new_compiler(compiler=self._compiler,
-                                         verbose=self.verbose,
-                                         dry_run=self.dry_run,
-                                         force=self.force)
-
-        # used to keep the compiler object reachable with
-        # "self.compiler". this will be removed in 3.3 and 2.8
-        self._compiler = self.compiler_obj
-
-        customize_compiler(self.compiler_obj)
+        self.compiler = new_compiler(compiler=self.compiler,
+                                     verbose=self.verbose,
+                                     dry_run=self.dry_run,
+                                     force=self.force)
+        customize_compiler(self.compiler)
         # If we are cross-compiling, init the compiler now (if we are not
         # cross-compiling, init would not hurt, but people may rely on
         # late initialization of compiler even if they shouldn't...)
         if os.name == 'nt' and self.plat_name != get_platform():
-            self.compiler_obj.initialize(self.plat_name)
+            self.compiler.initialize(self.plat_name)
 
         # And make sure that any compile/link-related options (which might
         # come from the command-line or from the setup script) are set in
         # that CCompiler object -- that way, they automatically apply to
         # all compiling and linking done here.
         if self.include_dirs is not None:
-            self.compiler_obj.set_include_dirs(self.include_dirs)
+            self.compiler.set_include_dirs(self.include_dirs)
         if self.define is not None:
             # 'define' option is a list of (name,value) tuples
             for (name, value) in self.define:
-                self.compiler_obj.define_macro(name, value)
+                self.compiler.define_macro(name, value)
         if self.undef is not None:
             for macro in self.undef:
-                self.compiler_obj.undefine_macro(macro)
+                self.compiler.undefine_macro(macro)
         if self.libraries is not None:
-            self.compiler_obj.set_libraries(self.libraries)
+            self.compiler.set_libraries(self.libraries)
         if self.library_dirs is not None:
-            self.compiler_obj.set_library_dirs(self.library_dirs)
+            self.compiler.set_library_dirs(self.library_dirs)
         if self.rpath is not None:
-            self.compiler_obj.set_runtime_library_dirs(self.rpath)
+            self.compiler.set_runtime_library_dirs(self.rpath)
         if self.link_objects is not None:
-            self.compiler_obj.set_link_objects(self.link_objects)
+            self.compiler.set_link_objects(self.link_objects)
 
         # Now actually compile and link everything.
         self.build_extensions()
@@ -548,13 +502,13 @@
         for undef in ext.undef_macros:
             macros.append((undef,))
 
-        objects = self.compiler_obj.compile(sources,
-                                            output_dir=self.build_temp,
-                                            macros=macros,
-                                            include_dirs=ext.include_dirs,
-                                            debug=self.debug,
-                                            extra_postargs=extra_args,
-                                            depends=ext.depends)
+        objects = self.compiler.compile(sources,
+                                         output_dir=self.build_temp,
+                                         macros=macros,
+                                         include_dirs=ext.include_dirs,
+                                         debug=self.debug,
+                                         extra_postargs=extra_args,
+                                         depends=ext.depends)
 
         # XXX -- this is a Vile HACK!
         #
@@ -575,9 +529,9 @@
         extra_args = ext.extra_link_args or []
 
         # Detect target language, if not provided
-        language = ext.language or self.compiler_obj.detect_language(sources)
+        language = ext.language or self.compiler.detect_language(sources)
 
-        self.compiler_obj.link_shared_object(
+        self.compiler.link_shared_object(
             objects, ext_path,
             libraries=self.get_libraries(ext),
             library_dirs=ext.library_dirs,
@@ -710,13 +664,13 @@
         of the file from which it will be loaded (eg. "foo/bar.so", or
         "foo\bar.pyd").
         """
-        _sysconfig = __import__('sysconfig')
+        from distutils.sysconfig import get_config_var
         ext_path = ext_name.split('.')
         # OS/2 has an 8 character module (extension) limit :-(
         if os.name == "os2":
             ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
         # extensions in debug_mode are named 'module_d.pyd' under windows
-        so_ext = _sysconfig.get_config_var('SO')
+        so_ext = get_config_var('SO')
         if os.name == 'nt' and self.debug:
             return os.path.join(*ext_path) + '_d' + so_ext
         return os.path.join(*ext_path) + so_ext
@@ -744,7 +698,7 @@
         # Append '_d' to the python import library on debug builds.
         if sys.platform == "win32":
             from distutils.msvccompiler import MSVCCompiler
-            if not isinstance(self.compiler_obj, MSVCCompiler):
+            if not isinstance(self.compiler, MSVCCompiler):
                 template = "python%d%d"
                 if self.debug:
                     template = template + '_d'
@@ -775,12 +729,28 @@
             # don't extend ext.libraries, it may be shared with other
             # extensions, it is a reference to the original list
             return ext.libraries + [pythonlib]
+        elif sys.platform[:6] == "atheos":
+            from distutils import sysconfig
+
+            template = "python%d.%d"
+            pythonlib = (template %
+                   (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+            # Get SHLIBS from Makefile
+            extra = []
+            for lib in sysconfig.get_config_var('SHLIBS').split():
+                if lib.startswith('-l'):
+                    extra.append(lib[2:])
+                else:
+                    extra.append(lib)
+            # 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:
-            _sysconfig = __import__('sysconfig')
-            if _sysconfig.get_config_var('Py_ENABLE_SHARED'):
+            from distutils import sysconfig
+            if sysconfig.get_config_var('Py_ENABLE_SHARED'):
                 template = "python%d.%d"
                 pythonlib = (template %
                              (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))

Modified: python/branches/py3k/Lib/distutils/command/build_py.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/build_py.py	(original)
+++ python/branches/py3k/Lib/distutils/command/build_py.py	Thu Jul 22 14:50:05 2010
@@ -4,16 +4,16 @@
 
 __revision__ = "$Id$"
 
-import os
+import sys, os
 import sys
 from glob import glob
 
 from distutils.core import Command
-from distutils.errors import DistutilsOptionError, DistutilsFileError
+from distutils.errors import *
 from distutils.util import convert_path, Mixin2to3
 from distutils import log
 
-class build_py(Command):
+class build_py (Command):
 
     description = "\"build\" pure Python modules (copy to build directory)"
 
@@ -133,6 +133,7 @@
 
     def build_package_data(self):
         """Copy data files into build directory"""
+        lastdir = None
         for package, src_dir, build_dir, filenames in self.data_files:
             for filename in filenames:
                 target = os.path.join(build_dir, filename)

Modified: python/branches/py3k/Lib/distutils/command/build_scripts.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/build_scripts.py	(original)
+++ python/branches/py3k/Lib/distutils/command/build_scripts.py	Thu Jul 22 14:50:05 2010
@@ -6,6 +6,7 @@
 
 import os, re
 from stat import ST_MODE
+from distutils import sysconfig
 from distutils.core import Command
 from distutils.dep_util import newer
 from distutils.util import convert_path, Mixin2to3
@@ -56,7 +57,6 @@
         ie. starts with "\#!" and contains "python"), then adjust the first
         line to refer to the current Python interpreter as we copy.
         """
-        _sysconfig = __import__('sysconfig')
         self.mkpath(self.build_dir)
         outfiles = []
         updated_files = []
@@ -96,16 +96,16 @@
                 updated_files.append(outfile)
                 if not self.dry_run:
                     outf = open(outfile, "w")
-                    if not _sysconfig.is_python_build():
+                    if not sysconfig.python_build:
                         outf.write("#!%s%s\n" %
                                    (self.executable,
                                     post_interp))
                     else:
                         outf.write("#!%s%s\n" %
                                    (os.path.join(
-                            _sysconfig.get_config_var("BINDIR"),
-                           "python%s%s" % (_sysconfig.get_config_var("VERSION"),
-                                           _sysconfig.get_config_var("EXE"))),
+                            sysconfig.get_config_var("BINDIR"),
+                           "python%s%s" % (sysconfig.get_config_var("VERSION"),
+                                           sysconfig.get_config_var("EXE"))),
                                     post_interp))
                     outf.writelines(f.readlines())
                     outf.close()

Modified: python/branches/py3k/Lib/distutils/command/config.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/config.py	(original)
+++ python/branches/py3k/Lib/distutils/command/config.py	Thu Jul 22 14:50:05 2010
@@ -11,12 +11,11 @@
 
 __revision__ = "$Id$"
 
-import os
-import re
+import sys, os, re
 
 from distutils.core import Command
 from distutils.errors import DistutilsExecError
-from distutils.ccompiler import customize_compiler
+from distutils.sysconfig import customize_compiler
 from distutils import log
 
 LANG_EXT = {"c": ".c", "c++": ".cxx"}

Modified: python/branches/py3k/Lib/distutils/command/install.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/install.py	(original)
+++ python/branches/py3k/Lib/distutils/command/install.py	Thu Jul 22 14:50:05 2010
@@ -7,17 +7,26 @@
 import sys
 import os
 
-from sysconfig import get_config_vars, get_paths, get_path, get_config_var
-
 from distutils import log
 from distutils.core import Command
 from distutils.debug import DEBUG
+from distutils.sysconfig import get_config_vars
 from distutils.errors import DistutilsPlatformError
 from distutils.file_util import write_file
-from distutils.util import convert_path, change_root, get_platform
+from distutils.util import convert_path, subst_vars, change_root
+from distutils.util import get_platform
 from distutils.errors import DistutilsOptionError
 
-# kept for backward compat, will be removed in 3.2
+# this keeps compatibility from 2.3 to 2.5
+if sys.version < "2.6":
+    USER_BASE = None
+    USER_SITE = None
+    HAS_USER_SITE = False
+else:
+    from site import USER_BASE
+    from site import USER_SITE
+    HAS_USER_SITE = True
+
 if sys.version < "2.2":
     WINDOWS_SCHEME = {
         'purelib': '$base',
@@ -50,21 +59,15 @@
         'scripts': '$base/bin',
         'data'   : '$base',
         },
-    'unix_user': {
-        'purelib': '$usersite',
-        'platlib': '$usersite',
-        'headers': '$userbase/include/python$py_version_short/$dist_name',
-        'scripts': '$userbase/bin',
-        'data'   : '$userbase',
-        },
     'nt': WINDOWS_SCHEME,
-    'nt_user': {
-        'purelib': '$usersite',
-        'platlib': '$usersite',
-        'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
-        'scripts': '$userbase/Scripts',
-        'data'   : '$userbase',
+    'mac': {
+        'purelib': '$base/Lib/site-packages',
+        'platlib': '$base/Lib/site-packages',
+        'headers': '$base/Include/$dist_name',
+        'scripts': '$base/Scripts',
+        'data'   : '$base',
         },
+
     'os2': {
         'purelib': '$base/Lib/site-packages',
         'platlib': '$base/Lib/site-packages',
@@ -72,26 +75,47 @@
         'scripts': '$base/Scripts',
         'data'   : '$base',
         },
-    'os2_home': {
+    }
+
+# user site schemes
+if HAS_USER_SITE:
+    INSTALL_SCHEMES['nt_user'] = {
+        'purelib': '$usersite',
+        'platlib': '$usersite',
+        'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
+        'scripts': '$userbase/Scripts',
+        'data'   : '$userbase',
+        }
+
+    INSTALL_SCHEMES['unix_user'] = {
         'purelib': '$usersite',
         'platlib': '$usersite',
         'headers': '$userbase/include/python$py_version_short/$dist_name',
         'scripts': '$userbase/bin',
         'data'   : '$userbase',
-        },
-    }
+        }
+
+    INSTALL_SCHEMES['mac_user'] = {
+        'purelib': '$usersite',
+        'platlib': '$usersite',
+        'headers': '$userbase/$py_version_short/include/$dist_name',
+        'scripts': '$userbase/bin',
+        'data'   : '$userbase',
+        }
 
+    INSTALL_SCHEMES['os2_home'] = {
+        'purelib': '$usersite',
+        'platlib': '$usersite',
+        'headers': '$userbase/include/python$py_version_short/$dist_name',
+        'scripts': '$userbase/bin',
+        'data'   : '$userbase',
+        }
+
+# The keys to an installation scheme; if any new types of files are to be
+# installed, be sure to add an entry to every installation scheme above,
+# and to SCHEME_KEYS here.
 SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')
-# end of backward compat
 
-def _subst_vars(s, local_vars):
-    try:
-        return s.format(**local_vars)
-    except KeyError:
-        try:
-            return s.format(**os.environ)
-        except KeyError as var:
-            raise AttributeError('{%s}' % var)
 
 class install(Command):
 
@@ -158,10 +182,11 @@
 
     boolean_options = ['compile', 'force', 'skip-build']
 
-    user_options.append(('user', None,
-                        "install in user site-package '%s'" % \
-                            get_path('purelib', '%s_user' % os.name)))
-    boolean_options.append('user')
+    if HAS_USER_SITE:
+        user_options.append(('user', None,
+                             "install in user site-package '%s'" % USER_SITE))
+        boolean_options.append('user')
+
     negative_opt = {'no-compile' : 'compile'}
 
 
@@ -191,8 +216,8 @@
         self.install_lib = None         # set to either purelib or platlib
         self.install_scripts = None
         self.install_data = None
-        self.install_userbase = get_config_var('userbase')
-        self.install_usersite = get_path('purelib', '%s_user' % os.name)
+        self.install_userbase = USER_BASE
+        self.install_usersite = USER_SITE
 
         self.compile = None
         self.optimize = None
@@ -302,9 +327,7 @@
         # about needing recursive variable expansion (shudder).
 
         py_version = sys.version.split()[0]
-        prefix, exec_prefix, srcdir, projectbase = get_config_vars('prefix', 'exec_prefix',
-                                                      'srcdir', 'projectbase')
-
+        (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
         self.config_vars = {'dist_name': self.distribution.get_name(),
                             'dist_version': self.distribution.get_version(),
                             'dist_fullname': self.distribution.get_fullname(),
@@ -315,12 +338,12 @@
                             'prefix': prefix,
                             'sys_exec_prefix': exec_prefix,
                             'exec_prefix': exec_prefix,
-                            'srcdir': srcdir,
-                            'projectbase': projectbase,
                            }
 
-        self.config_vars['userbase'] = self.install_userbase
-        self.config_vars['usersite'] = self.install_usersite
+        if HAS_USER_SITE:
+            self.config_vars['userbase'] = self.install_userbase
+            self.config_vars['usersite'] = self.install_usersite
+
         self.expand_basedirs()
 
         self.dump_dirs("post-expand_basedirs()")
@@ -424,10 +447,10 @@
                 raise DistutilsPlatformError(
                     "User base directory is not specified")
             self.install_base = self.install_platbase = self.install_userbase
-            self.select_scheme("posix_user")
+            self.select_scheme("unix_user")
         elif self.home is not None:
             self.install_base = self.install_platbase = self.home
-            self.select_scheme("posix_home")
+            self.select_scheme("unix_home")
         else:
             if self.prefix is None:
                 if self.exec_prefix is not None:
@@ -443,7 +466,7 @@
 
             self.install_base = self.prefix
             self.install_platbase = self.exec_prefix
-            self.select_scheme("posix_prefix")
+            self.select_scheme("unix_prefix")
 
     def finalize_other(self):
         """Finalizes options for non-posix platforms"""
@@ -455,7 +478,7 @@
             self.select_scheme(os.name + "_user")
         elif self.home is not None:
             self.install_base = self.install_platbase = self.home
-            self.select_scheme("posix_home")
+            self.select_scheme("unix_home")
         else:
             if self.prefix is None:
                 self.prefix = os.path.normpath(sys.prefix)
@@ -470,15 +493,11 @@
     def select_scheme(self, name):
         """Sets the install directories by applying the install schemes."""
         # it's the caller's problem if they supply a bad name!
-        scheme = get_paths(name, expand=False)
-        for key, value in scheme.items():
-            if key == 'platinclude':
-                key = 'headers'
-                value = os.path.join(value, self.distribution.get_name())
+        scheme = INSTALL_SCHEMES[name]
+        for key in SCHEME_KEYS:
             attrname = 'install_' + key
-            if hasattr(self, attrname):
-                if getattr(self, attrname) is None:
-                    setattr(self, attrname, value)
+            if getattr(self, attrname) is None:
+                setattr(self, attrname, scheme[key])
 
     def _expand_attrs(self, attrs):
         for attr in attrs:
@@ -486,7 +505,7 @@
             if val is not None:
                 if os.name == 'posix' or os.name == 'nt':
                     val = os.path.expanduser(val)
-                val = _subst_vars(val, self.config_vars)
+                val = subst_vars(val, self.config_vars)
                 setattr(self, attr, val)
 
     def expand_basedirs(self):

Modified: python/branches/py3k/Lib/distutils/command/register.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/register.py	(original)
+++ python/branches/py3k/Lib/distutils/command/register.py	Thu Jul 22 14:50:05 2010
@@ -7,15 +7,13 @@
 
 __revision__ = "$Id$"
 
-import os
-import string
-import getpass
+import os, string, getpass
 import io
-import urllib.parse
-import urllib.request
+import urllib.parse, urllib.request
 from warnings import warn
 
 from distutils.core import PyPIRCCommand
+from distutils.errors import *
 from distutils import log
 
 class register(PyPIRCCommand):

Modified: python/branches/py3k/Lib/distutils/command/sdist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/sdist.py	(original)
+++ python/branches/py3k/Lib/distutils/command/sdist.py	Thu Jul 22 14:50:05 2010
@@ -7,14 +7,14 @@
 import os
 import string
 import sys
+from types import *
 from glob import glob
 from warnings import warn
 
 from distutils.core import Command
 from distutils import dir_util, dep_util, file_util, archive_util
 from distutils.text_file import TextFile
-from distutils.errors import (DistutilsPlatformError, DistutilsOptionError,
-                              DistutilsTemplateError)
+from distutils.errors import *
 from distutils.filelist import FileList
 from distutils import log
 from distutils.util import convert_path
@@ -76,10 +76,6 @@
         ('medata-check', None,
          "Ensure that all required elements of meta-data "
          "are supplied. Warn if any missing. [default]"),
-        ('owner=', 'u',
-         "Owner name used when creating a tar file [default: current user]"),
-        ('group=', 'g',
-         "Group name used when creating a tar file [default: current group]"),
         ]
 
     boolean_options = ['use-defaults', 'prune',
@@ -119,8 +115,6 @@
 
         self.archive_files = None
         self.metadata_check = 1
-        self.owner = None
-        self.group = None
 
     def finalize_options(self):
         if self.manifest is None:
@@ -424,8 +418,7 @@
             self.formats.append(self.formats.pop(self.formats.index('tar')))
 
         for fmt in self.formats:
-            file = self.make_archive(base_name, fmt, base_dir=base_dir,
-                                     owner=self.owner, group=self.group)
+            file = self.make_archive(base_name, fmt, base_dir=base_dir)
             archive_files.append(file)
             self.distribution.dist_files.append(('sdist', '', file))
 

Modified: python/branches/py3k/Lib/distutils/command/upload.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/upload.py	(original)
+++ python/branches/py3k/Lib/distutils/command/upload.py	Thu Jul 22 14:50:05 2010
@@ -1,19 +1,25 @@
 """distutils.command.upload
 
 Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
-import os
-import io
-import socket
-import platform
-from urllib.request import urlopen, Request, HTTPError
-from base64 import standard_b64encode
-from urllib.parse import urlparse
-from hashlib import md5
 
-from distutils.errors import DistutilsOptionError
+from distutils.errors import *
 from distutils.core import PyPIRCCommand
 from distutils.spawn import spawn
 from distutils import log
+import sys
+import os, io
+import socket
+import platform
+import configparser
+import http.client as httpclient
+from base64 import standard_b64encode
+import urllib.parse
+
+# this keeps compatibility for 2.3 and 2.4
+if sys.version < "2.5":
+    from md5 import md5
+else:
+    from hashlib import md5
 
 class upload(PyPIRCCommand):
 
@@ -60,15 +66,6 @@
             self.upload_file(command, pyversion, filename)
 
     def upload_file(self, command, pyversion, filename):
-        # Makes sure the repository URL is compliant
-        schema, netloc, url, params, query, fragments = \
-            urlparse(self.repository)
-        if params or query or fragments:
-            raise AssertionError("Incompatible url %s" % self.repository)
-
-        if schema not in ('http', 'https'):
-            raise AssertionError("unsupported schema " + schema)
-
         # Sign if requested
         if self.sign:
             gpg_args = ["gpg", "--detach-sign", "-a", filename]
@@ -140,10 +137,10 @@
         for key, value in data.items():
             title = '\nContent-Disposition: form-data; name="%s"' % key
             # handle multiple entries for the same name
-            if not isinstance(value, list):
+            if type(value) != type([]):
                 value = [value]
             for value in value:
-                if isinstance(value, tuple):
+                if type(value) is tuple:
                     title += '; filename="%s"' % value[0]
                     value = value[1]
                 else:
@@ -161,30 +158,40 @@
         self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
 
         # build the Request
-        headers = {'Content-type':
-                        'multipart/form-data; boundary=%s' % boundary,
-                   'Content-length': str(len(body)),
-                   'Authorization': auth}
-
-        request = Request(self.repository, data=body,
-                          headers=headers)
-        # send the data
+        # We can't use urllib since we need to send the Basic
+        # auth right with the first request
+        # TODO(jhylton): Can we fix urllib?
+        schema, netloc, url, params, query, fragments = \
+            urllib.parse.urlparse(self.repository)
+        assert not params and not query and not fragments
+        if schema == 'http':
+            http = httpclient.HTTPConnection(netloc)
+        elif schema == 'https':
+            http = httpclient.HTTPSConnection(netloc)
+        else:
+            raise AssertionError("unsupported schema "+schema)
+
+        data = ''
+        loglevel = log.INFO
         try:
-            result = urlopen(request)
-            status = result.getcode()
-            reason = result.msg
+            http.connect()
+            http.putrequest("POST", url)
+            http.putheader('Content-type',
+                           'multipart/form-data; boundary=%s'%boundary)
+            http.putheader('Content-length', str(len(body)))
+            http.putheader('Authorization', auth)
+            http.endheaders()
+            http.send(body)
         except socket.error as e:
             self.announce(str(e), log.ERROR)
             return
-        except HTTPError as e:
-            status = e.code
-            reason = e.msg
 
-        if status == 200:
-            self.announce('Server response (%s): %s' % (status, reason),
+        r = http.getresponse()
+        if r.status == 200:
+            self.announce('Server response (%s): %s' % (r.status, r.reason),
                           log.INFO)
         else:
-            self.announce('Upload failed (%s): %s' % (status, reason),
+            self.announce('Upload failed (%s): %s' % (r.status, r.reason),
                           log.ERROR)
         if self.show_response:
-            self.announce('-'*75, result.read(), '-'*75)
+            self.announce('-'*75, r.read(), '-'*75)

Modified: python/branches/py3k/Lib/distutils/config.py
==============================================================================
--- python/branches/py3k/Lib/distutils/config.py	(original)
+++ python/branches/py3k/Lib/distutils/config.py	Thu Jul 22 14:50:05 2010
@@ -4,6 +4,7 @@
 that uses .pypirc in the distutils.command package.
 """
 import os
+import sys
 from configparser import ConfigParser
 
 from distutils.cmd import Command
@@ -59,6 +60,8 @@
         if os.path.exists(rc):
             self.announce('Using PyPI login from %s' % rc)
             repository = self.repository or self.DEFAULT_REPOSITORY
+            realm = self.realm or self.DEFAULT_REALM
+
             config = ConfigParser()
             config.read(rc)
             sections = config.sections()

Modified: python/branches/py3k/Lib/distutils/core.py
==============================================================================
--- python/branches/py3k/Lib/distutils/core.py	(original)
+++ python/branches/py3k/Lib/distutils/core.py	Thu Jul 22 14:50:05 2010
@@ -8,12 +8,10 @@
 
 __revision__ = "$Id$"
 
-import sys
-import os
+import sys, os
 
 from distutils.debug import DEBUG
-from distutils.errors import (DistutilsSetupError, DistutilsArgError,
-                              DistutilsError, CCompilerError)
+from distutils.errors import *
 from distutils.util import grok_environment_error
 
 # Mainly import these so setup scripts can "from distutils.core import" them.
@@ -33,9 +31,9 @@
    or: %(script)s cmd --help
 """
 
-def gen_usage(script_name):
+def gen_usage (script_name):
     script = os.path.basename(script_name)
-    return USAGE % {'script': script}
+    return USAGE % vars()
 
 
 # Some mild magic to control the behaviour of 'setup()' from 'run_setup()'.
@@ -58,7 +56,7 @@
                       'extra_objects', 'extra_compile_args', 'extra_link_args',
                       'swig_opts', 'export_symbols', 'depends', 'language')
 
-def setup(**attrs):
+def setup (**attrs):
     """The gateway to the Distutils: do everything your setup script needs
     to do, in a highly flexible and user-driven way.  Briefly: create a
     Distribution instance; find and parse config files; parse the command
@@ -131,9 +129,8 @@
     if _setup_stop_after == "config":
         return dist
 
-    # Parse the command line and override config files; any
-    # command-line errors are the end user's fault, so turn them into
-    # SystemExit to suppress tracebacks.
+    # Parse the command line; any command-line errors are the end user's
+    # fault, so turn them into SystemExit to suppress tracebacks.
     try:
         ok = dist.parse_command_line()
     except DistutilsArgError as msg:
@@ -170,8 +167,10 @@
 
     return dist
 
+# setup ()
 
-def run_setup(script_name, script_args=None, stop_after="run"):
+
+def run_setup (script_name, script_args=None, stop_after="run"):
     """Run a setup script in a somewhat controlled environment, and
     return the Distribution instance that drives things.  This is useful
     if you need to find out the distribution meta-data (passed as
@@ -234,4 +233,7 @@
 
     # I wonder if the setup script's namespace -- g and l -- would be of
     # any interest to callers?
+    #print "_setup_distribution:", _setup_distribution
     return _setup_distribution
+
+# run_setup ()

Modified: python/branches/py3k/Lib/distutils/cygwinccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/cygwinccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/cygwinccompiler.py	Thu Jul 22 14:50:05 2010
@@ -50,13 +50,16 @@
 import os
 import sys
 import copy
+from subprocess import Popen, PIPE
 import re
-from warnings import warn
 
+from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
 from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
-from distutils.util import get_compiler_versions
+from distutils import log
+from distutils.version import LooseVersion
+from distutils.spawn import find_executable
 
 def get_msvcr():
     """Include the appropriate MSVC runtime library if Python was built
@@ -107,7 +110,7 @@
                 % details)
 
         self.gcc_version, self.ld_version, self.dllwrap_version = \
-            get_compiler_versions()
+            get_versions()
         self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
                          (self.gcc_version,
                           self.ld_version,
@@ -337,7 +340,7 @@
     # XXX since this function also checks sys.version, it's not strictly a
     # "pyconfig.h" check -- should probably be renamed...
 
-    _sysconfig = __import__('sysconfig')
+    from distutils import sysconfig
 
     # if sys.version contains GCC then python was compiled with GCC, and the
     # pyconfig.h file should be OK
@@ -345,7 +348,7 @@
         return CONFIG_H_OK, "sys.version mentions 'GCC'"
 
     # let's see if __GNUC__ is mentioned in python.h
-    fn = _sysconfig.get_config_h_filename()
+    fn = sysconfig.get_config_h_filename()
     try:
         with open(fn) as config_h:
             if "__GNUC__" in config_h.read():
@@ -356,27 +359,33 @@
         return (CONFIG_H_UNCERTAIN,
                 "couldn't read '%s': %s" % (fn, exc.strerror))
 
-class _Deprecated_SRE_Pattern(object):
-    def __init__(self, pattern):
-        self.pattern = pattern
-
-    def __getattr__(self, name):
-        if name in ('findall', 'finditer', 'match', 'scanner', 'search',
-                    'split', 'sub', 'subn'):
-            warn("'distutils.cygwinccompiler.RE_VERSION' is deprecated "
-                 "and will be removed in the next version", DeprecationWarning)
-        return getattr(self.pattern, name)
+RE_VERSION = re.compile(b'(\d+\.\d+(\.\d+)*)')
 
+def _find_exe_version(cmd):
+    """Find the version of an executable by running `cmd` in the shell.
 
-RE_VERSION = _Deprecated_SRE_Pattern(re.compile('(\d+\.\d+(\.\d+)*)'))
+    If the command is not found, or the output does not match
+    `RE_VERSION`, returns None.
+    """
+    executable = cmd.split()[0]
+    if find_executable(executable) is None:
+        return None
+    out = Popen(cmd, shell=True, stdout=PIPE).stdout
+    try:
+        out_string = out.read()
+    finally:
+        out.close()
+    result = RE_VERSION.search(out_string)
+    if result is None:
+        return None
+    # LooseVersion works with strings
+    # so we need to decode our bytes
+    return LooseVersion(result.group(1).decode())
 
 def get_versions():
     """ Try to find out the versions of gcc, ld and dllwrap.
 
     If not possible it returns None for it.
     """
-    warn("'distutils.cygwinccompiler.get_versions' is deprecated "
-         "use 'distutils.util.get_compiler_versions' instead",
-         DeprecationWarning)
-
-    return get_compiler_versions()
+    commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
+    return tuple([_find_exe_version(cmd) for cmd in commands])

Modified: python/branches/py3k/Lib/distutils/dep_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/dep_util.py	(original)
+++ python/branches/py3k/Lib/distutils/dep_util.py	Thu Jul 22 14:50:05 2010
@@ -9,27 +9,29 @@
 import os
 from distutils.errors import DistutilsFileError
 
-def newer(source, target):
-    """Tells if the target is newer than the source.
 
-    Return true if 'source' exists and is more recently modified than
-    'target', or if 'source' exists and 'target' doesn't.
-
-    Return false if both exist and 'target' is the same age or younger
-    than 'source'. Raise DistutilsFileError if 'source' does not exist.
-
-    Note that this test is not very accurate: files created in the same second
-    will have the same "age".
+def newer (source, target):
+    """Return true if 'source' exists and is more recently modified than
+    'target', or if 'source' exists and 'target' doesn't.  Return false if
+    both exist and 'target' is the same age or younger than 'source'.
+    Raise DistutilsFileError if 'source' does not exist.
     """
     if not os.path.exists(source):
         raise DistutilsFileError("file '%s' does not exist" %
                                  os.path.abspath(source))
     if not os.path.exists(target):
-        return True
+        return 1
+
+    from stat import ST_MTIME
+    mtime1 = os.stat(source)[ST_MTIME]
+    mtime2 = os.stat(target)[ST_MTIME]
+
+    return mtime1 > mtime2
+
+# newer ()
 
-    return os.stat(source).st_mtime > os.stat(target).st_mtime
 
-def newer_pairwise(sources, targets):
+def newer_pairwise (sources, targets):
     """Walk two filename lists in parallel, testing if each source is newer
     than its corresponding target.  Return a pair of lists (sources,
     targets) where source is newer than target, according to the semantics
@@ -41,18 +43,19 @@
     # build a pair of lists (sources, targets) where  source is newer
     n_sources = []
     n_targets = []
-    for source, target in zip(sources, targets):
-        if newer(source, target):
-            n_sources.append(source)
-            n_targets.append(target)
+    for i in range(len(sources)):
+        if newer(sources[i], targets[i]):
+            n_sources.append(sources[i])
+            n_targets.append(targets[i])
 
-    return n_sources, n_targets
+    return (n_sources, n_targets)
+
+# newer_pairwise ()
 
-def newer_group(sources, target, missing='error'):
-    """Return true if 'target' is out-of-date with respect to any file
-    listed in 'sources'.
 
-    In other words, if 'target' exists and is newer
+def newer_group (sources, target, missing='error'):
+    """Return true if 'target' is out-of-date with respect to any file
+    listed in 'sources'.  In other words, if 'target' exists and is newer
     than every file in 'sources', return false; otherwise return true.
     'missing' controls what we do when a source file is missing; the
     default ("error") is to blow up with an OSError from inside 'stat()';
@@ -65,14 +68,14 @@
     """
     # If the target doesn't even exist, then it's definitely out-of-date.
     if not os.path.exists(target):
-        return True
+        return 1
 
     # Otherwise we have to find out the hard way: if *any* source file
     # is more recent than 'target', then 'target' is out-of-date and
     # we can immediately return true.  If we fall through to the end
     # of the loop, then 'target' is up-to-date and we return false.
-    target_mtime = os.stat(target).st_mtime
-
+    from stat import ST_MTIME
+    target_mtime = os.stat(target)[ST_MTIME]
     for source in sources:
         if not os.path.exists(source):
             if missing == 'error':      # blow up when we stat() the file
@@ -80,9 +83,12 @@
             elif missing == 'ignore':   # missing source dropped from
                 continue                #  target's dependency list
             elif missing == 'newer':    # missing source means target is
-                return True             #  out-of-date
+                return 1                #  out-of-date
 
-        if os.stat(source).st_mtime > target_mtime:
-            return True
+        source_mtime = os.stat(source)[ST_MTIME]
+        if source_mtime > target_mtime:
+            return 1
+    else:
+        return 0
 
-    return False
+# newer_group ()

Modified: python/branches/py3k/Lib/distutils/dir_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/dir_util.py	(original)
+++ python/branches/py3k/Lib/distutils/dir_util.py	Thu Jul 22 14:50:05 2010
@@ -4,7 +4,7 @@
 
 __revision__ = "$Id$"
 
-import os
+import os, sys
 from distutils.errors import DistutilsFileError, DistutilsInternalError
 from distutils import log
 

Modified: python/branches/py3k/Lib/distutils/dist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/dist.py	(original)
+++ python/branches/py3k/Lib/distutils/dist.py	Thu Jul 22 14:50:05 2010
@@ -7,15 +7,13 @@
 __revision__ = "$Id$"
 
 import sys, os, re
-from email import message_from_file
 
 try:
     import warnings
 except ImportError:
     warnings = None
 
-from distutils.errors import (DistutilsOptionError, DistutilsArgError,
-                              DistutilsModuleError, DistutilsClassError)
+from distutils.errors import *
 from distutils.fancy_getopt import FancyGetopt, translate_longopt
 from distutils.util import check_environ, strtobool, rfc822_escape
 from distutils import log
@@ -55,9 +53,7 @@
                       ('quiet', 'q', "run quietly (turns verbosity off)"),
                       ('dry-run', 'n', "don't actually do anything"),
                       ('help', 'h', "show detailed help message"),
-                      ('no-user-cfg', None,
-                       'ignore pydistutils.cfg in your home directory'),
-    ]
+                     ]
 
     # 'common_usage' is a short (2-3 line) string describing the common
     # usage of the setup script.
@@ -264,22 +260,6 @@
                     else:
                         sys.stderr.write(msg + "\n")
 
-        # no-user-cfg is handled before other command line args
-        # because other args override the config files, and this
-        # one is needed before we can load the config files.
-        # If attrs['script_args'] wasn't passed, assume false.
-        #
-        # This also make sure we just look at the global options
-        self.want_user_cfg = True
-
-        if self.script_args is not None:
-            for arg in self.script_args:
-                if not arg.startswith('-'):
-                    break
-                if arg == '--no-user-cfg':
-                    self.want_user_cfg = False
-                    break
-
         self.finalize_options()
 
     def get_option_dict(self, command):
@@ -331,10 +311,7 @@
         Distutils installation directory (ie. where the top-level
         Distutils __inst__.py file lives), a file in the user's home
         directory named .pydistutils.cfg on Unix and pydistutils.cfg
-        on Windows/Mac; and setup.cfg in the current directory.
-
-        The file in the user's home directory can be disabled with the
-        --no-user-cfg option.
+        on Windows/Mac, and setup.cfg in the current directory.
         """
         files = []
         check_environ()
@@ -354,19 +331,15 @@
             user_filename = "pydistutils.cfg"
 
         # And look for the user config file
-        if self.want_user_cfg:
-            user_file = os.path.join(os.path.expanduser('~'), user_filename)
-            if os.path.isfile(user_file):
-                files.append(user_file)
+        user_file = os.path.join(os.path.expanduser('~'), user_filename)
+        if os.path.isfile(user_file):
+            files.append(user_file)
 
         # All platforms support local setup.cfg
         local_file = "setup.cfg"
         if os.path.isfile(local_file):
             files.append(local_file)
 
-        if DEBUG:
-            self.announce("using config files: %s" % ', '.join(files))
-
         return files
 
     def parse_config_files(self, filenames=None):
@@ -1016,80 +989,25 @@
                          "provides", "requires", "obsoletes",
                          )
 
-    def __init__(self, path=None):
-        if path is not None:
-            self.read_pkg_file(open(path))
-        else:
-            self.name = None
-            self.version = None
-            self.author = None
-            self.author_email = None
-            self.maintainer = None
-            self.maintainer_email = None
-            self.url = None
-            self.license = None
-            self.description = None
-            self.long_description = None
-            self.keywords = None
-            self.platforms = None
-            self.classifiers = None
-            self.download_url = None
-            # PEP 314
-            self.provides = None
-            self.requires = None
-            self.obsoletes = None
-
-    def read_pkg_file(self, file):
-        """Reads the metadata values from a file object."""
-        msg = message_from_file(file)
-
-        def _read_field(name):
-            value = msg[name]
-            if value == 'UNKNOWN':
-                return None
-            return value
-
-        def _read_list(name):
-            values = msg.get_all(name, None)
-            if values == []:
-                return None
-            return values
-
-        metadata_version = msg['metadata-version']
-        self.name = _read_field('name')
-        self.version = _read_field('version')
-        self.description = _read_field('summary')
-        # we are filling author only.
-        self.author = _read_field('author')
+    def __init__ (self):
+        self.name = None
+        self.version = None
+        self.author = None
+        self.author_email = None
         self.maintainer = None
-        self.author_email = _read_field('author-email')
         self.maintainer_email = None
-        self.url = _read_field('home-page')
-        self.license = _read_field('license')
-
-        if 'download-url' in msg:
-            self.download_url = _read_field('download-url')
-        else:
-            self.download_url = None
-
-        self.long_description = _read_field('description')
-        self.description = _read_field('summary')
-
-        if 'keywords' in msg:
-            self.keywords = _read_field('keywords').split(',')
-
-        self.platforms = _read_list('platform')
-        self.classifiers = _read_list('classifier')
-
-        # PEP 314 - these fields only exist in 1.1
-        if metadata_version == '1.1':
-            self.requires = _read_list('requires')
-            self.provides = _read_list('provides')
-            self.obsoletes = _read_list('obsoletes')
-        else:
-            self.requires = None
-            self.provides = None
-            self.obsoletes = None
+        self.url = None
+        self.license = None
+        self.description = None
+        self.long_description = None
+        self.keywords = None
+        self.platforms = None
+        self.classifiers = None
+        self.download_url = None
+        # PEP 314
+        self.provides = None
+        self.requires = None
+        self.obsoletes = None
 
     def write_pkg_info(self, base_dir):
         """Write the PKG-INFO file into the release tree.

Modified: python/branches/py3k/Lib/distutils/emxccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/emxccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/emxccompiler.py	Thu Jul 22 14:50:05 2010
@@ -21,13 +21,12 @@
 
 __revision__ = "$Id$"
 
-import os, sys, copy
-from warnings import warn
-
+import os,sys,copy
+from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
 from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
-from distutils.util import get_compiler_versions
+from distutils import log
 
 class EMXCCompiler (UnixCCompiler):
 
@@ -56,8 +55,8 @@
                 ("Reason: %s." % details) +
                 "Compiling may fail because of undefined preprocessor macros.")
 
-        gcc_version, ld_version, dllwrap_version = get_compiler_versions()
-        self.gcc_version, self.ld_version = gcc_version, ld_version
+        (self.gcc_version, self.ld_version) = \
+            get_versions()
         self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" %
                          (self.gcc_version,
                           self.ld_version) )
@@ -292,11 +291,23 @@
     """ Try to find out the versions of gcc and ld.
         If not possible it returns None for it.
     """
-    warn("'distutils.emxccompiler.get_versions' is deprecated "
-         "use 'distutils.util.get_compiler_versions' instead",
-         DeprecationWarning)
-
+    from distutils.version import StrictVersion
+    from distutils.spawn import find_executable
+    import re
+
+    gcc_exe = find_executable('gcc')
+    if gcc_exe:
+        out = os.popen(gcc_exe + ' -dumpversion','r')
+        out_string = out.read()
+        out.close()
+        result = re.search('(\d+\.\d+\.\d+)', out_string, re.ASCII)
+        if result:
+            gcc_version = StrictVersion(result.group(1))
+        else:
+            gcc_version = None
+    else:
+        gcc_version = None
     # EMX ld has no way of reporting version number, and we use GCC
     # anyway - so we can link OMF DLLs
-    gcc_version, ld_version, dllwrap_version = get_compiler_versions()
-    return gcc_version, None
+    ld_version = None
+    return (gcc_version, ld_version)

Modified: python/branches/py3k/Lib/distutils/errors.py
==============================================================================
--- python/branches/py3k/Lib/distutils/errors.py	(original)
+++ python/branches/py3k/Lib/distutils/errors.py	Thu Jul 22 14:50:05 2010
@@ -10,79 +10,90 @@
 
 __revision__ = "$Id$"
 
-class DistutilsError(Exception):
+class DistutilsError (Exception):
     """The root of all Distutils evil."""
+    pass
 
-class DistutilsModuleError(DistutilsError):
+class DistutilsModuleError (DistutilsError):
     """Unable to load an expected module, or to find an expected class
     within some module (in particular, command modules and classes)."""
+    pass
 
-class DistutilsClassError(DistutilsError):
+class DistutilsClassError (DistutilsError):
     """Some command class (or possibly distribution class, if anyone
     feels a need to subclass Distribution) is found not to be holding
     up its end of the bargain, ie. implementing some part of the
     "command "interface."""
+    pass
 
-class DistutilsGetoptError(DistutilsError):
+class DistutilsGetoptError (DistutilsError):
     """The option table provided to 'fancy_getopt()' is bogus."""
+    pass
 
-class DistutilsArgError(DistutilsError):
+class DistutilsArgError (DistutilsError):
     """Raised by fancy_getopt in response to getopt.error -- ie. an
     error in the command line usage."""
+    pass
 
-class DistutilsFileError(DistutilsError):
+class DistutilsFileError (DistutilsError):
     """Any problems in the filesystem: expected file not found, etc.
     Typically this is for problems that we detect before IOError or
     OSError could be raised."""
+    pass
 
-class DistutilsOptionError(DistutilsError):
+class DistutilsOptionError (DistutilsError):
     """Syntactic/semantic errors in command options, such as use of
     mutually conflicting options, or inconsistent options,
     badly-spelled values, etc.  No distinction is made between option
     values originating in the setup script, the command line, config
     files, or what-have-you -- but if we *know* something originated in
     the setup script, we'll raise DistutilsSetupError instead."""
+    pass
 
-class DistutilsSetupError(DistutilsError):
+class DistutilsSetupError (DistutilsError):
     """For errors that can be definitely blamed on the setup script,
     such as invalid keyword arguments to 'setup()'."""
+    pass
 
-class DistutilsPlatformError(DistutilsError):
+class DistutilsPlatformError (DistutilsError):
     """We don't know how to do something on the current platform (but
     we do know how to do it on some platform) -- eg. trying to compile
     C files on a platform not supported by a CCompiler subclass."""
+    pass
 
-class DistutilsExecError(DistutilsError):
+class DistutilsExecError (DistutilsError):
     """Any problems executing an external program (such as the C
     compiler, when compiling C files)."""
+    pass
 
-class DistutilsInternalError(DistutilsError):
+class DistutilsInternalError (DistutilsError):
     """Internal inconsistencies or impossibilities (obviously, this
     should never be seen if the code is working!)."""
+    pass
 
-class DistutilsTemplateError(DistutilsError):
+class DistutilsTemplateError (DistutilsError):
     """Syntax error in a file list template."""
 
 class DistutilsByteCompileError(DistutilsError):
     """Byte compile error."""
 
 # Exception classes used by the CCompiler implementation classes
-class CCompilerError(Exception):
+class CCompilerError (Exception):
     """Some compile/link operation failed."""
 
-class PreprocessError(CCompilerError):
+class PreprocessError (CCompilerError):
     """Failure to preprocess one or more C/C++ files."""
 
-class CompileError(CCompilerError):
+class CompileError (CCompilerError):
     """Failure to compile one or more C/C++ source files."""
 
-class LibError(CCompilerError):
+class LibError (CCompilerError):
     """Failure to create a static library from one or more C/C++ object
     files."""
 
-class LinkError(CCompilerError):
+class LinkError (CCompilerError):
     """Failure to link one or more C/C++ object files into an executable
     or shared library file."""
 
-class UnknownFileError(CCompilerError):
+class UnknownFileError (CCompilerError):
     """Attempt to process an unknown file type."""

Modified: python/branches/py3k/Lib/distutils/extension.py
==============================================================================
--- python/branches/py3k/Lib/distutils/extension.py	(original)
+++ python/branches/py3k/Lib/distutils/extension.py	Thu Jul 22 14:50:05 2010
@@ -6,6 +6,7 @@
 __revision__ = "$Id$"
 
 import os
+import sys
 import warnings
 
 # This class is really only used by the "build_ext" command, so it might
@@ -134,17 +135,14 @@
 
 def read_setup_file(filename):
     """Reads a Setup file and returns Extension instances."""
-    warnings.warn('distutils.extensions.read_setup_file is deprecated. '
-                  'It will be removed in the next Python release.')
-    _sysconfig = __import__('sysconfig')
-    from distutils.sysconfig import (expand_makefile_vars,
+    from distutils.sysconfig import (parse_makefile, expand_makefile_vars,
                                      _variable_rx)
 
     from distutils.text_file import TextFile
     from distutils.util import split_quoted
 
     # First pass over the file to gather "VAR = VALUE" assignments.
-    vars = _sysconfig._parse_makefile(filename)
+    vars = parse_makefile(filename)
 
     # Second pass to gobble up the real content: lines of the form
     #   <module> ... [<sourcefile> ...] [<cpparg> ...] [<library> ...]
@@ -164,10 +162,7 @@
             file.warn("'%s' lines not handled yet" % line)
             continue
 
-        with warnings.catch_warnings():
-            warnings.simplefilter("ignore")
-            line = expand_makefile_vars(line, vars)
-
+        line = expand_makefile_vars(line, vars)
         words = split_quoted(line)
 
         # NB. this parses a slightly different syntax than the old

Modified: python/branches/py3k/Lib/distutils/fancy_getopt.py
==============================================================================
--- python/branches/py3k/Lib/distutils/fancy_getopt.py	(original)
+++ python/branches/py3k/Lib/distutils/fancy_getopt.py	Thu Jul 22 14:50:05 2010
@@ -10,11 +10,9 @@
 
 __revision__ = "$Id$"
 
-import sys
-import string
-import re
+import sys, string, re
 import getopt
-from distutils.errors import DistutilsGetoptError, DistutilsArgError
+from distutils.errors import *
 
 # Much like command_re in distutils.core, this is close to but not quite
 # the same as a Python NAME -- except, in the spirit of most GNU
@@ -446,3 +444,16 @@
         'options' will be initialized to None."""
         for opt in options:
             setattr(self, opt, None)
+
+
+if __name__ == "__main__":
+    text = """\
+Tra-la-la, supercalifragilisticexpialidocious.
+How *do* you spell that odd word, anyways?
+(Someone ask Mary -- she'll know [or she'll
+say, "How should I know?"].)"""
+
+    for w in (10, 20, 30, 40):
+        print("width: %d" % w)
+        print("\n".join(wrap_text(text, w)))
+        print()

Modified: python/branches/py3k/Lib/distutils/file_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/file_util.py	(original)
+++ python/branches/py3k/Lib/distutils/file_util.py	Thu Jul 22 14:50:05 2010
@@ -10,18 +10,17 @@
 from distutils import log
 
 # for generating verbose output in 'copy_file()'
-_copy_action = {None: 'copying',
-                'hard': 'hard linking',
-                'sym': 'symbolically linking'}
+_copy_action = { None:   'copying',
+                 'hard': 'hard linking',
+                 'sym':  'symbolically linking' }
 
 
 def _copy_file_contents(src, dst, buffer_size=16*1024):
-    """Copy the file 'src' to 'dst'.
-
-    Both must be filenames. Any error opening either file, reading from
-    'src', or writing to 'dst', raises DistutilsFileError.  Data is
-    read/written in chunks of 'buffer_size' bytes (default 16k).  No attempt
-    is made to handle anything apart from regular files.
+    """Copy the file 'src' to 'dst'; both must be filenames.  Any error
+    opening either file, reading from 'src', or writing to 'dst', raises
+    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
+    bytes (default 16k).  No attempt is made to handle anything apart from
+    regular files.
     """
     # Stolen from shutil module in the standard library, but with
     # custom error-handling added.
@@ -69,16 +68,15 @@
 
 def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
               link=None, verbose=1, dry_run=0):
-    """Copy a file 'src' to 'dst'.
-
-    If 'dst' is a directory, then 'src' is copied there with the same name;
-    otherwise, it must be a filename.  (If the file exists, it will be
-    ruthlessly clobbered.)  If 'preserve_mode' is true (the default),
-    the file's mode (type and permission bits, or whatever is analogous on
-    the current platform) is copied.  If 'preserve_times' is true (the
-    default), the last-modified and last-access times are copied as well.
-    If 'update' is true, 'src' will only be copied if 'dst' does not exist,
-    or if 'dst' does exist but is older than 'src'.
+    """Copy a file 'src' to 'dst'.  If 'dst' is a directory, then 'src' is
+    copied there with the same name; otherwise, it must be a filename.  (If
+    the file exists, it will be ruthlessly clobbered.)  If 'preserve_mode'
+    is true (the default), the file's mode (type and permission bits, or
+    whatever is analogous on the current platform) is copied.  If
+    'preserve_times' is true (the default), the last-modified and
+    last-access times are copied as well.  If 'update' is true, 'src' will
+    only be copied if 'dst' does not exist, or if 'dst' does exist but is
+    older than 'src'.
 
     'link' allows you to make hard links (os.link) or symbolic links
     (os.symlink) instead of copying: set it to "hard" or "sym"; if it is
@@ -132,6 +130,15 @@
     if dry_run:
         return (dst, 1)
 
+    # On Mac OS, use the native file copy routine
+    if os.name == 'mac':
+        import macostools
+        try:
+            macostools.copy(src, dst, 0, preserve_times)
+        except os.error as exc:
+            raise DistutilsFileError(
+                  "could not copy '%s' to '%s': %s" % (src, dst, exc.args[-1]))
+
     # If linking (hard or symbolic), use the appropriate system call
     # (Unix only, of course, but that's the caller's responsibility)
     elif link == 'hard':
@@ -159,12 +166,13 @@
 
 
 # XXX I suspect this is Unix-specific -- need porting help!
-def move_file(src, dst, verbose=1, dry_run=0):
-    """Move a file 'src' to 'dst'.
-
-    If 'dst' is a directory, the file will be moved into it with the same
-    name; otherwise, 'src' is just renamed to 'dst'.  Return the new
-    full name of the file.
+def move_file (src, dst,
+               verbose=1,
+               dry_run=0):
+
+    """Move a file 'src' to 'dst'.  If 'dst' is a directory, the file will
+    be moved into it with the same name; otherwise, 'src' is just renamed
+    to 'dst'.  Return the new full name of the file.
 
     Handles cross-device moves on Unix using 'copy_file()'.  What about
     other systems???
@@ -221,7 +229,7 @@
     return dst
 
 
-def write_file(filename, contents):
+def write_file (filename, contents):
     """Create a file with the specified name and write 'contents' (a
     sequence of strings without line terminators) to it.
     """

Modified: python/branches/py3k/Lib/distutils/filelist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/filelist.py	(original)
+++ python/branches/py3k/Lib/distutils/filelist.py	Thu Jul 22 14:50:05 2010
@@ -108,7 +108,7 @@
         # defined: it's the first word of the line.  Which of the other
         # three are defined depends on the action; it'll be either
         # patterns, (dir and patterns), or (dir_pattern).
-        action, patterns, dir, dir_pattern = self._parse_template_line(line)
+        (action, patterns, dir, dir_pattern) = self._parse_template_line(line)
 
         # OK, now we know that the action is valid and we have the
         # right number of words on the line for that action -- so we
@@ -175,15 +175,15 @@
             raise DistutilsInternalError(
                   "this cannot happen: invalid action '%s'" % action)
 
+
     # -- Filtering/selection methods -----------------------------------
 
     def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
         """Select strings (presumably filenames) from 'self.files' that
-        match 'pattern', a Unix-style wildcard (glob) pattern.
-
-        Patterns are not quite the same as implemented by the 'fnmatch'
-        module: '*' and '?'  match non-special characters, where "special"
-        is platform-dependent: slash on Unix; colon, slash, and backslash on
+        match 'pattern', a Unix-style wildcard (glob) pattern.  Patterns
+        are not quite the same as implemented by the 'fnmatch' module: '*'
+        and '?'  match non-special characters, where "special" is platform-
+        dependent: slash on Unix; colon, slash, and backslash on
         DOS/Windows; and colon on Mac OS.
 
         If 'anchor' is true (the default), then the pattern match is more
@@ -220,13 +220,13 @@
         return files_found
 
 
-    def exclude_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
+    def exclude_pattern (self, pattern,
+                         anchor=1, prefix=None, is_regex=0):
         """Remove strings (presumably filenames) from 'files' that match
-        'pattern'.
-
-        Other parameters are the same as for 'include_pattern()', above.
-        The list 'self.files' is modified in place. Return 1 if files are
-        found.
+        'pattern'.  Other parameters are the same as for
+        'include_pattern()', above.
+        The list 'self.files' is modified in place.
+        Return True if files are found, False otherwise.
         """
         files_found = False
         pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
@@ -275,11 +275,10 @@
 
 
 def glob_to_re(pattern):
-    """Translate a shell-like glob pattern to a regular expression.
-
-    Return a string containing the regex.  Differs from
-    'fnmatch.translate()' in that '*' does not match "special characters"
-    (which are platform-specific).
+    """Translate a shell-like glob pattern to a regular expression; return
+    a string containing the regex.  Differs from 'fnmatch.translate()' in
+    that '*' does not match "special characters" (which are
+    platform-specific).
     """
     pattern_re = fnmatch.translate(pattern)
 
@@ -297,9 +296,7 @@
 
 def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
     """Translate a shell-like wildcard pattern to a compiled regular
-    expression.
-
-    Return the compiled regex.  If 'is_regex' true,
+    expression.  Return the compiled regex.  If 'is_regex' true,
     then 'pattern' is directly compiled to a regex (if it's a string)
     or just returned as-is (assumes it's a regex object).
     """
@@ -317,7 +314,7 @@
     if prefix is not None:
         # ditch end of pattern character
         empty_pattern = glob_to_re('')
-        prefix_re = glob_to_re(prefix)[:-len(empty_pattern)]
+        prefix_re = (glob_to_re(prefix))[:-len(empty_pattern)]
         pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re)
     else:                               # no prefix -- respect anchor flag
         if anchor:

Modified: python/branches/py3k/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/msvc9compiler.py	(original)
+++ python/branches/py3k/Lib/distutils/msvc9compiler.py	Thu Jul 22 14:50:05 2010
@@ -19,9 +19,10 @@
 import sys
 import re
 
-from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
-                              CompileError, LibError, LinkError)
-from distutils.ccompiler import CCompiler, gen_lib_options
+from distutils.errors import DistutilsExecError, DistutilsPlatformError, \
+                             CompileError, LibError, LinkError
+from distutils.ccompiler import CCompiler, gen_preprocess_options, \
+                                gen_lib_options
 from distutils import log
 from distutils.util import get_platform
 

Modified: python/branches/py3k/Lib/distutils/msvccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/msvccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/msvccompiler.py	Thu Jul 22 14:50:05 2010
@@ -10,12 +10,12 @@
 
 __revision__ = "$Id$"
 
-import sys
-import os
-
-from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
-                              CompileError, LibError, LinkError)
-from distutils.ccompiler import CCompiler, gen_lib_options
+import sys, os
+from distutils.errors import \
+     DistutilsExecError, DistutilsPlatformError, \
+     CompileError, LibError, LinkError
+from distutils.ccompiler import \
+     CCompiler, gen_preprocess_options, gen_lib_options
 from distutils import log
 
 _can_read_reg = False
@@ -124,7 +124,7 @@
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
             else:
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
-        except KeyError:
+        except KeyError as exc: #
             raise DistutilsPlatformError(
             """Python was built with Visual Studio 2003;
 extensions must be built with a compiler than can generate compatible binaries.

Modified: python/branches/py3k/Lib/distutils/sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/sysconfig.py	Thu Jul 22 14:50:05 2010
@@ -7,9 +7,6 @@
 
 Written by:   Fred L. Drake, Jr.
 Email:        <fdrake at acm.org>
-
-**This module has been moved out of Distutils and will be removed from
-Python in the next version (3.3)**
 """
 
 __revision__ = "$Id$"
@@ -17,45 +14,51 @@
 import io
 import os
 import re
-from warnings import warn
-
-from distutils.errors import DistutilsPlatformError
+import sys
 
-# importing sysconfig from Lib
-# to avoid this module to shadow it
-_sysconfig = __import__('sysconfig')
-
-# names defined here to keep backward compatibility
-# for APIs that were relocated
-get_python_version = _sysconfig.get_python_version
-get_config_h_filename = _sysconfig.get_config_h_filename
-parse_config_h = _sysconfig.parse_config_h
-get_config_vars = _sysconfig.get_config_vars
-get_config_var = _sysconfig.get_config_var
-from distutils.ccompiler import customize_compiler
-
-_DEPRECATION_MSG = ("distutils.sysconfig.%s is deprecated. "
-                    "Use the APIs provided by the sysconfig module instead")
-
-def _get_project_base():
-    return _sysconfig._PROJECT_BASE
-
-project_base = _get_project_base()
-
-class _DeprecatedBool(int):
-    def __nonzero__(self):
-        warn(_DEPRECATION_MSG % 'get_python_version', DeprecationWarning)
-        return super(_DeprecatedBool, self).__nonzero__()
+from .errors import DistutilsPlatformError
 
+# These are needed in a couple of spots, so just compute them once.
+PREFIX = os.path.normpath(sys.prefix)
+EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+
+# Path to the base directory of the project. On Windows the binary may
+# live in project/PCBuild9.  If we're dealing with an x64 Windows build,
+# it'll live in project/PCbuild/amd64.
+project_base = os.path.dirname(os.path.abspath(sys.executable))
+if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
+    project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
+# PC/VS7.1
+if os.name == "nt" and "\\pc\\v" in project_base[-10:].lower():
+    project_base = os.path.abspath(os.path.join(project_base, os.path.pardir,
+                                                os.path.pardir))
+# PC/AMD64
+if os.name == "nt" and "\\pcbuild\\amd64" in project_base[-14:].lower():
+    project_base = os.path.abspath(os.path.join(project_base, os.path.pardir,
+                                                os.path.pardir))
+
+# python_build: (Boolean) if true, we're either building Python or
+# building an extension with an un-installed Python, so we use
+# different (hard-wired) directories.
+# Setup.local is available for Makefile builds including VPATH builds,
+# Setup.dist is available on Windows
 def _python_build():
-    return _DeprecatedBool(_sysconfig.is_python_build())
-
+    for fn in ("Setup.dist", "Setup.local"):
+        if os.path.isfile(os.path.join(project_base, "Modules", fn)):
+            return True
+    return False
 python_build = _python_build()
 
-def get_python_inc(plat_specific=0, prefix=None):
-    """This function is deprecated.
+def get_python_version():
+    """Return a string containing the major and minor Python version,
+    leaving off the patchlevel.  Sample return values could be '1.5'
+    or '2.2'.
+    """
+    return sys.version[:3]
+
 
-    Return the directory containing installed Python header files.
+def get_python_inc(plat_specific=0, prefix=None):
+    """Return the directory containing installed Python header files.
 
     If 'plat_specific' is false (the default), this is the path to the
     non-platform-specific header files, i.e. Python.h and so on;
@@ -65,22 +68,39 @@
     If 'prefix' is supplied, use it instead of sys.prefix or
     sys.exec_prefix -- i.e., ignore 'plat_specific'.
     """
-    warn(_DEPRECATION_MSG % 'get_python_inc', DeprecationWarning)
-    get_path = _sysconfig.get_path
-
-    if prefix is not None:
-        vars = {'base': prefix}
-        return get_path('include', vars=vars)
-
-    if not plat_specific:
-        return get_path('include')
+    if prefix is None:
+        prefix = plat_specific and EXEC_PREFIX or PREFIX
+    if os.name == "posix":
+        if python_build:
+            # Assume the executable is in the build directory.  The
+            # pyconfig.h file should be in the same directory.  Since
+            # the build directory may not be the source directory, we
+            # must use "srcdir" from the makefile to find the "Include"
+            # directory.
+            base = os.path.dirname(os.path.abspath(sys.executable))
+            if plat_specific:
+                return base
+            else:
+                incdir = os.path.join(get_config_var('srcdir'), 'Include')
+                return os.path.normpath(incdir)
+        return os.path.join(prefix, "include", "python" + get_python_version())
+    elif os.name == "nt":
+        return os.path.join(prefix, "include")
+    elif os.name == "mac":
+        if plat_specific:
+            return os.path.join(prefix, "Mac", "Include")
+        else:
+            return os.path.join(prefix, "Include")
+    elif os.name == "os2":
+        return os.path.join(prefix, "Include")
     else:
-        return get_path('platinclude')
+        raise DistutilsPlatformError(
+            "I don't know where Python installs its C header files "
+            "on platform '%s'" % os.name)
 
-def get_python_lib(plat_specific=False, standard_lib=False, prefix=None):
-    """This function is deprecated.
 
-    Return the directory containing the Python library (standard or
+def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
+    """Return the directory containing the Python library (standard or
     site additions).
 
     If 'plat_specific' is true, return the directory containing
@@ -93,33 +113,149 @@
     If 'prefix' is supplied, use it instead of sys.prefix or
     sys.exec_prefix -- i.e., ignore 'plat_specific'.
     """
-    warn(_DEPRECATION_MSG % 'get_python_lib', DeprecationWarning)
-    vars = {}
-    get_path = _sysconfig.get_path
-    if prefix is not None:
-        if plat_specific:
-            vars['platbase'] = prefix
+    if prefix is None:
+        prefix = plat_specific and EXEC_PREFIX or PREFIX
+
+    if os.name == "posix":
+        libpython = os.path.join(prefix,
+                                 "lib", "python" + get_python_version())
+        if standard_lib:
+            return libpython
+        else:
+            return os.path.join(libpython, "site-packages")
+    elif os.name == "nt":
+        if standard_lib:
+            return os.path.join(prefix, "Lib")
         else:
-            vars['base'] = prefix
-    if standard_lib:
+            if get_python_version() < "2.2":
+                return prefix
+            else:
+                return os.path.join(prefix, "Lib", "site-packages")
+    elif os.name == "mac":
         if plat_specific:
-            return get_path('platstdlib', vars=vars)
+            if standard_lib:
+                return os.path.join(prefix, "Lib", "lib-dynload")
+            else:
+                return os.path.join(prefix, "Lib", "site-packages")
         else:
-            return get_path('stdlib', vars=vars)
+            if standard_lib:
+                return os.path.join(prefix, "Lib")
+            else:
+                return os.path.join(prefix, "Lib", "site-packages")
+    elif os.name == "os2":
+        if standard_lib:
+            return os.path.join(prefix, "Lib")
+        else:
+            return os.path.join(prefix, "Lib", "site-packages")
     else:
-        if plat_specific:
-            return get_path('platlib', vars=vars)
+        raise DistutilsPlatformError(
+            "I don't know where Python installs its library "
+            "on platform '%s'" % os.name)
+
+
+def customize_compiler(compiler):
+    """Do any platform-specific customization of a CCompiler instance.
+
+    Mainly needed on Unix, so we can plug in the information that
+    varies across Unices and is stored in Python's Makefile.
+    """
+    if compiler.compiler_type == "unix":
+        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
+            get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+                            'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
+
+        if 'CC' in os.environ:
+            cc = os.environ['CC']
+        if 'CXX' in os.environ:
+            cxx = os.environ['CXX']
+        if 'LDSHARED' in os.environ:
+            ldshared = os.environ['LDSHARED']
+        if 'CPP' in os.environ:
+            cpp = os.environ['CPP']
         else:
-            return get_path('purelib', vars=vars)
+            cpp = cc + " -E"           # not always
+        if 'LDFLAGS' in os.environ:
+            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
+        if 'CFLAGS' in os.environ:
+            cflags = opt + ' ' + os.environ['CFLAGS']
+            ldshared = ldshared + ' ' + os.environ['CFLAGS']
+        if 'CPPFLAGS' in os.environ:
+            cpp = cpp + ' ' + os.environ['CPPFLAGS']
+            cflags = cflags + ' ' + os.environ['CPPFLAGS']
+            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
+        if 'AR' in os.environ:
+            ar = os.environ['AR']
+        if 'ARFLAGS' in os.environ:
+            archiver = ar + ' ' + os.environ['ARFLAGS']
+        else:
+            archiver = ar + ' ' + ar_flags
+
+        cc_cmd = cc + ' ' + cflags
+        compiler.set_executables(
+            preprocessor=cpp,
+            compiler=cc_cmd,
+            compiler_so=cc_cmd + ' ' + ccshared,
+            compiler_cxx=cxx,
+            linker_so=ldshared,
+            linker_exe=cc,
+            archiver=archiver)
+
+        compiler.shared_lib_extension = so_ext
+
+
+def get_config_h_filename():
+    """Return full pathname of installed pyconfig.h file."""
+    if python_build:
+        if os.name == "nt":
+            inc_dir = os.path.join(project_base, "PC")
+        else:
+            inc_dir = project_base
+    else:
+        inc_dir = get_python_inc(plat_specific=1)
+    if get_python_version() < '2.2':
+        config_h = 'config.h'
+    else:
+        # The name of the config.h file changed in 2.2
+        config_h = 'pyconfig.h'
+    return os.path.join(inc_dir, config_h)
+
 
 def get_makefile_filename():
-    """This function is deprecated.
+    """Return full pathname of installed Makefile from the Python build."""
+    if python_build:
+        return os.path.join(os.path.dirname(sys.executable), "Makefile")
+    lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
+    return os.path.join(lib_dir, "config", "Makefile")
+
+
+def parse_config_h(fp, g=None):
+    """Parse a config.h-style file.
 
-    Return full pathname of installed Makefile from the Python build.
+    A dictionary containing name/value pairs is returned.  If an
+    optional dictionary is passed in as the second argument, it is
+    used instead of a new dictionary.
     """
+    if g is None:
+        g = {}
+    define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
+    undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
+    #
+    while True:
+        line = fp.readline()
+        if not line:
+            break
+        m = define_rx.match(line)
+        if m:
+            n, v = m.group(1, 2)
+            try: v = int(v)
+            except ValueError: pass
+            g[n] = v
+        else:
+            m = undef_rx.match(line)
+            if m:
+                g[m.group(1)] = 0
+    return g
 
-    warn(_DEPRECATION_MSG % 'get_makefile_filename', DeprecationWarning)
-    return _sysconfig._get_makefile_filename()
 
 # Regexes needed for parsing Makefile (and similar syntaxes,
 # like old-style Setup files).
@@ -128,29 +264,91 @@
 _findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")
 
 def parse_makefile(fn, g=None):
-    """This function is deprecated.
-
-    Parse a Makefile-style file.
+    """Parse a Makefile-style file.
 
     A dictionary containing name/value pairs is returned.  If an
     optional dictionary is passed in as the second argument, it is
     used instead of a new dictionary.
     """
-    warn(_DEPRECATION_MSG % 'parse_makefile', DeprecationWarning)
-    return _sysconfig._parse_makefile(fn, g)
+    from distutils.text_file import TextFile
+    fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1)
+
+    if g is None:
+        g = {}
+    done = {}
+    notdone = {}
+
+    while True:
+        line = fp.readline()
+        if line is None: # eof
+            break
+        m = _variable_rx.match(line)
+        if m:
+            n, v = m.group(1, 2)
+            v = v.strip()
+            # `$$' is a literal `$' in make
+            tmpv = v.replace('$$', '')
+
+            if "$" in tmpv:
+                notdone[n] = v
+            else:
+                try:
+                    v = int(v)
+                except ValueError:
+                    # insert literal `$'
+                    done[n] = v.replace('$$', '$')
+                else:
+                    done[n] = v
+
+    # do variable interpolation here
+    while notdone:
+        for name in list(notdone):
+            value = notdone[name]
+            m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
+            if m:
+                n = m.group(1)
+                found = True
+                if n in done:
+                    item = str(done[n])
+                elif n in notdone:
+                    # get it on a subsequent round
+                    found = False
+                elif n in os.environ:
+                    # do it like make: fall back to environment
+                    item = os.environ[n]
+                else:
+                    done[n] = item = ""
+                if found:
+                    after = value[m.end():]
+                    value = value[:m.start()] + item + after
+                    if "$" in after:
+                        notdone[name] = value
+                    else:
+                        try: value = int(value)
+                        except ValueError:
+                            done[name] = value.strip()
+                        else:
+                            done[name] = value
+                        del notdone[name]
+            else:
+                # bogus variable reference; just drop it since we can't deal
+                del notdone[name]
+
+    fp.close()
+
+    # save the results in the global dictionary
+    g.update(done)
+    return g
 
-def expand_makefile_vars(s, vars):
-    """This function is deprecated.
 
-    Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
+def expand_makefile_vars(s, vars):
+    """Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
     'string' according to 'vars' (a dictionary mapping variable names to
     values).  Variables not present in 'vars' are silently expanded to the
     empty string.  The variable values in 'vars' should not contain further
     variable expansions; if 'vars' is the output of 'parse_makefile()',
     you're fine.  Returns a variable-expanded version of 's'.
     """
-    warn('this function will be removed in then next version of Python',
-         DeprecationWarning)
 
     # This algorithm does multiple expansion, so if vars['foo'] contains
     # "${bar}", it will expand ${foo} to ${bar}, and then expand
@@ -166,3 +364,220 @@
         else:
             break
     return s
+
+
+_config_vars = None
+
+def _init_posix():
+    """Initialize the module as appropriate for POSIX systems."""
+    g = {}
+    # load the installed Makefile:
+    try:
+        filename = get_makefile_filename()
+        parse_makefile(filename, g)
+    except IOError as msg:
+        my_msg = "invalid Python installation: unable to open %s" % filename
+        if hasattr(msg, "strerror"):
+            my_msg = my_msg + " (%s)" % msg.strerror
+
+        raise DistutilsPlatformError(my_msg)
+
+    # load the installed pyconfig.h:
+    try:
+        filename = get_config_h_filename()
+        parse_config_h(io.open(filename), g)
+    except IOError as msg:
+        my_msg = "invalid Python installation: unable to open %s" % filename
+        if hasattr(msg, "strerror"):
+            my_msg = my_msg + " (%s)" % msg.strerror
+
+        raise DistutilsPlatformError(my_msg)
+
+    # On MacOSX we need to check the setting of the environment variable
+    # 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 'MACOSX_DEPLOYMENT_TARGET' in g:
+        cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
+        cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
+        if cur_target == '':
+            cur_target = cfg_target
+            os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target)
+        elif [int(x) for x in cfg_target.split('.')] > [int(x) for x in cur_target.split('.')]:
+            my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure'
+                % (cur_target, cfg_target))
+            raise DistutilsPlatformError(my_msg)
+
+    # On AIX, there are wrong paths to the linker scripts in the Makefile
+    # -- these paths are relative to the Python source, but when installed
+    # the scripts are in another directory.
+    if python_build:
+        g['LDSHARED'] = g['BLDSHARED']
+
+    elif get_python_version() < '2.1':
+        # The following two branches are for 1.5.2 compatibility.
+        if sys.platform == 'aix4':          # what about AIX 3.x ?
+            # Linker script is in the config directory, not in Modules as the
+            # Makefile says.
+            python_lib = get_python_lib(standard_lib=1)
+            ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix')
+            python_exp = os.path.join(python_lib, 'config', 'python.exp')
+
+            g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp)
+
+    global _config_vars
+    _config_vars = g
+
+
+def _init_nt():
+    """Initialize the module as appropriate for NT"""
+    g = {}
+    # set basic install directories
+    g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
+    g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
+
+    # XXX hmmm.. a normal install puts include files here
+    g['INCLUDEPY'] = get_python_inc(plat_specific=0)
+
+    g['SO'] = '.pyd'
+    g['EXE'] = ".exe"
+    g['VERSION'] = get_python_version().replace(".", "")
+    g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
+
+    global _config_vars
+    _config_vars = g
+
+
+def _init_mac():
+    """Initialize the module as appropriate for Macintosh systems"""
+    g = {}
+    # set basic install directories
+    g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
+    g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
+
+    # XXX hmmm.. a normal install puts include files here
+    g['INCLUDEPY'] = get_python_inc(plat_specific=0)
+
+    import MacOS
+    if not hasattr(MacOS, 'runtimemodel'):
+        g['SO'] = '.ppc.slb'
+    else:
+        g['SO'] = '.%s.slb' % MacOS.runtimemodel
+
+    # XXX are these used anywhere?
+    g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib")
+    g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib")
+
+    # These are used by the extension module build
+    g['srcdir'] = ':'
+    global _config_vars
+    _config_vars = g
+
+
+def _init_os2():
+    """Initialize the module as appropriate for OS/2"""
+    g = {}
+    # set basic install directories
+    g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
+    g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
+
+    # XXX hmmm.. a normal install puts include files here
+    g['INCLUDEPY'] = get_python_inc(plat_specific=0)
+
+    g['SO'] = '.pyd'
+    g['EXE'] = ".exe"
+
+    global _config_vars
+    _config_vars = g
+
+
+def get_config_vars(*args):
+    """With no arguments, return a dictionary of all configuration
+    variables relevant for the current platform.  Generally this includes
+    everything needed to build extensions and install both pure modules and
+    extensions.  On Unix, this means every variable defined in Python's
+    installed Makefile; on Windows and Mac OS it's a much smaller set.
+
+    With arguments, return a list of values that result from looking up
+    each argument in the configuration variable dictionary.
+    """
+    global _config_vars
+    if _config_vars is None:
+        func = globals().get("_init_" + os.name)
+        if func:
+            func()
+        else:
+            _config_vars = {}
+
+        # Normalized versions of prefix and exec_prefix are handy to have;
+        # in fact, these are the standard versions used most places in the
+        # Distutils.
+        _config_vars['prefix'] = PREFIX
+        _config_vars['exec_prefix'] = EXEC_PREFIX
+
+        # Convert srcdir into an absolute path if it appears necessary.
+        # Normally it is relative to the build directory.  However, during
+        # testing, for example, we might be running a non-installed python
+        # from a different directory.
+        if python_build and os.name == "posix":
+            base = os.path.dirname(os.path.abspath(sys.executable))
+            if (not os.path.isabs(_config_vars['srcdir']) and
+                base != os.getcwd()):
+                # srcdir is relative and we are not in the same directory
+                # as the executable. Assume executable is in the build
+                # directory and make srcdir absolute.
+                srcdir = os.path.join(base, _config_vars['srcdir'])
+                _config_vars['srcdir'] = os.path.normpath(srcdir)
+
+        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',
+                        # a number of derived variables. These need to be
+                        # patched up as well.
+                        'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
+                    flags = _config_vars[key]
+                    flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII)
+                    flags = re.sub('-isysroot [^ \t]*', ' ', flags)
+                    _config_vars[key] = flags
+
+            else:
+
+                # Allow the user to override the architecture flags using
+                # an environment variable.
+                # NOTE: This name was introduced by Apple in OSX 10.5 and
+                # is used by several scripting languages distributed with
+                # that OS release.
+
+                if 'ARCHFLAGS' in os.environ:
+                    arch = os.environ['ARCHFLAGS']
+                    for key in ('LDFLAGS', 'BASECFLAGS',
+                        # a number of derived variables. These need to be
+                        # patched up as well.
+                        'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
+
+                        flags = _config_vars[key]
+                        flags = re.sub('-arch\s+\w+\s', ' ', flags)
+                        flags = flags + ' ' + arch
+                        _config_vars[key] = flags
+
+    if args:
+        vals = []
+        for name in args:
+            vals.append(_config_vars.get(name))
+        return vals
+    else:
+        return _config_vars
+
+def get_config_var(name):
+    """Return the value of a single variable using the dictionary
+    returned by 'get_config_vars()'.  Equivalent to
+    get_config_vars().get(name)
+    """
+    return get_config_vars().get(name)

Modified: python/branches/py3k/Lib/distutils/tests/support.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/support.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/support.py	Thu Jul 22 14:50:05 2010
@@ -3,19 +3,11 @@
 import shutil
 import tempfile
 from copy import deepcopy
-import warnings
 
 from distutils import log
 from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
 from distutils.core import Distribution
 
-def capture_warnings(func):
-    def _capture_warnings(*args, **kw):
-        with warnings.catch_warnings():
-            warnings.simplefilter("ignore")
-            return func(*args, **kw)
-    return _capture_warnings
-
 class LoggingSilencer(object):
 
     def setUp(self):
@@ -63,8 +55,6 @@
         super().tearDown()
         while self.tempdirs:
             d = self.tempdirs.pop()
-            if not os.path.exists(d):
-                continue
             shutil.rmtree(d, os.name in ('nt', 'cygwin'))
 
     def mkdtemp(self):

Modified: python/branches/py3k/Lib/distutils/tests/test_archive_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_archive_util.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_archive_util.py	Thu Jul 22 14:50:05 2010
@@ -15,30 +15,15 @@
 from test.support import check_warnings
 
 try:
-    import grp
-    import pwd
-    UID_GID_SUPPORT = True
-except ImportError:
-    UID_GID_SUPPORT = False
-
-try:
     import zipfile
     ZIP_SUPPORT = True
 except ImportError:
     ZIP_SUPPORT = find_executable('zip')
 
-# some tests will fail if zlib is not available
-try:
-    import zlib
-except ImportError:
-    zlib = None
-
-
 class ArchiveUtilTestCase(support.TempdirManager,
                           support.LoggingSilencer,
                           unittest.TestCase):
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_make_tarball(self):
         # creating something to tar
         tmpdir = self.mkdtemp()
@@ -49,7 +34,7 @@
 
         tmpdir2 = self.mkdtemp()
         unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
-                            "source and target should be on same drive")
+                            "Source and target should be on same drive")
 
         base_name = os.path.join(tmpdir2, 'archive')
 
@@ -99,7 +84,6 @@
         base_name = os.path.join(tmpdir2, 'archive')
         return tmpdir, tmpdir2, base_name
 
-    @unittest.skipUnless(zlib, "Requires zlib")
     @unittest.skipUnless(find_executable('tar') and find_executable('gzip'),
                          'Need the tar command to run')
     def test_tarfile_vs_tar(self):
@@ -185,7 +169,6 @@
         self.assertTrue(not os.path.exists(tarball))
         self.assertEquals(len(w.warnings), 1)
 
-    @unittest.skipUnless(zlib, "Requires zlib")
     @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
     def test_make_zipfile(self):
         # creating something to tar
@@ -210,59 +193,6 @@
         base_name = os.path.join(tmpdir, 'archive')
         self.assertRaises(ValueError, make_archive, base_name, 'xxx')
 
-    @unittest.skipUnless(zlib, "Requires zlib")
-    def test_make_archive_owner_group(self):
-        # testing make_archive with owner and group, with various combinations
-        # this works even if there's not gid/uid support
-        if UID_GID_SUPPORT:
-            group = grp.getgrgid(0)[0]
-            owner = pwd.getpwuid(0)[0]
-        else:
-            group = owner = 'root'
-
-        base_dir, root_dir, base_name =  self._create_files()
-        base_name = os.path.join(self.mkdtemp() , 'archive')
-        res = make_archive(base_name, 'zip', root_dir, base_dir, owner=owner,
-                           group=group)
-        self.assertTrue(os.path.exists(res))
-
-        res = make_archive(base_name, 'zip', root_dir, base_dir)
-        self.assertTrue(os.path.exists(res))
-
-        res = make_archive(base_name, 'tar', root_dir, base_dir,
-                           owner=owner, group=group)
-        self.assertTrue(os.path.exists(res))
-
-        res = make_archive(base_name, 'tar', root_dir, base_dir,
-                           owner='kjhkjhkjg', group='oihohoh')
-        self.assertTrue(os.path.exists(res))
-
-    @unittest.skipUnless(zlib, "Requires zlib")
-    @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
-    def test_tarfile_root_owner(self):
-        tmpdir, tmpdir2, base_name =  self._create_files()
-        old_dir = os.getcwd()
-        os.chdir(tmpdir)
-        group = grp.getgrgid(0)[0]
-        owner = pwd.getpwuid(0)[0]
-        try:
-            archive_name = make_tarball(base_name, 'dist', compress=None,
-                                        owner=owner, group=group)
-        finally:
-            os.chdir(old_dir)
-
-        # check if the compressed tarball was created
-        self.assertTrue(os.path.exists(archive_name))
-
-        # now checks the rights
-        archive = tarfile.open(archive_name)
-        try:
-            for member in archive.getmembers():
-                self.assertEquals(member.uid, 0)
-                self.assertEquals(member.gid, 0)
-        finally:
-            archive.close()
-
     def test_make_archive_cwd(self):
         current_dir = os.getcwd()
         def _breaks(*args, **kw):

Modified: python/branches/py3k/Lib/distutils/tests/test_bdist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_bdist.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_bdist.py	Thu Jul 22 14:50:05 2010
@@ -5,8 +5,6 @@
 import tempfile
 import shutil
 
-from test.support import run_unittest
-
 from distutils.core import Distribution
 from distutils.command.bdist import bdist
 from distutils.tests import support
@@ -42,4 +40,4 @@
     return unittest.makeSuite(BuildTestCase)
 
 if __name__ == '__main__':
-    run_unittest(test_suite())
+    test_support.run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_bdist_dumb.py	Thu Jul 22 14:50:05 2010
@@ -4,15 +4,6 @@
 import sys
 import os
 
-# zlib is not used here, but if it's not available
-# test_simple_built will fail
-try:
-    import zlib
-except ImportError:
-    zlib = None
-
-from test.support import run_unittest
-
 from distutils.core import Distribution
 from distutils.command.bdist_dumb import bdist_dumb
 from distutils.tests import support
@@ -42,7 +33,6 @@
         sys.argv[:] = self.old_sys_argv[1]
         super(BuildDumbTestCase, self).tearDown()
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_simple_built(self):
 
         # let's create a simple package
@@ -83,23 +73,8 @@
         # now let's check what we have in the zip file
         # XXX to be done
 
-    def test_finalize_options(self):
-        pkg_dir, dist = self.create_dist()
-        os.chdir(pkg_dir)
-        cmd = bdist_dumb(dist)
-        self.assertEquals(cmd.bdist_dir, None)
-        cmd.finalize_options()
-
-        # bdist_dir is initialized to bdist_base/dumb if not set
-        base = cmd.get_finalized_command('bdist').bdist_base
-        self.assertEquals(cmd.bdist_dir, os.path.join(base, 'dumb'))
-
-        # the format is set to a default value depending on the os.name
-        default = cmd.default_format[os.name]
-        self.assertEquals(cmd.format, default)
-
 def test_suite():
     return unittest.makeSuite(BuildDumbTestCase)
 
 if __name__ == '__main__':
-    run_unittest(test_suite())
+    test_support.run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py	Thu Jul 22 14:50:05 2010
@@ -6,8 +6,6 @@
 import tempfile
 import shutil
 
-from test.support import run_unittest
-
 from distutils.core import Distribution
 from distutils.command.bdist_rpm import bdist_rpm
 from distutils.tests import support
@@ -124,4 +122,4 @@
     return unittest.makeSuite(BuildRpmTestCase)
 
 if __name__ == '__main__':
-    run_unittest(test_suite())
+    test_support.run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py	Thu Jul 22 14:50:05 2010
@@ -1,8 +1,6 @@
 """Tests for distutils.command.bdist_wininst."""
 import unittest
 
-from test.support import run_unittest
-
 from distutils.command.bdist_wininst import bdist_wininst
 from distutils.tests import support
 
@@ -29,4 +27,4 @@
     return unittest.makeSuite(BuildWinInstTestCase)
 
 if __name__ == '__main__':
-    run_unittest(test_suite())
+    test_support.run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_build_clib.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_clib.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_clib.py	Thu Jul 22 14:50:05 2010
@@ -120,7 +120,8 @@
         # before we run the command, we want to make sure
         # all commands are present on the system
         # by creating a compiler and checking its executables
-        from distutils.ccompiler import new_compiler, customize_compiler
+        from distutils.ccompiler import new_compiler
+        from distutils.sysconfig import customize_compiler
 
         compiler = new_compiler()
         customize_compiler(compiler)

Modified: python/branches/py3k/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_ext.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_ext.py	Thu Jul 22 14:50:05 2010
@@ -3,13 +3,10 @@
 import tempfile
 import shutil
 from io import StringIO
-import warnings
-from test.support import check_warnings
-from test.support import captured_stdout
 
 from distutils.core import Extension, Distribution
 from distutils.command.build_ext import build_ext
-import sysconfig
+from distutils import sysconfig
 from distutils.tests.support import TempdirManager
 from distutils.tests.support import LoggingSilencer
 from distutils.extension import Extension
@@ -25,23 +22,19 @@
 
 def _get_source_filename():
     srcdir = sysconfig.get_config_var('srcdir')
-    if srcdir is None:
-        return os.path.join(sysconfig.project_base, 'Modules', 'xxmodule.c')
     return os.path.join(srcdir, 'Modules', 'xxmodule.c')
 
-_XX_MODULE_PATH = _get_source_filename()
-
-class BuildExtTestCase(TempdirManager, LoggingSilencer, unittest.TestCase):
-
+class BuildExtTestCase(TempdirManager,
+                       LoggingSilencer,
+                       unittest.TestCase):
     def setUp(self):
         # Create a simple test environment
         # Note that we're making changes to sys.path
         super(BuildExtTestCase, self).setUp()
         self.tmp_dir = self.mkdtemp()
-        if os.path.exists(_XX_MODULE_PATH):
-            self.sys_path = sys.path[:]
-            sys.path.append(self.tmp_dir)
-            shutil.copy(_XX_MODULE_PATH, self.tmp_dir)
+        self.sys_path = sys.path, sys.path[:]
+        sys.path.append(self.tmp_dir)
+        shutil.copy(_get_source_filename(), self.tmp_dir)
         if sys.version > "2.6":
             import site
             self.old_user_base = site.USER_BASE
@@ -49,19 +42,6 @@
             from distutils.command import build_ext
             build_ext.USER_BASE = site.USER_BASE
 
-    def tearDown(self):
-        # Get everything back to normal
-        if os.path.exists(_XX_MODULE_PATH):
-            support.unload('xx')
-            sys.path[:] = self.sys_path
-            # XXX on Windows the test leaves a directory
-            # with xx module in TEMP
-        shutil.rmtree(self.tmp_dir, os.name == 'nt' or
-                                    sys.platform == 'cygwin')
-        super(BuildExtTestCase, self).tearDown()
-
-    @unittest.skipIf(not os.path.exists(_XX_MODULE_PATH),
-                     'xxmodule.c not found')
     def test_build_ext(self):
         global ALREADY_TESTED
         xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
@@ -104,23 +84,35 @@
         self.assertTrue(isinstance(xx.Null(), xx.Null))
         self.assertTrue(isinstance(xx.Str(), xx.Str))
 
+    def tearDown(self):
+        # Get everything back to normal
+        support.unload('xx')
+        sys.path = self.sys_path[0]
+        sys.path[:] = self.sys_path[1]
+        if sys.version > "2.6":
+            import site
+            site.USER_BASE = self.old_user_base
+            from distutils.command import build_ext
+            build_ext.USER_BASE = self.old_user_base
+        super(BuildExtTestCase, self).tearDown()
+
     def test_solaris_enable_shared(self):
         dist = Distribution({'name': 'xx'})
         cmd = build_ext(dist)
         old = sys.platform
 
         sys.platform = 'sunos' # fooling finalize_options
-        from sysconfig import _CONFIG_VARS
-        old_var = _CONFIG_VARS.get('Py_ENABLE_SHARED')
-        _CONFIG_VARS['Py_ENABLE_SHARED'] = 1
+        from distutils.sysconfig import  _config_vars
+        old_var = _config_vars.get('Py_ENABLE_SHARED')
+        _config_vars['Py_ENABLE_SHARED'] = 1
         try:
             cmd.ensure_finalized()
         finally:
             sys.platform = old
             if old_var is None:
-                del _CONFIG_VARS['Py_ENABLE_SHARED']
+                del _config_vars['Py_ENABLE_SHARED']
             else:
-                _CONFIG_VARS['Py_ENABLE_SHARED'] = old_var
+                _config_vars['Py_ENABLE_SHARED'] = old_var
 
         # make sure we get some library dirs under solaris
         self.assertTrue(len(cmd.library_dirs) > 0)
@@ -182,10 +174,11 @@
         cmd = build_ext(dist)
         cmd.finalize_options()
 
-        py_include = sysconfig.get_path('include')
+        from distutils import sysconfig
+        py_include = sysconfig.get_python_inc()
         self.assertTrue(py_include in cmd.include_dirs)
 
-        plat_py_include = sysconfig.get_path('platinclude')
+        plat_py_include = sysconfig.get_python_inc(plat_specific=1)
         self.assertTrue(plat_py_include in cmd.include_dirs)
 
         # make sure cmd.libraries is turned into a list
@@ -336,6 +329,7 @@
         self.assertEquals(so_dir, other_tmp_dir)
 
         cmd.inplace = 0
+        cmd.compiler = None
         cmd.run()
         so_file = cmd.get_outputs()[0]
         self.assertTrue(os.path.exists(so_file))
@@ -404,26 +398,6 @@
         wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
         self.assertEquals(wanted, path)
 
-    def test_compiler_deprecation_warning(self):
-        dist = Distribution()
-        cmd = build_ext(dist)
-
-        class MyCompiler(object):
-            def do_something(self):
-                pass
-
-        with check_warnings() as w:
-            warnings.simplefilter("always")
-            cmd.compiler = MyCompiler()
-            self.assertEquals(len(w.warnings), 1)
-            cmd.compile = 'unix'
-            self.assertEquals(len(w.warnings), 1)
-            cmd.compiler = MyCompiler()
-            cmd.compiler.do_something()
-            # two more warnings genereated by the get
-            # and the set
-            self.assertEquals(len(w.warnings), 3)
-
 def test_suite():
     src = _get_source_filename()
     if not os.path.exists(src):

Modified: python/branches/py3k/Lib/distutils/tests/test_build_py.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_py.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_py.py	Thu Jul 22 14:50:05 2010
@@ -16,7 +16,7 @@
                       support.LoggingSilencer,
                       unittest.TestCase):
 
-    def _setup_package_data(self):
+    def test_package_data(self):
         sources = self.mkdtemp()
         f = open(os.path.join(sources, "__init__.py"), "w")
         f.write("# Pretend this is a package.")
@@ -52,18 +52,9 @@
         self.assertEqual(len(cmd.get_outputs()), 3)
         pkgdest = os.path.join(destination, "pkg")
         files = os.listdir(pkgdest)
-        return files
-
-    def test_package_data(self):
-        files = self._setup_package_data()
         self.assertTrue("__init__.py" in files)
-        self.assertTrue("README.txt" in files)
-
-    @unittest.skipIf(sys.flags.optimize >= 2,
-                     "pyc files are not written with -O2 and above")
-    def test_package_data_pyc(self):
-        files = self._setup_package_data()
         self.assertTrue("__init__.pyc" in files)
+        self.assertTrue("README.txt" in files)
 
     def test_empty_package_dir (self):
         # See SF 1668596/1720897.

Modified: python/branches/py3k/Lib/distutils/tests/test_build_scripts.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_scripts.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_scripts.py	Thu Jul 22 14:50:05 2010
@@ -5,7 +5,7 @@
 
 from distutils.command.build_scripts import build_scripts
 from distutils.core import Distribution
-import sysconfig
+from distutils import sysconfig
 
 from distutils.tests import support
 
@@ -91,12 +91,12 @@
         # --with-suffix=3`, python is compiled okay but the build scripts
         # failed when writing the name of the executable
         old = sysconfig.get_config_vars().get('VERSION')
-        sysconfig._CONFIG_VARS['VERSION'] = 4
+        sysconfig._config_vars['VERSION'] = 4
         try:
             cmd.run()
         finally:
             if old is not None:
-                sysconfig._CONFIG_VARS['VERSION'] = old
+                sysconfig._config_vars['VERSION'] = old
 
         built = os.listdir(target)
         for name in expected:

Deleted: python/branches/py3k/Lib/distutils/tests/test_ccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_ccompiler.py	Thu Jul 22 14:50:05 2010
+++ (empty file)
@@ -1,81 +0,0 @@
-"""Tests for distutils.ccompiler."""
-import os
-import unittest
-from test.support import captured_stdout
-
-from distutils.ccompiler import (gen_lib_options, CCompiler,
-                                 get_default_compiler, customize_compiler)
-from distutils import debug
-from distutils.tests import support
-
-class FakeCompiler(object):
-    def library_dir_option(self, dir):
-        return "-L" + dir
-
-    def runtime_library_dir_option(self, dir):
-        return ["-cool", "-R" + dir]
-
-    def find_library_file(self, dirs, lib, debug=0):
-        return 'found'
-
-    def library_option(self, lib):
-        return "-l" + lib
-
-class CCompilerTestCase(support.EnvironGuard, unittest.TestCase):
-
-    def test_gen_lib_options(self):
-        compiler = FakeCompiler()
-        libdirs = ['lib1', 'lib2']
-        runlibdirs = ['runlib1']
-        libs = [os.path.join('dir', 'name'), 'name2']
-
-        opts = gen_lib_options(compiler, libdirs, runlibdirs, libs)
-        wanted = ['-Llib1', '-Llib2', '-cool', '-Rrunlib1', 'found',
-                  '-lname2']
-        self.assertEquals(opts, wanted)
-
-    def test_debug_print(self):
-
-        class MyCCompiler(CCompiler):
-            executables = {}
-
-        compiler = MyCCompiler()
-        with captured_stdout() as stdout:
-            compiler.debug_print('xxx')
-        stdout.seek(0)
-        self.assertEquals(stdout.read(), '')
-
-        debug.DEBUG = True
-        try:
-            with captured_stdout() as stdout:
-                compiler.debug_print('xxx')
-            stdout.seek(0)
-            self.assertEquals(stdout.read(), 'xxx\n')
-        finally:
-            debug.DEBUG = False
-
-    def test_customize_compiler(self):
-
-        # not testing if default compiler is not unix
-        if get_default_compiler() != 'unix':
-            return
-
-        os.environ['AR'] = 'my_ar'
-        os.environ['ARFLAGS'] = '-arflags'
-
-        # make sure AR gets caught
-        class compiler:
-            compiler_type = 'unix'
-
-            def set_executables(self, **kw):
-                self.exes = kw
-
-        comp = compiler()
-        customize_compiler(comp)
-        self.assertEquals(comp.exes['archiver'], 'my_ar -arflags')
-
-def test_suite():
-    return unittest.makeSuite(CCompilerTestCase)
-
-if __name__ == "__main__":
-    unittest.main(defaultTest="test_suite")

Modified: python/branches/py3k/Lib/distutils/tests/test_cmd.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_cmd.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_cmd.py	Thu Jul 22 14:50:05 2010
@@ -1,7 +1,7 @@
 """Tests for distutils.cmd."""
 import unittest
 import os
-from test.support import captured_stdout, run_unittest
+from test.support import captured_stdout
 
 from distutils.cmd import Command
 from distutils.dist import Distribution
@@ -124,4 +124,4 @@
     return unittest.makeSuite(CommandTestCase)
 
 if __name__ == '__main__':
-    run_unittest(test_suite())
+    test_support.run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_cygwinccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_cygwinccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_cygwinccompiler.py	Thu Jul 22 14:50:05 2010
@@ -2,21 +2,29 @@
 import unittest
 import sys
 import os
+from io import BytesIO
 import subprocess
-import warnings
-import sysconfig
-
-from test.support import check_warnings, run_unittest
-from test.support import captured_stdout
 
 from distutils import cygwinccompiler
 from distutils.cygwinccompiler import (CygwinCCompiler, check_config_h,
                                        CONFIG_H_OK, CONFIG_H_NOTOK,
                                        CONFIG_H_UNCERTAIN, get_versions,
-                                       get_msvcr, RE_VERSION)
-from distutils.util import get_compiler_versions
+                                       get_msvcr)
 from distutils.tests import support
 
+class FakePopen(object):
+    test_class = None
+
+    def __init__(self, cmd, shell, stdout):
+        self.cmd = cmd.split()[0]
+        exes = self.test_class._exes
+        if self.cmd in exes:
+            # issue #6438 in Python 3.x, Popen returns bytes
+            self.stdout = BytesIO(exes[self.cmd])
+        else:
+            self.stdout = os.popen(cmd, 'r')
+
+
 class CygwinCCompilerTestCase(support.TempdirManager,
                               unittest.TestCase):
 
@@ -24,17 +32,32 @@
         super(CygwinCCompilerTestCase, self).setUp()
         self.version = sys.version
         self.python_h = os.path.join(self.mkdtemp(), 'python.h')
+        from distutils import sysconfig
         self.old_get_config_h_filename = sysconfig.get_config_h_filename
         sysconfig.get_config_h_filename = self._get_config_h_filename
+        self.old_find_executable = cygwinccompiler.find_executable
+        cygwinccompiler.find_executable = self._find_executable
+        self._exes = {}
+        self.old_popen = cygwinccompiler.Popen
+        FakePopen.test_class = self
+        cygwinccompiler.Popen = FakePopen
 
     def tearDown(self):
         sys.version = self.version
+        from distutils import sysconfig
         sysconfig.get_config_h_filename = self.old_get_config_h_filename
+        cygwinccompiler.find_executable = self.old_find_executable
+        cygwinccompiler.Popen = self.old_popen
         super(CygwinCCompilerTestCase, self).tearDown()
 
     def _get_config_h_filename(self):
         return self.python_h
 
+    def _find_executable(self, name):
+        if name in self._exes:
+            return name
+        return None
+
     def test_check_config_h(self):
 
         # check_config_h looks for "GCC" in sys.version first
@@ -58,6 +81,40 @@
         self.write_file(self.python_h, 'xxx __GNUC__ xxx')
         self.assertEquals(check_config_h()[0], CONFIG_H_OK)
 
+    def test_get_versions(self):
+
+        # get_versions calls distutils.spawn.find_executable on
+        # 'gcc', 'ld' and 'dllwrap'
+        self.assertEquals(get_versions(), (None, None, None))
+
+        # Let's fake we have 'gcc' and it returns '3.4.5'
+        self._exes['gcc'] = b'gcc (GCC) 3.4.5 (mingw special)\nFSF'
+        res = get_versions()
+        self.assertEquals(str(res[0]), '3.4.5')
+
+        # and let's see what happens when the version
+        # doesn't match the regular expression
+        # (\d+\.\d+(\.\d+)*)
+        self._exes['gcc'] = b'very strange output'
+        res = get_versions()
+        self.assertEquals(res[0], None)
+
+        # same thing for ld
+        self._exes['ld'] = b'GNU ld version 2.17.50 20060824'
+        res = get_versions()
+        self.assertEquals(str(res[1]), '2.17.50')
+        self._exes['ld'] = b'@(#)PROGRAM:ld  PROJECT:ld64-77'
+        res = get_versions()
+        self.assertEquals(res[1], None)
+
+        # and dllwrap
+        self._exes['dllwrap'] = b'GNU dllwrap 2.17.50 20060824\nFSF'
+        res = get_versions()
+        self.assertEquals(str(res[2]), '2.17.50')
+        self._exes['dllwrap'] = b'Cheese Wrap'
+        res = get_versions()
+        self.assertEquals(res[2], None)
+
     def test_get_msvcr(self):
 
         # none
@@ -90,23 +147,8 @@
                        '[MSC v.1999 32 bits (Intel)]')
         self.assertRaises(ValueError, get_msvcr)
 
-
-    def test_get_version_deprecated(self):
-        with check_warnings() as w:
-            warnings.simplefilter("always")
-            # make sure get_compiler_versions and get_versions
-            # returns the same thing
-            self.assertEquals(get_compiler_versions(), get_versions())
-            # make sure using get_version() generated a warning
-            self.assertEquals(len(w.warnings), 1)
-            # make sure any usage of RE_VERSION will also
-            # generate a warning, but till works
-            version = RE_VERSION.search('1.2').group(1)
-            self.assertEquals(version, '1.2')
-            self.assertEquals(len(w.warnings), 2)
-
 def test_suite():
     return unittest.makeSuite(CygwinCCompilerTestCase)
 
 if __name__ == '__main__':
-    run_unittest(test_suite())
+    test_support.run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_dist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_dist.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_dist.py	Thu Jul 22 14:50:05 2010
@@ -7,9 +7,8 @@
 import warnings
 import textwrap
 
-from distutils.dist import Distribution, fix_help_options, DistributionMetadata
+from distutils.dist import Distribution, fix_help_options
 from distutils.cmd import Command
-import distutils.dist
 
 from test.support import TESTFN, captured_stdout
 from distutils.tests import support
@@ -38,8 +37,7 @@
         return self._config_files
 
 
-class DistributionTestCase(support.TempdirManager,
-                           support.LoggingSilencer,
+class DistributionTestCase(support.LoggingSilencer,
                            support.EnvironGuard,
                            unittest.TestCase):
 
@@ -60,27 +58,6 @@
         d.parse_command_line()
         return d
 
-    def test_debug_mode(self):
-        with open(TESTFN, "w") as f:
-            f.write("[global]")
-            f.write("command_packages = foo.bar, splat")
-
-        files = [TESTFN]
-        sys.argv.append("build")
-
-        with captured_stdout() as stdout:
-            self.create_distribution(files)
-        stdout.seek(0)
-        self.assertEquals(stdout.read(), '')
-        distutils.dist.DEBUG = True
-        try:
-            with captured_stdout() as stdout:
-                self.create_distribution(files)
-            stdout.seek(0)
-            self.assertEquals(stdout.read(), '')
-        finally:
-            distutils.dist.DEBUG = False
-
     def test_command_packages_unspecified(self):
         sys.argv.append("build")
         d = self.create_distribution()
@@ -182,35 +159,6 @@
         kwargs = {'level': 'ok2'}
         self.assertRaises(ValueError, dist.announce, args, kwargs)
 
-    def test_find_config_files_disable(self):
-        # Ticket #1180: Allow user to disable their home config file.
-        temp_home = self.mkdtemp()
-        if os.name == 'posix':
-            user_filename = os.path.join(temp_home, ".pydistutils.cfg")
-        else:
-            user_filename = os.path.join(temp_home, "pydistutils.cfg")
-
-        with open(user_filename, 'w') as f:
-            f.write('[distutils]\n')
-
-        def _expander(path):
-            return temp_home
-
-        old_expander = os.path.expanduser
-        os.path.expanduser = _expander
-        try:
-            d = distutils.dist.Distribution()
-            all_files = d.find_config_files()
-
-            d = distutils.dist.Distribution(attrs={'script_args':
-                                            ['--no-user-cfg']})
-            files = d.find_config_files()
-        finally:
-            os.path.expanduser = old_expander
-
-        # make sure --no-user-cfg disables the user cfg file
-        self.assertEquals(len(all_files)-1, len(files))
-
 class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
                        unittest.TestCase):
 
@@ -364,38 +312,11 @@
                  "version": "1.0",
                  "long_description": long_desc}
 
-        dist = distutils.dist.Distribution(attrs)
+        dist = Distribution(attrs)
         meta = self.format_metadata(dist)
         meta = meta.replace('\n' + 8 * ' ', '\n')
         self.assertTrue(long_desc in meta)
 
-    def test_read_metadata(self):
-        attrs = {"name": "package",
-                 "version": "1.0",
-                 "long_description": "desc",
-                 "description": "xxx",
-                 "download_url": "http://example.com",
-                 "keywords": ['one', 'two'],
-                 "requires": ['foo']}
-
-        dist = Distribution(attrs)
-        metadata = dist.metadata
-
-        # write it then reloads it
-        PKG_INFO = io.StringIO()
-        metadata.write_pkg_file(PKG_INFO)
-        PKG_INFO.seek(0)
-        metadata.read_pkg_file(PKG_INFO)
-
-        self.assertEquals(metadata.name, "package")
-        self.assertEquals(metadata.version, "1.0")
-        self.assertEquals(metadata.description, "xxx")
-        self.assertEquals(metadata.download_url, 'http://example.com')
-        self.assertEquals(metadata.keywords, ['one', 'two'])
-        self.assertEquals(metadata.platforms, ['UNKNOWN'])
-        self.assertEquals(metadata.obsoletes, None)
-        self.assertEquals(metadata.requires, ['foo'])
-
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(DistributionTestCase))

Deleted: python/branches/py3k/Lib/distutils/tests/test_emxccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_emxccompiler.py	Thu Jul 22 14:50:05 2010
+++ (empty file)
@@ -1,33 +0,0 @@
-"""Tests for distutils.emxccompiler."""
-import unittest
-import sys
-import os
-import warnings
-
-from test.support import check_warnings, run_unittest
-from test.support import captured_stdout
-
-from distutils.emxccompiler import get_versions
-from distutils.util import get_compiler_versions
-from distutils.tests import support
-
-class EmxCCompilerTestCase(support.TempdirManager,
-                           unittest.TestCase):
-
-    def test_get_version_deprecated(self):
-        with check_warnings() as w:
-            warnings.simplefilter("always")
-            # make sure get_compiler_versions and get_versions
-            # returns the same gcc
-            gcc, ld, dllwrap = get_compiler_versions()
-            emx_gcc, emx_ld = get_versions()
-            self.assertEquals(gcc, emx_gcc)
-
-            # make sure using get_version() generated a warning
-            self.assertEquals(len(w.warnings), 1)
-
-def test_suite():
-    return unittest.makeSuite(EmxCCompilerTestCase)
-
-if __name__ == '__main__':
-    run_unittest(test_suite())

Modified: python/branches/py3k/Lib/distutils/tests/test_extension.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_extension.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_extension.py	Thu Jul 22 14:50:05 2010
@@ -1,16 +1,13 @@
 """Tests for distutils.extension."""
-import os
-import sys
 import unittest
+import os
 import warnings
 
 from test.support import check_warnings
 from distutils.extension import read_setup_file, Extension
-from distutils.tests.support import capture_warnings
 
 class ExtensionTestCase(unittest.TestCase):
 
-    @capture_warnings
     def test_read_setup_file(self):
         # trying to read a Setup file
         # (sample extracted from the PyGame project)
@@ -33,22 +30,16 @@
 
         self.assertEquals(names, wanted)
 
-    @unittest.skipIf(sys.flags.optimize >= 2,
-                     "Assertions are omitted with -O2 and above")
-    def test_extension_init_assertions(self):
-        # The first argument, which is the name, must be a string.
+    def test_extension_init(self):
+        # the first argument, which is the name, must be a string
         self.assertRaises(AssertionError, Extension, 1, [])
+        ext = Extension('name', [])
+        self.assertEquals(ext.name, 'name')
 
         # the second argument, which is the list of files, must
         # be a list of strings
         self.assertRaises(AssertionError, Extension, 'name', 'file')
         self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
-
-    def test_extension_init(self):
-        ext = Extension('name', [])
-        self.assertEquals(ext.name, 'name')
-
-
         ext = Extension('name', ['file1', 'file2'])
         self.assertEquals(ext.sources, ['file1', 'file2'])
 

Modified: python/branches/py3k/Lib/distutils/tests/test_file_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_file_util.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_file_util.py	Thu Jul 22 14:50:05 2010
@@ -3,7 +3,7 @@
 import os
 import shutil
 
-from distutils.file_util import move_file, write_file, copy_file
+from distutils.file_util import move_file
 from distutils import log
 from distutils.tests import support
 
@@ -55,21 +55,6 @@
         wanted = ['moving %s -> %s' % (self.source, self.target_dir)]
         self.assertEquals(self._logs, wanted)
 
-    def test_write_file(self):
-        lines = ['a', 'b', 'c']
-        dir = self.mkdtemp()
-        foo = os.path.join(dir, 'foo')
-        write_file(foo, lines)
-        content = [line.strip() for line in open(foo).readlines()]
-        self.assertEquals(content, lines)
-
-    def test_copy_file(self):
-        src_dir = self.mkdtemp()
-        foo = os.path.join(src_dir, 'foo')
-        write_file(foo, 'content')
-        dst_dir = self.mkdtemp()
-        copy_file(foo, dst_dir)
-        self.assertTrue(os.path.exists(os.path.join(dst_dir, 'foo')))
 
 def test_suite():
     return unittest.makeSuite(FileUtilTestCase)

Modified: python/branches/py3k/Lib/distutils/tests/test_filelist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_filelist.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_filelist.py	Thu Jul 22 14:50:05 2010
@@ -1,25 +1,10 @@
 """Tests for distutils.filelist."""
-from os.path import join
 import unittest
-from test.support import captured_stdout
 
 from distutils.filelist import glob_to_re, FileList
+from test.support import captured_stdout
 from distutils import debug
 
-MANIFEST_IN = """\
-include ok
-include xo
-exclude xo
-include foo.tmp
-global-include *.x
-global-include *.txt
-global-exclude *.tmp
-recursive-include f *.oo
-recursive-exclude global *.x
-graft dir
-prune dir3
-"""
-
 class FileListTestCase(unittest.TestCase):
 
     def test_glob_to_re(self):
@@ -34,34 +19,6 @@
         self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)')
         self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)')
 
-    def test_process_template_line(self):
-        # testing  all MANIFEST.in template patterns
-        file_list = FileList()
-
-        # simulated file list
-        file_list.allfiles = ['foo.tmp', 'ok', 'xo', 'four.txt',
-                              join('global', 'one.txt'),
-                              join('global', 'two.txt'),
-                              join('global', 'files.x'),
-                              join('global', 'here.tmp'),
-                              join('f', 'o', 'f.oo'),
-                              join('dir', 'graft-one'),
-                              join('dir', 'dir2', 'graft2'),
-                              join('dir3', 'ok'),
-                              join('dir3', 'sub', 'ok.txt')
-                              ]
-
-        for line in MANIFEST_IN.split('\n'):
-            if line.strip() == '':
-                continue
-            file_list.process_template_line(line)
-
-        wanted = ['ok', 'four.txt', join('global', 'one.txt'),
-                  join('global', 'two.txt'), join('f', 'o', 'f.oo'),
-                  join('dir', 'graft-one'), join('dir', 'dir2', 'graft2')]
-
-        self.assertEquals(file_list.files, wanted)
-
     def test_debug_print(self):
         file_list = FileList()
         with captured_stdout() as stdout:

Modified: python/branches/py3k/Lib/distutils/tests/test_install.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_install.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_install.py	Thu Jul 22 14:50:05 2010
@@ -5,14 +5,12 @@
 import sys
 import unittest
 import site
-import sysconfig
-from sysconfig import (get_scheme_names, _CONFIG_VARS, _INSTALL_SCHEMES,
-                       get_config_var, get_path)
 
 from test.support import captured_stdout
 
 from distutils.command.install import install
 from distutils.command import install as install_module
+from distutils.command.install import INSTALL_SCHEMES
 from distutils.core import Distribution
 from distutils.errors import DistutilsOptionError
 
@@ -38,23 +36,9 @@
             build_lib=os.path.join(builddir, "lib"),
             )
 
-
-
-        posix_prefix = _INSTALL_SCHEMES['posix_prefix']
-        old_posix_prefix = posix_prefix['platinclude']
-        posix_prefix['platinclude'] = \
-                '{platbase}/include/python{py_version_short}'
-
-        posix_home = _INSTALL_SCHEMES['posix_home']
-        old_posix_home = posix_home['platinclude']
-        posix_home['platinclude'] = '{base}/include/python'
-        try:
-            cmd = install(dist)
-            cmd.home = destination
-            cmd.ensure_finalized()
-        finally:
-            posix_home['platinclude'] = old_posix_home
-            posix_prefix['platinclude'] = old_posix_prefix
+        cmd = install(dist)
+        cmd.home = destination
+        cmd.ensure_finalized()
 
         self.assertEqual(cmd.install_base, destination)
         self.assertEqual(cmd.install_platbase, destination)
@@ -79,19 +63,18 @@
             return
 
         # preparing the environement for the test
-        self.old_user_base = get_config_var('userbase')
-        self.old_user_site = get_path('purelib', '%s_user' % os.name)
+        self.old_user_base = site.USER_BASE
+        self.old_user_site = site.USER_SITE
         self.tmpdir = self.mkdtemp()
         self.user_base = os.path.join(self.tmpdir, 'B')
         self.user_site = os.path.join(self.tmpdir, 'S')
-        _CONFIG_VARS['userbase'] = self.user_base
-        scheme = _INSTALL_SCHEMES['%s_user' % os.name]
-        scheme['purelib'] = self.user_site
+        site.USER_BASE = self.user_base
+        site.USER_SITE = self.user_site
+        install_module.USER_BASE = self.user_base
+        install_module.USER_SITE = self.user_site
 
         def _expanduser(path):
-            if path[0] == '~':
-                path = os.path.normpath(self.tmpdir) + path[1:]
-            return path
+            return self.tmpdir
         self.old_expand = os.path.expanduser
         os.path.expanduser = _expanduser
 
@@ -99,17 +82,19 @@
             # this is the actual test
             self._test_user_site()
         finally:
-            _CONFIG_VARS['userbase'] = self.old_user_base
-            scheme['purelib'] = self.old_user_site
+            site.USER_BASE = self.old_user_base
+            site.USER_SITE = self.old_user_site
+            install_module.USER_BASE = self.old_user_base
+            install_module.USER_SITE = self.old_user_site
             os.path.expanduser = self.old_expand
 
     def _test_user_site(self):
-        schemes = get_scheme_names()
-        for key in ('nt_user', 'posix_user', 'os2_home'):
-            self.assertTrue(key in schemes)
+        for key in ('nt_user', 'unix_user', 'os2_home'):
+            self.assertTrue(key in INSTALL_SCHEMES)
 
         dist = Distribution({'name': 'xx'})
         cmd = install(dist)
+
         # making sure the user option is there
         options = [name for name, short, lable in
                    cmd.user_options]
@@ -200,7 +185,7 @@
         with open(cmd.record) as f:
             self.assertEquals(len(f.readlines()), 1)
 
-    def _test_debug_mode(self):
+    def test_debug_mode(self):
         # this covers the code called when DEBUG is set
         old_logs_len = len(self.logs)
         install_module.DEBUG = True

Modified: python/branches/py3k/Lib/distutils/tests/test_install_lib.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_install_lib.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_install_lib.py	Thu Jul 22 14:50:05 2010
@@ -1,6 +1,6 @@
 """Tests for distutils.command.install_data."""
-import os
 import sys
+import os
 import unittest
 
 from distutils.command.install_lib import install_lib
@@ -31,7 +31,9 @@
         cmd.finalize_options()
         self.assertEquals(cmd.optimize, 2)
 
-    def _setup_byte_compile(self):
+    @unittest.skipUnless(not sys.dont_write_bytecode,
+                         'byte-compile not supported')
+    def test_byte_compile(self):
         pkg_dir, dist = self.create_dist()
         cmd = install_lib(dist)
         cmd.compile = cmd.optimize = 1
@@ -39,15 +41,8 @@
         f = os.path.join(pkg_dir, 'foo.py')
         self.write_file(f, '# python file')
         cmd.byte_compile([f])
-        return pkg_dir
-
-    @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile not enabled')
-    def test_byte_compile(self):
-        pkg_dir = self._setup_byte_compile()
-        if sys.flags.optimize < 1:
-            self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
-        else:
-            self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
+        self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
+        self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
 
     def test_get_outputs(self):
         pkg_dir, dist = self.create_dist()

Modified: python/branches/py3k/Lib/distutils/tests/test_register.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_register.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_register.py	Thu Jul 22 14:50:05 2010
@@ -202,10 +202,10 @@
         self.assertRaises(DistutilsSetupError, cmd.run)
 
         # we don't test the reSt feature if docutils
-        # is not installed or we our on py3k
+        # is not installed
         try:
             import docutils
-        except Exception:
+        except ImportError:
             return
 
         # metadata are OK but long_description is broken

Modified: python/branches/py3k/Lib/distutils/tests/test_sdist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_sdist.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_sdist.py	Thu Jul 22 14:50:05 2010
@@ -3,22 +3,6 @@
 import unittest
 import shutil
 import zipfile
-import tarfile
-
-# zlib is not used here, but if it's not available
-# the tests that use zipfile may fail
-try:
-    import zlib
-except ImportError:
-    zlib = None
-
-try:
-    import grp
-    import pwd
-    UID_GID_SUPPORT = True
-except ImportError:
-    UID_GID_SUPPORT = False
-
 from os.path import join
 import sys
 import tempfile
@@ -95,7 +79,6 @@
         cmd.warn = _warn
         return dist, cmd
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_prune_file_list(self):
         # this test creates a package with some vcs dirs in it
         # and launch sdist to make sure they get pruned
@@ -137,7 +120,6 @@
         # making sure everything has been pruned correctly
         self.assertEquals(len(content), 4)
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_make_distribution(self):
 
         # check if tar and gzip are installed
@@ -174,7 +156,6 @@
         self.assertEquals(result,
                 ['fake-1.0.tar', 'fake-1.0.tar.gz'])
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_add_defaults(self):
 
         # http://bugs.python.org/issue2279
@@ -236,7 +217,6 @@
         manifest = open(join(self.tmp_dir, 'MANIFEST')).read()
         self.assertEquals(manifest, MANIFEST % {'sep': os.sep})
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_metadata_check_option(self):
         # testing the `medata-check` option
         dist, cmd = self.get_cmd(metadata={})
@@ -296,57 +276,7 @@
         cmd.formats = 'supazipa'
         self.assertRaises(DistutilsOptionError, cmd.finalize_options)
 
-    @unittest.skipUnless(zlib, "requires zlib")
-    @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
-    def test_make_distribution_owner_group(self):
-
-        # check if tar and gzip are installed
-        if (find_executable('tar') is None or
-            find_executable('gzip') is None):
-            return
-
-        # now building a sdist
-        dist, cmd = self.get_cmd()
-
-        # creating a gztar and specifying the owner+group
-        cmd.formats = ['gztar']
-        cmd.owner = pwd.getpwuid(0)[0]
-        cmd.group = grp.getgrgid(0)[0]
-        cmd.ensure_finalized()
-        cmd.run()
-
-        # making sure we have the good rights
-        archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
-        archive = tarfile.open(archive_name)
-        try:
-            for member in archive.getmembers():
-                self.assertEquals(member.uid, 0)
-                self.assertEquals(member.gid, 0)
-        finally:
-            archive.close()
-
-        # building a sdist again
-        dist, cmd = self.get_cmd()
-
-        # creating a gztar
-        cmd.formats = ['gztar']
-        cmd.ensure_finalized()
-        cmd.run()
-
-        # making sure we have the good rights
-        archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
-        archive = tarfile.open(archive_name)
-
-        # note that we are not testing the group ownership here
-        # because, depending on the platforms and the container
-        # rights (see #7408)
-        try:
-            for member in archive.getmembers():
-                self.assertEquals(member.uid, os.getuid())
-        finally:
-            archive.close()
 
-    @unittest.skipUnless(zlib, "requires zlib")
     def test_get_file_list(self):
         # make sure MANIFEST is recalculated
         dist, cmd = self.get_cmd()

Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py	Thu Jul 22 14:50:05 2010
@@ -2,9 +2,9 @@
 import os
 import test
 import unittest
-import shutil
 
 from distutils import sysconfig
+from distutils.ccompiler import get_default_compiler
 from distutils.tests import support
 from test.support import TESTFN, run_unittest
 
@@ -26,7 +26,10 @@
         elif os.path.isdir(TESTFN):
             shutil.rmtree(TESTFN)
 
-    @support.capture_warnings
+    def test_get_config_h_filename(self):
+        config_h = sysconfig.get_config_h_filename()
+        self.assertTrue(os.path.isfile(config_h), config_h)
+
     def test_get_python_lib(self):
         lib_dir = sysconfig.get_python_lib()
         # XXX doesn't work on Linux when Python was never installed before
@@ -34,11 +37,7 @@
         # test for pythonxx.lib?
         self.assertNotEqual(sysconfig.get_python_lib(),
                             sysconfig.get_python_lib(prefix=TESTFN))
-        _sysconfig = __import__('sysconfig')
-        res = sysconfig.get_python_lib(True, True)
-        self.assertEquals(_sysconfig.get_path('platstdlib'), res)
 
-    @support.capture_warnings
     def test_get_python_inc(self):
         inc_dir = sysconfig.get_python_inc()
         # This is not much of a test.  We make sure Python.h exists
@@ -48,7 +47,31 @@
         python_h = os.path.join(inc_dir, "Python.h")
         self.assertTrue(os.path.isfile(python_h), python_h)
 
-    @support.capture_warnings
+    def test_get_config_vars(self):
+        cvars = sysconfig.get_config_vars()
+        self.assertTrue(isinstance(cvars, dict))
+        self.assertTrue(cvars)
+
+    def test_customize_compiler(self):
+
+        # not testing if default compiler is not unix
+        if get_default_compiler() != 'unix':
+            return
+
+        os.environ['AR'] = 'my_ar'
+        os.environ['ARFLAGS'] = '-arflags'
+
+        # make sure AR gets caught
+        class compiler:
+            compiler_type = 'unix'
+
+            def set_executables(self, **kw):
+                self.exes = kw
+
+        comp = compiler()
+        sysconfig.customize_compiler(comp)
+        self.assertEquals(comp.exes['archiver'], 'my_ar -arflags')
+
     def test_parse_makefile_base(self):
         self.makefile = TESTFN
         fd = open(self.makefile, 'w')

Modified: python/branches/py3k/Lib/distutils/tests/test_unixccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_unixccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_unixccompiler.py	Thu Jul 22 14:50:05 2010
@@ -1,8 +1,8 @@
 """Tests for distutils.unixccompiler."""
 import sys
 import unittest
-import sysconfig
 
+from distutils import sysconfig
 from distutils.unixccompiler import UnixCCompiler
 
 class UnixCCompilerTestCase(unittest.TestCase):
@@ -114,14 +114,6 @@
         sysconfig.get_config_var = gcv
         self.assertEqual(self.cc.rpath_foo(), '-R/foo')
 
-        # AIX C/C++ linker
-        sys.platform = 'aix'
-        def gcv(v):
-            return 'xxx'
-        sysconfig.get_config_var = gcv
-        self.assertEqual(self.cc.rpath_foo(), '-blibpath:/foo')
-
-
 def test_suite():
     return unittest.makeSuite(UnixCCompilerTestCase)
 

Modified: python/branches/py3k/Lib/distutils/tests/test_upload.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_upload.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_upload.py	Thu Jul 22 14:50:05 2010
@@ -2,8 +2,8 @@
 import sys
 import os
 import unittest
+import http.client as httpclient
 
-from distutils.command import upload as upload_mod
 from distutils.command.upload import upload
 from distutils.core import Distribution
 
@@ -38,37 +38,48 @@
 [server1]
 username:me
 """
+class Response(object):
+    def __init__(self, status=200, reason='OK'):
+        self.status = status
+        self.reason = reason
 
-class FakeOpen(object):
+class FakeConnection(object):
 
-    def __init__(self, url):
-        self.url = url
-        if not isinstance(url, str):
-            self.req = url
-        else:
-            self.req = None
-        self.msg = 'OK'
+    def __init__(self):
+        self.requests = []
+        self.headers = []
+        self.body = ''
 
-    def getcode(self):
-        return 200
+    def __call__(self, netloc):
+        return self
 
+    def connect(self):
+        pass
+    endheaders = connect
+
+    def putrequest(self, method, url):
+        self.requests.append((method, url))
+
+    def putheader(self, name, value):
+        self.headers.append((name, value))
+
+    def send(self, body):
+        self.body = body
+
+    def getresponse(self):
+        return Response()
 
 class uploadTestCase(PyPIRCCommandTestCase):
 
     def setUp(self):
         super(uploadTestCase, self).setUp()
-        self.old_open = upload_mod.urlopen
-        upload_mod.urlopen = self._urlopen
-        self.last_open = None
+        self.old_class = httpclient.HTTPConnection
+        self.conn = httpclient.HTTPConnection = FakeConnection()
 
     def tearDown(self):
-        upload_mod.urlopen = self.old_open
+        httpclient.HTTPConnection = self.old_class
         super(uploadTestCase, self).tearDown()
 
-    def _urlopen(self, url):
-        self.last_open = FakeOpen(url)
-        return self.last_open
-
     def test_finalize_options(self):
 
         # new format
@@ -113,15 +124,13 @@
         cmd.run()
 
         # what did we send ?
-        headers = dict(self.last_open.req.headers)
+        headers = dict(self.conn.headers)
         self.assertEquals(headers['Content-length'], '2087')
         self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
-        self.assertEquals(self.last_open.req.get_method(), 'POST')
-        self.assertEquals(self.last_open.req.get_full_url(),
-                          'http://pypi.python.org/pypi')
-        self.assertTrue(b'xxx' in self.last_open.req.data)
-        auth = self.last_open.req.headers['Authorization']
-        self.assertFalse('\n' in auth)
+        self.assertFalse('\n' in headers['Authorization'])
+
+        self.assertEquals(self.conn.requests, [('POST', '/pypi')])
+        self.assert_((b'xxx') in self.conn.body)
 
 def test_suite():
     return unittest.makeSuite(uploadTestCase)

Modified: python/branches/py3k/Lib/distutils/tests/test_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_util.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_util.py	Thu Jul 22 14:50:05 2010
@@ -3,33 +3,15 @@
 import sys
 import unittest
 from copy import copy
-from io import BytesIO
-import subprocess
 
-from sysconfig import get_config_vars, get_platform
 from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
-from distutils.util import (convert_path, change_root,
+from distutils.util import (get_platform, convert_path, change_root,
                             check_environ, split_quoted, strtobool,
-                            rfc822_escape, get_compiler_versions,
-                            _find_exe_version, _MAC_OS_X_LD_VERSION,
-                            byte_compile)
-from distutils import util
+                            rfc822_escape, byte_compile)
+from distutils import util # used to patch _environ_checked
+from distutils.sysconfig import get_config_vars
+from distutils import sysconfig
 from distutils.tests import support
-from distutils.version import LooseVersion
-
-class FakePopen(object):
-    test_class = None
-    def __init__(self, cmd, shell, stdout, stderr):
-        self.cmd = cmd.split()[0]
-        exes = self.test_class._exes
-        if self.cmd not in exes:
-            # we don't want to call the system, returning an empty
-            # output so it doesn't match
-            self.stdout = BytesIO()
-            self.stderr = BytesIO()
-        else:
-            self.stdout = BytesIO(exes[self.cmd])
-            self.stderr = BytesIO()
 
 class UtilTestCase(support.EnvironGuard, unittest.TestCase):
 
@@ -43,7 +25,7 @@
         self.join = os.path.join
         self.isabs = os.path.isabs
         self.splitdrive = os.path.splitdrive
-        #self._config_vars = copy(sysconfig._config_vars)
+        self._config_vars = copy(sysconfig._config_vars)
 
         # patching os.uname
         if hasattr(os, 'uname'):
@@ -52,17 +34,8 @@
         else:
             self.uname = None
             self._uname = None
-        os.uname = self._get_uname
 
-        # patching POpen
-        self.old_find_executable = util.find_executable
-        util.find_executable = self._find_executable
-        self._exes = {}
-        self.old_popen = subprocess.Popen
-        self.old_stdout  = sys.stdout
-        self.old_stderr = sys.stderr
-        FakePopen.test_class = self
-        subprocess.Popen = FakePopen
+        os.uname = self._get_uname
 
     def tearDown(self):
         # getting back the environment
@@ -77,11 +50,7 @@
             os.uname = self.uname
         else:
             del os.uname
-        #sysconfig._config_vars = copy(self._config_vars)
-        util.find_executable = self.old_find_executable
-        subprocess.Popen = self.old_popen
-        sys.old_stdout  = self.old_stdout
-        sys.old_stderr = self.old_stderr
+        sysconfig._config_vars = copy(self._config_vars)
         super(UtilTestCase, self).tearDown()
 
     def _set_uname(self, uname):
@@ -91,11 +60,103 @@
         return self._uname
 
     def test_get_platform(self):
-        platform = util.get_platform()
-        self.assertEquals(platform, get_platform())
-        util.set_platform('MyOwnPlatform')
-        self.assertEquals('MyOwnPlatform', util.get_platform())
-        util.set_platform(platform)
+
+        # windows XP, 32bits
+        os.name = 'nt'
+        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+                       '[MSC v.1310 32 bit (Intel)]')
+        sys.platform = 'win32'
+        self.assertEquals(get_platform(), 'win32')
+
+        # windows XP, amd64
+        os.name = 'nt'
+        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+                       '[MSC v.1310 32 bit (Amd64)]')
+        sys.platform = 'win32'
+        self.assertEquals(get_platform(), 'win-amd64')
+
+        # windows XP, itanium
+        os.name = 'nt'
+        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+                       '[MSC v.1310 32 bit (Itanium)]')
+        sys.platform = 'win32'
+        self.assertEquals(get_platform(), 'win-ia64')
+
+        # macbook
+        os.name = 'posix'
+        sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
+                       '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
+        sys.platform = 'darwin'
+        self._set_uname(('Darwin', 'macziade', '8.11.1',
+                   ('Darwin Kernel Version 8.11.1: '
+                    'Wed Oct 10 18:23:28 PDT 2007; '
+                    'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
+        os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
+
+        get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
+                                       '-fwrapv -O3 -Wall -Wstrict-prototypes')
+
+        cursize = sys.maxsize
+        sys.maxsize = (2 ** 31)-1
+        try:
+            self.assertEquals(get_platform(), 'macosx-10.3-i386')
+        finally:
+            sys.maxsize = cursize
+
+        # macbook with fat binaries (fat, universal or fat64)
+        os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
+        get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot '
+                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
+                                       '-fno-strict-aliasing -fno-common '
+                                       '-dynamic -DNDEBUG -g -O3')
+
+        self.assertEquals(get_platform(), 'macosx-10.4-fat')
+
+        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot '
+                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
+                                       '-fno-strict-aliasing -fno-common '
+                                       '-dynamic -DNDEBUG -g -O3')
+
+        self.assertEquals(get_platform(), 'macosx-10.4-intel')
+
+        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot '
+                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
+                                       '-fno-strict-aliasing -fno-common '
+                                       '-dynamic -DNDEBUG -g -O3')
+        self.assertEquals(get_platform(), 'macosx-10.4-fat3')
+
+        get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
+                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
+                                       '-fno-strict-aliasing -fno-common '
+                                       '-dynamic -DNDEBUG -g -O3')
+        self.assertEquals(get_platform(), 'macosx-10.4-universal')
+
+        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot '
+                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
+                                       '-fno-strict-aliasing -fno-common '
+                                       '-dynamic -DNDEBUG -g -O3')
+
+        self.assertEquals(get_platform(), 'macosx-10.4-fat64')
+
+        for arch in ('ppc', 'i386', 'x86_64', 'ppc64'):
+            get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
+                                           '/Developer/SDKs/MacOSX10.4u.sdk  '
+                                           '-fno-strict-aliasing -fno-common '
+                                           '-dynamic -DNDEBUG -g -O3'%(arch,))
+
+            self.assertEquals(get_platform(), 'macosx-10.4-%s'%(arch,))
+
+        # linux debian sarge
+        os.name = 'posix'
+        sys.version = ('2.3.5 (#1, Jul  4 2007, 17:28:59) '
+                       '\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]')
+        sys.platform = 'linux2'
+        self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7',
+                    '#1 Mon Apr 30 17:25:38 CEST 2007', 'i686'))
+
+        self.assertEquals(get_platform(), 'linux-i686')
+
+        # XXX more platforms to tests here
 
     def test_convert_path(self):
         # linux/mac
@@ -199,70 +260,6 @@
                   'header%(8s)s') % {'8s': '\n'+8*' '}
         self.assertEquals(res, wanted)
 
-    def test_find_exe_version(self):
-        # the ld version scheme under MAC OS is:
-        #   ^@(#)PROGRAM:ld  PROJECT:ld64-VERSION
-        #
-        # where VERSION is a 2-digit number for major
-        # revisions. For instance under Leopard, it's
-        # currently 77
-        #
-        # Dots are used when branching is done.
-        #
-        # The SnowLeopard ld64 is currently 95.2.12
-
-        for output, version in ((b'@(#)PROGRAM:ld  PROJECT:ld64-77', '77'),
-                                (b'@(#)PROGRAM:ld  PROJECT:ld64-95.2.12',
-                                 '95.2.12')):
-            result = _MAC_OS_X_LD_VERSION.search(output)
-            self.assertEquals(result.group(1).decode(), version)
-
-    def _find_executable(self, name):
-        if name in self._exes:
-            return name
-        return None
-
-    def test_get_compiler_versions(self):
-        # get_versions calls distutils.spawn.find_executable on
-        # 'gcc', 'ld' and 'dllwrap'
-        self.assertEquals(get_compiler_versions(), (None, None, None))
-
-        # Let's fake we have 'gcc' and it returns '3.4.5'
-        self._exes['gcc'] = b'gcc (GCC) 3.4.5 (mingw special)\nFSF'
-        res = get_compiler_versions()
-        self.assertEquals(str(res[0]), '3.4.5')
-
-        # and let's see what happens when the version
-        # doesn't match the regular expression
-        # (\d+\.\d+(\.\d+)*)
-        self._exes['gcc'] = b'very strange output'
-        res = get_compiler_versions()
-        self.assertEquals(res[0], None)
-
-        # same thing for ld
-        if sys.platform != 'darwin':
-            self._exes['ld'] = b'GNU ld version 2.17.50 20060824'
-            res = get_compiler_versions()
-            self.assertEquals(str(res[1]), '2.17.50')
-            self._exes['ld'] = b'@(#)PROGRAM:ld  PROJECT:ld64-77'
-            res = get_compiler_versions()
-            self.assertEquals(res[1], None)
-        else:
-            self._exes['ld'] = b'GNU ld version 2.17.50 20060824'
-            res = get_compiler_versions()
-            self.assertEquals(res[1], None)
-            self._exes['ld'] = b'@(#)PROGRAM:ld  PROJECT:ld64-77'
-            res = get_compiler_versions()
-            self.assertEquals(str(res[1]), '77')
-
-        # and dllwrap
-        self._exes['dllwrap'] = b'GNU dllwrap 2.17.50 20060824\nFSF'
-        res = get_compiler_versions()
-        self.assertEquals(str(res[2]), '2.17.50')
-        self._exes['dllwrap'] = b'Cheese Wrap'
-        res = get_compiler_versions()
-        self.assertEquals(res[2], None)
-
     def test_dont_write_bytecode(self):
         # makes sure byte_compile raise a DistutilsError
         # if sys.dont_write_bytecode is True

Modified: python/branches/py3k/Lib/distutils/text_file.py
==============================================================================
--- python/branches/py3k/Lib/distutils/text_file.py	(original)
+++ python/branches/py3k/Lib/distutils/text_file.py	Thu Jul 22 14:50:05 2010
@@ -6,8 +6,8 @@
 
 __revision__ = "$Id$"
 
-import sys
-import io
+import sys, os, io
+
 
 class TextFile:
     """Provides a file-like object that takes care of all the things you

Modified: python/branches/py3k/Lib/distutils/unixccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/unixccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/unixccompiler.py	Thu Jul 22 14:50:05 2010
@@ -17,6 +17,7 @@
 
 import os, sys, re
 
+from distutils import sysconfig
 from distutils.dep_util import newer
 from distutils.ccompiler import \
      CCompiler, gen_preprocess_options, gen_lib_options
@@ -24,7 +25,6 @@
      DistutilsExecError, CompileError, LibError, LinkError
 from distutils import log
 
-
 # XXX Things not currently handled:
 #   * optimization/debug/warning flags; we just use whatever's in Python's
 #     Makefile and live with it.  Is this adequate?  If not, we might
@@ -74,7 +74,7 @@
 
     if 'ARCHFLAGS' in os.environ and not stripArch:
         # User specified different -arch flags in the environ,
-        # see also the sysconfig
+        # see also distutils.sysconfig
         compiler_so = compiler_so + os.environ['ARCHFLAGS'].split()
 
     if stripSysroot:
@@ -281,9 +281,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.
-        _sysconfig = __import__('sysconfig')
-
-        compiler = os.path.basename(_sysconfig.get_config_var("CC"))
+        compiler = os.path.basename(sysconfig.get_config_var("CC"))
         if sys.platform[:6] == "darwin":
             # MacOSX's linker doesn't understand the -R flag at all
             return "-L" + dir
@@ -293,24 +291,23 @@
             return ["+s", "-L" + dir]
         elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5":
             return ["-rpath", dir]
-        elif self._is_gcc(compiler):
-            # gcc on non-GNU systems does not need -Wl, but can
-            # use it anyway.  Since distutils has always passed in
-            # -Wl whenever gcc was used in the past it is probably
-            # safest to keep doing so.
-            if _sysconfig.get_config_var("GNULD") == "yes":
-                # GNU ld needs an extra option to get a RUNPATH
-                # instead of just an RPATH.
-                return "-Wl,--enable-new-dtags,-R" + dir
-            else:
-                return "-Wl,-R" + dir
-        elif sys.platform[:3] == "aix":
-            return "-blibpath:" + dir
         else:
-            # No idea how --enable-new-dtags would be passed on to
-            # ld if this system was using GNU ld.  Don't know if a
-            # system like this even exists.
-            return "-R" + dir
+            if self._is_gcc(compiler):
+                # gcc on non-GNU systems does not need -Wl, but can
+                # use it anyway.  Since distutils has always passed in
+                # -Wl whenever gcc was used in the past it is probably
+                # safest to keep doing so.
+                if sysconfig.get_config_var("GNULD") == "yes":
+                    # GNU ld needs an extra option to get a RUNPATH
+                    # instead of just an RPATH.
+                    return "-Wl,--enable-new-dtags,-R" + dir
+                else:
+                    return "-Wl,-R" + dir
+            else:
+                # No idea how --enable-new-dtags would be passed on to
+                # ld if this system was using GNU ld.  Don't know if a
+                # system like this even exists.
+                return "-R" + dir
 
     def library_option(self, lib):
         return "-l" + lib
@@ -324,8 +321,7 @@
             # On OSX users can specify an alternate SDK using
             # '-isysroot', calculate the SDK root if it is specified
             # (and use it further on)
-            _sysconfig = __import__('sysconfig')
-            cflags = _sysconfig.get_config_var('CFLAGS')
+            cflags = sysconfig.get_config_var('CFLAGS')
             m = re.search(r'-isysroot\s+(\S+)', cflags)
             if m is None:
                 sysroot = '/'

Modified: python/branches/py3k/Lib/distutils/util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/util.py	(original)
+++ python/branches/py3k/Lib/distutils/util.py	Thu Jul 22 14:50:05 2010
@@ -7,40 +7,182 @@
 __revision__ = "$Id$"
 
 import sys, os, string, re
-
 from distutils.errors import DistutilsPlatformError
 from distutils.dep_util import newer
-from distutils.spawn import spawn, find_executable
+from distutils.spawn import spawn
 from distutils import log
-from distutils.version import LooseVersion
 from distutils.errors import DistutilsByteCompileError
 
-_sysconfig = __import__('sysconfig')
-_PLATFORM = None
+def get_platform ():
+    """Return a string that identifies the current platform.  This is used
+    mainly to distinguish platform-specific build directories and
+    platform-specific built distributions.  Typically includes the OS name
+    and version and the architecture (as supplied by 'os.uname()'),
+    although the exact information included depends on the OS; eg. for IRIX
+    the architecture isn't particularly important (IRIX only runs on SGI
+    hardware), but for Linux the kernel version isn't particularly
+    important.
+
+    Examples of returned values:
+       linux-i586
+       linux-alpha (?)
+       solaris-2.6-sun4u
+       irix-5.3
+       irix64-6.2
+
+    Windows will return one of:
+       win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
+       win-ia64 (64bit Windows on Itanium)
+       win32 (all others - specifically, sys.platform is returned)
+
+    For other non-POSIX platforms, currently just returns 'sys.platform'.
+    """
+    if os.name == 'nt':
+        # sniff sys.version for architecture.
+        prefix = " bit ("
+        i = sys.version.find(prefix)
+        if i == -1:
+            return sys.platform
+        j = sys.version.find(")", i)
+        look = sys.version[i+len(prefix):j].lower()
+        if look == 'amd64':
+            return 'win-amd64'
+        if look == 'itanium':
+            return 'win-ia64'
+        return sys.platform
+
+    if os.name != "posix" or not hasattr(os, 'uname'):
+        # XXX what about the architecture? NT is Intel or Alpha,
+        # Mac OS is M68k or PPC, etc.
+        return sys.platform
+
+    # Try to distinguish various flavours of Unix
+
+    (osname, host, release, version, machine) = os.uname()
+
+    # Convert the OS name to lowercase, remove '/' characters
+    # (to accommodate BSD/OS), and translate spaces (for "Power Macintosh")
+    osname = osname.lower().replace('/', '')
+    machine = machine.replace(' ', '_')
+    machine = machine.replace('/', '-')
+
+    if osname[:5] == "linux":
+        # At least on Linux/Intel, 'machine' is the processor --
+        # i386, etc.
+        # XXX what about Alpha, SPARC, etc?
+        return  "%s-%s" % (osname, machine)
+    elif osname[:5] == "sunos":
+        if release[0] >= "5":           # SunOS 5 == Solaris 2
+            osname = "solaris"
+            release = "%d.%s" % (int(release[0]) - 3, release[2:])
+        # fall through to standard osname-release-machine representation
+    elif osname[:4] == "irix":              # could be "irix64"!
+        return "%s-%s" % (osname, release)
+    elif osname[:3] == "aix":
+        return "%s-%s.%s" % (osname, version, release)
+    elif osname[:6] == "cygwin":
+        osname = "cygwin"
+        rel_re = re.compile (r'[\d.]+', re.ASCII)
+        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 1:
+            # Always calculate the release of the running machine,
+            # needed to determine if we can build fat binaries or not.
+
+            macrelease = 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:
+                    macrelease = '.'.join(m.group(1).split('.')[:2])
+                # else: fall back to the default behaviour
+
+        if not macver:
+            macver = macrelease
+
+        if macver:
+            from distutils.sysconfig import get_config_vars
+            release = macver
+            osname = "macosx"
+
+            if (macrelease + '.') >= '10.4.' and \
+                    '-arch' in get_config_vars().get('CFLAGS', '').strip():
+                # The universal build will build fat binaries, but not on
+                # systems before 10.4
+                #
+                # Try to detect 4-way universal builds, those have machine-type
+                # 'universal' instead of 'fat'.
+
+                machine = 'fat'
+                cflags = get_config_vars().get('CFLAGS')
+
+                archs = re.findall('-arch\s+(\S+)', cflags)
+                archs = tuple(sorted(set(archs)))
+
+                if len(archs) == 1:
+                    machine = archs[0]
+                elif archs == ('i386', 'ppc'):
+                    machine = 'fat'
+                elif archs == ('i386', 'x86_64'):
+                    machine = 'intel'
+                elif archs == ('i386', 'ppc', 'x86_64'):
+                    machine = 'fat3'
+                elif archs == ('ppc64', 'x86_64'):
+                    machine = 'fat64'
+                elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'):
+                    machine = 'universal'
+                else:
+                    raise ValueError(
+                       "Don't know machine value for archs=%r"%(archs,))
 
-def get_platform():
-    """Return a string that identifies the current platform.
+            elif machine == 'i386':
+                # On OSX the machine type returned by uname is always the
+                # 32-bit variant, even if the executable architecture is
+                # the 64-bit variant
+                if sys.maxsize >= 2**32:
+                    machine = 'x86_64'
 
-    By default, will return the value returned by sysconfig.get_platform(),
-    but it can be changed by calling set_platform().
-    """
-    global _PLATFORM
-    if _PLATFORM is None:
-        _PLATFORM = _sysconfig.get_platform()
-    return _PLATFORM
+            elif machine in ('PowerPC', 'Power_Macintosh'):
+                # Pick a sane name for the PPC architecture.
+                machine = 'ppc'
 
-def set_platform(identifier):
-    """Sets the platform string identifier returned by get_platform().
+                # See 'i386' case
+                if sys.maxsize >= 2**32:
+                    machine = 'ppc64'
 
-    Note that this change doesn't impact the value returned by
-    sysconfig.get_platform() and is local to Distutils
-    """
-    global _PLATFORM
-    _PLATFORM = identifier
+    return "%s-%s-%s" % (osname, release, machine)
+
+# get_platform ()
 
-def convert_path(pathname):
-    """Return 'pathname' as a name that will work on the native filesystem.
 
+def convert_path (pathname):
+    """Return 'pathname' as a name that will work on the native filesystem,
     i.e. split it on '/' and put it back together again using the current
     directory separator.  Needed because filenames in the setup script are
     always supplied in Unix style, and have to be converted to the local
@@ -64,12 +206,12 @@
         return os.curdir
     return os.path.join(*paths)
 
+# convert_path ()
 
-def change_root(new_root, pathname):
-    """Return 'pathname' with 'new_root' prepended.
 
-    If 'pathname' is relative, this is equivalent to
-    "os.path.join(new_root,pathname)".
+def change_root (new_root, pathname):
+    """Return 'pathname' with 'new_root' prepended.  If 'pathname' is
+    relative, this is equivalent to "os.path.join(new_root,pathname)".
     Otherwise, it requires making 'pathname' relative and then joining the
     two, which is tricky on DOS/Windows and Mac OS.
     """
@@ -91,16 +233,23 @@
             path = path[1:]
         return os.path.join(new_root, path)
 
-    else:
-        raise DistutilsPlatformError("nothing known about "
-                                     "platform '%s'" % os.name)
+    elif os.name == 'mac':
+        if not os.path.isabs(pathname):
+            return os.path.join(new_root, pathname)
+        else:
+            # Chop off volume name from start of path
+            elements = pathname.split(":", 1)
+            pathname = ":" + elements[1]
+            return os.path.join(new_root, pathname)
 
-_environ_checked = 0
+    else:
+        raise DistutilsPlatformError("nothing known about platform '%s'" % os.name)
 
-def check_environ():
-    """Ensure that 'os.environ' has all the environment variables needed.
 
-    We guarantee that users can use in config files, command-line options,
+_environ_checked = 0
+def check_environ ():
+    """Ensure that 'os.environ' has all the environment variables we
+    guarantee that users can use in config files, command-line options,
     etc.  Currently this includes:
       HOME - user's home directory (Unix only)
       PLAT - description of the current platform, including hardware
@@ -115,14 +264,14 @@
         os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
 
     if 'PLAT' not in os.environ:
-        os.environ['PLAT'] = _sysconfig.get_platform()
+        os.environ['PLAT'] = get_platform()
 
     _environ_checked = 1
 
-def subst_vars(s, local_vars):
-    """Perform shell/Perl-style variable substitution on 'string'.
 
-    Every occurrence of '$' followed by a name is considered a variable, and
+def subst_vars (s, local_vars):
+    """Perform shell/Perl-style variable substitution on 'string'.  Every
+    occurrence of '$' followed by a name is considered a variable, and
     variable is substituted by the value found in the 'local_vars'
     dictionary, or in 'os.environ' if it's not in 'local_vars'.
     'os.environ' is first checked/augmented to guarantee that it contains
@@ -142,11 +291,12 @@
     except KeyError as var:
         raise ValueError("invalid variable '$%s'" % var)
 
-def grok_environment_error(exc, prefix="error: "):
-    """Generate a useful error message from an EnvironmentError.
+# subst_vars ()
+
 
-    This will generate an IOError or an OSError exception object.
-    Handles Python 1.5.1 and 1.5.2 styles, and
+def grok_environment_error (exc, prefix="error: "):
+    """Generate a useful error message from an EnvironmentError (IOError or
+    OSError) exception object.  Handles Python 1.5.1 and 1.5.2 styles, and
     does what it can to deal with exception objects that don't have a
     filename (which happens when the error is due to a two-file operation,
     such as 'rename()' or 'link()'.  Returns the error message as a string
@@ -165,20 +315,18 @@
 
     return error
 
+
 # Needed by 'split_quoted()'
 _wordchars_re = _squote_re = _dquote_re = None
-
 def _init_regex():
     global _wordchars_re, _squote_re, _dquote_re
     _wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
     _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
     _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
 
-def split_quoted(s):
+def split_quoted (s):
     """Split a string up according to Unix shell-like rules for quotes and
-    backslashes.
-
-    In short: words are delimited by spaces, as long as those
+    backslashes.  In short: words are delimited by spaces, as long as those
     spaces are not escaped by a backslash, or inside a quoted string.
     Single and double quotes are equivalent, and the quote characters can
     be backslash-escaped.  The backslash is stripped from any two-character
@@ -186,6 +334,7 @@
     characters are stripped from any quoted string.  Returns a list of
     words.
     """
+
     # This is a nice algorithm for splitting up a single string, since it
     # doesn't require character-by-character examination.  It was a little
     # bit of a brain-bender to get it working right, though...
@@ -233,12 +382,13 @@
 
     return words
 
+# split_quoted ()
 
-def execute(func, args, msg=None, verbose=0, dry_run=0):
-    """Perform some action that affects the outside world.
 
-    eg. by writing to the filesystem).  Such actions are special because
-    they are disabled by the 'dry_run' flag.  This method takes care of all
+def execute (func, args, msg=None, verbose=0, dry_run=0):
+    """Perform some action that affects the outside world (eg.  by
+    writing to the filesystem).  Such actions are special because they
+    are disabled by the 'dry_run' flag.  This method takes care of all
     that bureaucracy for you; all you have to do is supply the
     function to call and an argument tuple for it (to embody the
     "external action" being performed), and an optional message to
@@ -254,7 +404,7 @@
         func(*args)
 
 
-def strtobool(val):
+def strtobool (val):
     """Convert a string representation of truth to true (1) or false (0).
 
     True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
@@ -270,13 +420,15 @@
         raise ValueError("invalid truth value %r" % (val,))
 
 
-def byte_compile(py_files, optimize=0, force=0, prefix=None, base_dir=None,
-                  verbose=1, dry_run=0, direct=None):
+def byte_compile (py_files,
+                  optimize=0, force=0,
+                  prefix=None, base_dir=None,
+                  verbose=1, dry_run=0,
+                  direct=None):
     """Byte-compile a collection of Python source files to either .pyc
-    or .pyo files in the same directory.
-
-    'py_files' is a list of files to compile; any files that don't end in
-    ".py" are silently skipped. 'optimize' must be one of the following:
+    or .pyo files in the same directory.  'py_files' is a list of files
+    to compile; any files that don't end in ".py" are silently skipped.
+    'optimize' must be one of the following:
       0 - don't optimize (generate .pyc)
       1 - normal optimization (like "python -O")
       2 - extra optimization (like "python -OO")
@@ -392,8 +544,8 @@
             dfile = file
             if prefix:
                 if file[:len(prefix)] != prefix:
-                    raise ValueError("invalid prefix: filename %r doesn't "
-                                     "start with %r" % (file, prefix))
+                    raise ValueError("invalid prefix: filename %r doesn't start with %r"
+                           % (file, prefix))
                 dfile = dfile[len(prefix):]
             if base_dir:
                 dfile = os.path.join(base_dir, dfile)
@@ -408,8 +560,9 @@
                     log.debug("skipping byte-compilation of %s to %s",
                               file, cfile_base)
 
+# byte_compile ()
 
-def rfc822_escape(header):
+def rfc822_escape (header):
     """Return a version of the string escaped for inclusion in an
     RFC-822 header, by ensuring there are 8 spaces space after each newline.
     """
@@ -417,56 +570,6 @@
     sep = '\n' + 8 * ' '
     return sep.join(lines)
 
-_RE_VERSION = re.compile(b'(\d+\.\d+(\.\d+)*)')
-_MAC_OS_X_LD_VERSION = re.compile(b'^@\(#\)PROGRAM:ld  PROJECT:ld64-((\d+)(\.\d+)*)')
-
-def _find_ld_version():
-    """Finds the ld version. The version scheme differs under Mac OSX."""
-    if sys.platform == 'darwin':
-        return _find_exe_version('ld -v', _MAC_OS_X_LD_VERSION)
-    else:
-        return _find_exe_version('ld -v')
-
-def _find_exe_version(cmd, pattern=_RE_VERSION):
-    """Find the version of an executable by running `cmd` in the shell.
-
-    `pattern` is a compiled regular expression. If not provided, default
-    to _RE_VERSION. If the command is not found, or the output does not
-    match the mattern, returns None.
-    """
-    from subprocess import Popen, PIPE
-    executable = cmd.split()[0]
-    if find_executable(executable) is None:
-        return None
-    pipe = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
-    try:
-        stdout, stderr = pipe.stdout.read(), pipe.stderr.read()
-    finally:
-        pipe.stdout.close()
-        pipe.stderr.close()
-    # some commands like ld under MacOS X, will give the
-    # output in the stderr, rather than stdout.
-    if stdout != b'':
-        out_string = stdout
-    else:
-        out_string = stderr
-
-    result = pattern.search(out_string)
-    if result is None:
-        return None
-    return LooseVersion(result.group(1).decode())
-
-def get_compiler_versions():
-    """Returns a tuple providing the versions of gcc, ld and dllwrap
-
-    For each command, if a command is not found, None is returned.
-    Otherwise a LooseVersion instance is returned.
-    """
-    gcc = _find_exe_version('gcc -dumpversion')
-    ld = _find_ld_version()
-    dllwrap = _find_exe_version('dllwrap --version')
-    return gcc, ld, dllwrap
-
 # 2to3 support
 
 def run_2to3(files, fixer_names=None, options=None, explicit=None):

Modified: python/branches/py3k/setup.py
==============================================================================
--- python/branches/py3k/setup.py	(original)
+++ python/branches/py3k/setup.py	Thu Jul 22 14:50:05 2010
@@ -222,7 +222,7 @@
         if compiler is not None:
             (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
             args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
-        self.compiler_obj.set_executables(**args)
+        self.compiler.set_executables(**args)
 
         build_ext.build_extensions(self)
 
@@ -343,8 +343,8 @@
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler_obj.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler_obj.include_dirs, '/usr/local/include')
+        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
 
         # Add paths specified in the environment variables LDFLAGS and
         # CPPFLAGS for header and library files.
@@ -353,9 +353,9 @@
         # the environment variable is not set even though the value were passed
         # into configure and stored in the Makefile (issue found on OS X 10.3).
         for env_var, arg_name, dir_list in (
-                ('LDFLAGS', '-R', self.compiler_obj.runtime_library_dirs),
-                ('LDFLAGS', '-L', self.compiler_obj.library_dirs),
-                ('CPPFLAGS', '-I', self.compiler_obj.include_dirs)):
+                ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
+                ('LDFLAGS', '-L', self.compiler.library_dirs),
+                ('CPPFLAGS', '-I', self.compiler.include_dirs)):
             env_val = sysconfig.get_config_var(env_var)
             if env_val:
                 # To prevent optparse from raising an exception about any
@@ -381,19 +381,19 @@
                         add_dir_to_list(dir_list, directory)
 
         if os.path.normpath(sys.prefix) != '/usr':
-            add_dir_to_list(self.compiler_obj.library_dirs,
+            add_dir_to_list(self.compiler.library_dirs,
                             sysconfig.get_config_var("LIBDIR"))
-            add_dir_to_list(self.compiler_obj.include_dirs,
+            add_dir_to_list(self.compiler.include_dirs,
                             sysconfig.get_config_var("INCLUDEDIR"))
 
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
-        lib_dirs = self.compiler_obj.library_dirs + [
+        lib_dirs = self.compiler.library_dirs + [
             '/lib64', '/usr/lib64',
             '/lib', '/usr/lib',
             ]
-        inc_dirs = self.compiler_obj.include_dirs + ['/usr/include']
+        inc_dirs = self.compiler.include_dirs + ['/usr/include']
         exts = []
         missing = []
 
@@ -525,7 +525,7 @@
         exts.append( Extension('audioop', ['audioop.c']) )
 
         # readline
-        do_readline = self.compiler_obj.find_library_file(lib_dirs, 'readline')
+        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
         readline_termcap_library = ""
         curses_library = ""
         # Determine if readline is already linked against curses or tinfo.
@@ -552,11 +552,11 @@
         # use the same library for the readline and curses modules.
         if 'curses' in readline_termcap_library:
             curses_library = readline_termcap_library
-        elif self.compiler_obj.find_library_file(lib_dirs, 'ncursesw'):
+        elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
             curses_library = 'ncursesw'
-        elif self.compiler_obj.find_library_file(lib_dirs, 'ncurses'):
+        elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
             curses_library = 'ncurses'
-        elif self.compiler_obj.find_library_file(lib_dirs, 'curses'):
+        elif self.compiler.find_library_file(lib_dirs, 'curses'):
             curses_library = 'curses'
 
         if platform == 'darwin':
@@ -586,7 +586,7 @@
                 pass # Issue 7384: Already linked against curses or tinfo.
             elif curses_library:
                 readline_libs.append(curses_library)
-            elif self.compiler_obj.find_library_file(lib_dirs +
+            elif self.compiler.find_library_file(lib_dirs +
                                                      ['/usr/lib/termcap'],
                                                      'termcap'):
                 readline_libs.append('termcap')
@@ -599,7 +599,7 @@
 
         # crypt module.
 
-        if self.compiler_obj.find_library_file(lib_dirs, 'crypt'):
+        if self.compiler.find_library_file(lib_dirs, 'crypt'):
             libs = ['crypt']
         else:
             libs = []
@@ -627,7 +627,7 @@
                                ['/usr/kerberos/include'])
             if krb5_h:
                 ssl_incs += krb5_h
-        ssl_libs = find_library_file(self.compiler_obj, 'ssl',lib_dirs,
+        ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
                                      ['/usr/local/ssl/lib',
                                       '/usr/contrib/ssl/lib/'
                                      ] )
@@ -952,7 +952,7 @@
                 os.path.join(sqlite_incdir, '..', '..', 'lib64'),
                 os.path.join(sqlite_incdir, '..', '..', 'lib'),
             ]
-            sqlite_libfile = self.compiler_obj.find_library_file(
+            sqlite_libfile = self.compiler.find_library_file(
                                 sqlite_dirs_to_check + lib_dirs, 'sqlite3')
             if sqlite_libfile:
                 sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))]
@@ -1014,7 +1014,7 @@
                 if cand == "ndbm":
                     if find_file("ndbm.h", inc_dirs, []) is not None:
                         # Some systems have -lndbm, others don't
-                        if self.compiler_obj.find_library_file(lib_dirs,
+                        if self.compiler.find_library_file(lib_dirs,
                                                                'ndbm'):
                             ndbm_libs = ['ndbm']
                         else:
@@ -1028,9 +1028,9 @@
                         break
 
                 elif cand == "gdbm":
-                    if self.compiler_obj.find_library_file(lib_dirs, 'gdbm'):
+                    if self.compiler.find_library_file(lib_dirs, 'gdbm'):
                         gdbm_libs = ['gdbm']
-                        if self.compiler_obj.find_library_file(lib_dirs,
+                        if self.compiler.find_library_file(lib_dirs,
                                                                'gdbm_compat'):
                             gdbm_libs.append('gdbm_compat')
                         if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
@@ -1071,7 +1071,7 @@
 
         # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm:
         if ('gdbm' in dbm_order and
-            self.compiler_obj.find_library_file(lib_dirs, 'gdbm')):
+            self.compiler.find_library_file(lib_dirs, 'gdbm')):
             exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
                                    libraries = ['gdbm'] ) )
         else:
@@ -1087,7 +1087,7 @@
             # Sun yellow pages. Some systems have the functions in libc.
             if (platform not in ['cygwin', 'qnx6'] and
                 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
-                if (self.compiler_obj.find_library_file(lib_dirs, 'nsl')):
+                if (self.compiler.find_library_file(lib_dirs, 'nsl')):
                     libs = ['nsl']
                 else:
                     libs = []
@@ -1112,9 +1112,9 @@
         elif curses_library == 'curses' and platform != 'darwin':
                 # OSX has an old Berkeley curses, not good enough for
                 # the _curses module.
-            if (self.compiler_obj.find_library_file(lib_dirs, 'terminfo')):
+            if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
                 curses_libs = ['curses', 'terminfo']
-            elif (self.compiler_obj.find_library_file(lib_dirs, 'termcap')):
+            elif (self.compiler.find_library_file(lib_dirs, 'termcap')):
                 curses_libs = ['curses', 'termcap']
             else:
                 curses_libs = ['curses']
@@ -1126,7 +1126,7 @@
 
         # If the curses module is enabled, check for the panel module
         if (module_enabled(exts, '_curses') and
-            self.compiler_obj.find_library_file(lib_dirs, panel_library)):
+            self.compiler.find_library_file(lib_dirs, panel_library)):
             exts.append( Extension('_curses_panel', ['_curses_panel.c'],
                                    libraries = [panel_library] + curses_libs) )
         else:
@@ -1159,7 +1159,7 @@
                     version = line.split()[2]
                     break
             if version >= version_req:
-                if (self.compiler_obj.find_library_file(lib_dirs, 'z')):
+                if (self.compiler.find_library_file(lib_dirs, 'z')):
                     if sys.platform == "darwin":
                         zlib_extra_link_args = ('-Wl,-search_paths_first',)
                     else:
@@ -1191,7 +1191,7 @@
                                extra_link_args = extra_link_args) )
 
         # Gustavo Niemeyer's bz2 module.
-        if (self.compiler_obj.find_library_file(lib_dirs, 'bz2')):
+        if (self.compiler.find_library_file(lib_dirs, 'bz2')):
             if sys.platform == "darwin":
                 bz2_extra_link_args = ('-Wl,-search_paths_first',)
             else:
@@ -1452,9 +1452,9 @@
         tcllib = tklib = tcl_includes = tk_includes = None
         for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
                         '8.2', '82', '8.1', '81', '8.0', '80']:
-            tklib = self.compiler_obj.find_library_file(lib_dirs,
+            tklib = self.compiler.find_library_file(lib_dirs,
                                                         'tk' + version)
-            tcllib = self.compiler_obj.find_library_file(lib_dirs,
+            tcllib = self.compiler.find_library_file(lib_dirs,
                                                          'tcl' + version)
             if tklib and tcllib:
                 # Exit the loop when we've found the Tcl/Tk libraries
@@ -1513,11 +1513,11 @@
                 return
 
         # Check for BLT extension
-        if self.compiler_obj.find_library_file(lib_dirs + added_lib_dirs,
+        if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
                                                'BLT8.0'):
             defs.append( ('WITH_BLT', 1) )
             libs.append('BLT8.0')
-        elif self.compiler_obj.find_library_file(lib_dirs + added_lib_dirs,
+        elif self.compiler.find_library_file(lib_dirs + added_lib_dirs,
                                                 'BLT'):
             defs.append( ('WITH_BLT', 1) )
             libs.append('BLT')
@@ -1572,7 +1572,7 @@
                              ]]
 
         # Add .S (preprocessed assembly) to C compiler source extensions.
-        self.compiler_obj.src_extensions.append('.S')
+        self.compiler.src_extensions.append('.S')
 
         include_dirs = [os.path.join(ffi_srcdir, 'include'),
                         os.path.join(ffi_srcdir, 'powerpc')]
@@ -1617,7 +1617,7 @@
                 exec(f.read(), globals(), fficonfig)
 
             # Add .S (preprocessed assembly) to C compiler source extensions.
-            self.compiler_obj.src_extensions.append('.S')
+            self.compiler.src_extensions.append('.S')
 
             include_dirs = [os.path.join(ffi_builddir, 'include'),
                             ffi_builddir,
@@ -1699,7 +1699,7 @@
         ffi_lib = None
         if ffi_inc is not None:
             for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'):
-                if (self.compiler_obj.find_library_file(lib_dirs, lib_name)):
+                if (self.compiler.find_library_file(lib_dirs, lib_name)):
                     ffi_lib = lib_name
                     break
 


More information about the Python-checkins mailing list