[Python-checkins] distutils2 (merge default -> default): merge

tarek.ziade python-checkins at python.org
Sun Mar 13 20:56:01 CET 2011


http://hg.python.org/distutils2/rev/ba136beee019
changeset:   1116:ba136beee019
parent:      1115:6cf51c545e01
parent:      1112:22da53c1cf98
user:        Tarek Ziade <tarek at ziade.org>
date:        Sun Mar 13 15:13:28 2011 -0400
summary:
  merge

files:
  

diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -21,6 +21,7 @@
 - Andrew Francis
 - Yannick Gingras
 - Alexandre Hamelin
+- Kelsey Hightower
 - Christian Hudon
 - Jeremy Kloth
 - Amos Latteier
diff --git a/distutils2/_backport/tests/test_pkgutil.py b/distutils2/_backport/tests/test_pkgutil.py
--- a/distutils2/_backport/tests/test_pkgutil.py
+++ b/distutils2/_backport/tests/test_pkgutil.py
@@ -15,7 +15,7 @@
 
 from distutils2.errors import DistutilsError
 from distutils2.metadata import Metadata
-from distutils2.tests import unittest, run_unittest, support
+from distutils2.tests import unittest, run_unittest, support, TESTFN
 
 from distutils2._backport import pkgutil
 from distutils2._backport.pkgutil import (
diff --git a/distutils2/_backport/tests/test_sysconfig.py b/distutils2/_backport/tests/test_sysconfig.py
--- a/distutils2/_backport/tests/test_sysconfig.py
+++ b/distutils2/_backport/tests/test_sysconfig.py
@@ -14,10 +14,15 @@
         get_config_var, get_config_vars, get_path, get_paths, get_platform,
         get_scheme_names, _main, _SCHEMES)
 
-from distutils2.tests import unittest
-from distutils2.tests.support import EnvironGuard, skip_unless_symlink
+from distutils2.tests import unittest, TESTFN, unlink
+from distutils2.tests.support import EnvironGuard
 from test.test_support import TESTFN, unlink
 
+try:
+    from test.test_support import skip_unless_symlink
+except ImportError:
+    skip_unless_symlink = unittest.skip(
+        'requires test.test_support.skip_unless_symlink')
 
 class TestSysConfig(EnvironGuard, unittest.TestCase):
 
diff --git a/distutils2/compiler/unixccompiler.py b/distutils2/compiler/unixccompiler.py
--- a/distutils2/compiler/unixccompiler.py
+++ b/distutils2/compiler/unixccompiler.py
@@ -15,7 +15,6 @@
 
 
 import os, sys
-from types import StringType, NoneType
 
 from distutils2.util import newer
 from distutils2.compiler.ccompiler import CCompiler
@@ -217,7 +216,7 @@
 
         lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
                                    libraries)
-        if type(output_dir) not in (StringType, NoneType):
+        if not isinstance(output_dir, (str, type(None))):
             raise TypeError, "'output_dir' must be a string or None"
         if output_dir is not None:
             output_filename = os.path.join(output_dir, output_filename)
diff --git a/distutils2/depgraph.py b/distutils2/depgraph.py
--- a/distutils2/depgraph.py
+++ b/distutils2/depgraph.py
@@ -78,7 +78,7 @@
             if label is not None:
                 dist = '%s [%s]' % (dist, label)
             output.append('    ' * level + '%s' % dist)
-            suboutput = self.repr_node(other, level+1)
+            suboutput = self.repr_node(other, level + 1)
             subs = suboutput.split('\n')
             output.extend(subs[1:])
         return '\n'.join(output)
@@ -133,16 +133,16 @@
     :rtype: an :class:`DependencyGraph` instance
     """
     graph = DependencyGraph()
-    provided = {} # maps names to lists of (version, dist) tuples
-    dists = list(dists) # maybe use generator_tools in future
+    provided = {}  # maps names to lists of (version, dist) tuples
+    dists = list(dists)  # maybe use generator_tools in future
 
     # first, build the graph and find out the provides
     for dist in dists:
         graph.add_distribution(dist)
-        provides = (dist.metadata['Provides-Dist'] + dist.metadata['Provides'] +
+        provides = (dist.metadata['Provides-Dist'] +
+                    dist.metadata['Provides'] +
                     ['%s (%s)' % (dist.name, dist.metadata['Version'])])
 
-
         for p in provides:
             comps = p.strip().rsplit(" ", 1)
             name = comps[0]
@@ -152,7 +152,7 @@
                 if len(version) < 3 or version[0] != '(' or version[-1] != ')':
                     raise DistutilsError('Distribution %s has ill formed' \
                                          'provides field: %s' % (dist.name, p))
-                version = version[1:-1] # trim off parenthesis
+                version = version[1:-1]  # trim off parenthesis
             if not name in provided:
                 provided[name] = []
             provided[name].append((version, dist))
@@ -179,7 +179,7 @@
                         match = predicate.match(version)
                     except IrrationalVersionError:
                         # XXX small compat-mode
-                        if version.split(' ' ) == 1:
+                        if version.split(' ') == 1:
                             match = True
                         else:
                             match = False
@@ -204,8 +204,8 @@
         raise ValueError('The given distribution is not a member of the list')
     graph = generate_graph(dists)
 
-    dep = [dist] # dependent distributions
-    fringe = graph.reverse_list[dist] # list of nodes we should inspect
+    dep = [dist]  # dependent distributions
+    fringe = graph.reverse_list[dist]  # list of nodes we should inspect
 
     while not len(fringe) == 0:
         node = fringe.pop()
@@ -214,9 +214,10 @@
             if not prev in dep:
                 fringe.append(prev)
 
-    dep.pop(0) # remove dist from dep, was there to prevent infinite loops
+    dep.pop(0)  # remove dist from dep, was there to prevent infinite loops
     return dep
 
+
 def main():
     from distutils2._backport.pkgutil import get_distributions
     tempout = StringIO()
diff --git a/distutils2/fancy_getopt.py b/distutils2/fancy_getopt.py
--- a/distutils2/fancy_getopt.py
+++ b/distutils2/fancy_getopt.py
@@ -13,6 +13,7 @@
 import string
 import re
 import getopt
+import textwrap
 from distutils2.errors import DistutilsGetoptError, DistutilsArgError
 
 # Much like command_re in distutils.core, this is close to but not quite
@@ -334,7 +335,7 @@
 
         for option in self.option_table:
             long, short, help = option[:3]
-            text = wrap_text(help, text_width)
+            text = textwrap.wrap(help, text_width)
             if long[-1] == '=':
                 long = long[0:-1]
 
@@ -373,7 +374,12 @@
     return parser.getopt(args, object)
 
 
-WS_TRANS = string.maketrans(string.whitespace, ' ' * len(string.whitespace))
+if 'maketrans' in str.__dict__ :
+    # Python 3.2+
+    WS_TRANS = str.maketrans(string.whitespace, ' ' * len(string.whitespace))
+else :
+    # Depreciated syntax
+    WS_TRANS = string.maketrans(string.whitespace, ' ' * len(string.whitespace))
 
 
 def wrap_text(text, width):
diff --git a/distutils2/resources.py b/distutils2/resources.py
--- a/distutils2/resources.py
+++ b/distutils2/resources.py
@@ -1,12 +1,15 @@
 import os
+
 from distutils2.util import iglob
 
+
 def _rel_path(base, path):
     assert path.startswith(base)
     return path[len(base):].lstrip('/')
 
+
 def resources_dests(resources_root, rules):
-    """find destination of ressources files"""
+    """find destination of resources files"""
     destinations = {}
     for (base, suffix, dest) in rules:
         prefix = os.path.join(resources_root, base)
@@ -14,7 +17,7 @@
             abs_glob = os.path.join(abs_base, suffix)
             for abs_path in iglob(abs_glob):
                 resource_file = _rel_path(resources_root, abs_path)
-                if dest is None: #remove the entry if it was here
+                if dest is None:  # remove the entry if it was here
                     destinations.pop(resource_file, None)
                 else:
                     rel_path = _rel_path(abs_base, abs_path)
diff --git a/distutils2/tests/__init__.py b/distutils2/tests/__init__.py
--- a/distutils2/tests/__init__.py
+++ b/distutils2/tests/__init__.py
@@ -30,8 +30,11 @@
     except ImportError:
         sys.exit('Error: You have to install unittest2')
 
-
-from test.test_support import TESTFN    # use TESTFN from stdlib/test_support.
+# use TESTFN from stdlib, pull in unlink for other modules to use as well
+if sys.version_info[0] == 3:
+  from test.support import TESTFN, unlink
+else :
+  from test.test_support import TESTFN, unlink
 
 here = os.path.dirname(__file__) or os.curdir
 
diff --git a/distutils2/tests/pypi_server.py b/distutils2/tests/pypi_server.py
--- a/distutils2/tests/pypi_server.py
+++ b/distutils2/tests/pypi_server.py
@@ -29,16 +29,23 @@
 implementations (static HTTP and XMLRPC over HTTP).
 """
 
-import Queue
-import SocketServer
 import os.path
 import select
 import socket
 import threading
 
-from BaseHTTPServer import HTTPServer
-from SimpleHTTPServer import SimpleHTTPRequestHandler
-from SimpleXMLRPCServer import SimpleXMLRPCServer
+# several packages had different names in Python 2.x
+try:
+    import queue
+    import socketserver
+    from http.server import HTTPServer, SimpleHTTPRequestHandler
+    from xmlrpc.server import SimpleXMLRPCServer
+except ImportError:
+    import Queue as queue
+    import SocketServer as socketserver
+    from BaseHTTPServer import HTTPServer    
+    from SimpleHTTPServer import SimpleHTTPRequestHandler
+    from SimpleXMLRPCServer import SimpleXMLRPCServer
 
 from distutils2.tests import unittest
 
@@ -109,7 +116,7 @@
             self.server = HTTPServer(('127.0.0.1', 0), PyPIRequestHandler)
             self.server.RequestHandlerClass.pypi_server = self
 
-            self.request_queue = Queue.Queue()
+            self.request_queue = queue.Queue()
             self._requests = []
             self.default_response_status = 200
             self.default_response_headers = [('Content-type', 'text/plain')]
@@ -157,7 +164,7 @@
         while True:
             try:
                 self._requests.append(self.request_queue.get_nowait())
-            except Queue.Empty:
+            except queue.Empty:
                 break
         return self._requests
 
@@ -252,7 +259,7 @@
 class PyPIXMLRPCServer(SimpleXMLRPCServer):
     def server_bind(self):
         """Override server_bind to store the server name."""
-        SocketServer.TCPServer.server_bind(self)
+        socketserver.TCPServer.server_bind(self)
         host, port = self.socket.getsockname()[:2]
         self.server_name = socket.getfqdn(host)
         self.server_port = port
diff --git a/distutils2/util.py b/distutils2/util.py
--- a/distutils2/util.py
+++ b/distutils2/util.py
@@ -15,7 +15,7 @@
 try:
     from glob import iglob as std_iglob
 except ImportError:
-    from glob import glob as std_iglob # for python < 2.5
+    from glob import glob as std_iglob  # for python < 2.5
 from ConfigParser import RawConfigParser
 from inspect import getsource
 
@@ -953,6 +953,7 @@
 _CHECK_RECURSIVE_GLOB = re.compile(r'[^/,{]\*\*|\*\*[^/,}]')
 _CHECK_MISMATCH_SET = re.compile(r'^[^{]*\}|\{[^}]*$')
 
+
 def iglob(path_glob):
     """Richer glob than the std glob module support ** and {opt1,opt2,opt3}"""
     if _CHECK_RECURSIVE_GLOB.search(path_glob):
@@ -971,7 +972,7 @@
         assert len(rich_path_glob) == 3, rich_path_glob
         prefix, set, suffix = rich_path_glob
         for item in set.split(','):
-            for path in _iglob( ''.join((prefix, item, suffix))):
+            for path in _iglob(''.join((prefix, item, suffix))):
                 yield path
     else:
         if '**' not in path_glob:
@@ -988,7 +989,7 @@
             for (path, dir, files) in os.walk(prefix):
                 path = os.path.normpath(path)
                 for file in _iglob(os.path.join(path, radical)):
-                   yield file
+                    yield file
 
 
 def cfg_to_args(path='setup.cfg'):
diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst
--- a/docs/source/contributing.rst
+++ b/docs/source/contributing.rst
@@ -6,47 +6,22 @@
 Reporting Issues
 ----------------
 
-When using, testing, developping distutils2, you may encounter issues. Please report to the following sections to know how these issues should be reported.
+When using, testing or developping distutils2, you may encounter issues. Please report to the following sections to know how these issues should be reported.
 
-Please keep in mind that this guide is intended to ease the triage and fixing processes by giving the maximum information to the developers. It should not be viewed as mandatory, only advised ;).
+Please keep in mind that this guide is intended to ease the triage and fixing processes by giving the maximum information to the developers. It should not be viewed as mandatory, only advisory ;).
 
-Issues regarding distutils2 commands
-====================================
 
 - Go to http://bugs.python.org/ (you'll need a Python Bugs account), then "Issues" > "Create ticket".
-- **Title**: write in a short summary of the issue. 
-    * You may prefix the issue title with [d2_component], where d2_component can be : installer, sdist, setup.cfg, ... This will ease up the triage process.
-
+- **Title**: write in a short summary of the issue. You may prefix the issue title with “component:”, where component can be something like installer, sdist, setup.cfg, etc., or add it at the end of your title if the normal flow of the sentence allows it. This will ease up later searches.
 - **Components**: choose "Distutils2"
 - **Version**: choose "3rd party"
-- **Comment**: use the following template for versions, reproduction conditions:
-    * If some of the fields presented don't apply to the issue, feel free to pick only the ones you need.
+- **Body**: explain how to reproduce the bug: What you want to do, what code you write, what happens, what should happen, how to fix it (if you have an idea).
+   * You should always test with the tip of the main repository, not releases.
+   * Mention the versions of Python you tested with.  d2 supports 2.4 to 2.7.
+   * If relevant, mention the version of your operating system (for example with issues related to C extensions).
+   * When referencing commits, be careful to use the universal changeset identifiers (12 characters, for instance c3cf81fc64db), not the local sequential numbers (for example 925) that are not shared among clones.
+   * Try to be as concise as possible, but not too much.
+   * If useful, paste tracebacks.
+   * If useful, attach setup.cfg or other files (binary files like archives are not very convenient, better to stick to text).
 
-::
-
-    Operating System:
-    Version of Python:
-    Version of Distutils2:
-
-    How to reproduce:
-
-    What happens:
-
-    What should happen:
-
-- Filling in the fields:
-    * **How to reproduce**: indicate some test case to reproduce the issue.
-    * **What happens**: describe what is the error, paste tracebacks if you have any.
-    * **What should happen**: indicate what you think should be the result of the test case (wanted behaviour).
-    * **Versions**:
-        - If you're using a release of distutils2, you may want to test the latest version of the project (under developpment code).
-        - If the issue is present in the latest version, please indicate the tip commit of the version tested.
-        - Be careful to indicate the remote reference (12 characters, for instance c3cf81fc64db), not the local reference (rXXX).
-
-- If it is relevant, please join any file that will help reproducing the issue or logs to understand the problem (setup.cfg, strace ouptups, ...).
-
-Issues regarding PyPI display of the distutils2 projects
-========================================================
-
-- Please send a bug report to the catalog-sig at python.org mailing list.
-- You can include your setup.cfg, and a link to your project page.
+Issues related to PyPI are reported via email to the **catalog-sig at python.org** mailing list, not within bugs.python.org.
diff --git a/runtests.py b/runtests.py
--- a/runtests.py
+++ b/runtests.py
@@ -64,7 +64,7 @@
         # running coverage 2.x
         cov.cache = COVERAGE_FILE
         cov.restore()
-        morfs = [m for m in cov.cexecuted if "distutils2" in m]
+        morfs = [m for m in list(cov.cexecuted.keys()) if "distutils2" in m]
 
     prefixes = ["runtests", "distutils2/tests", "distutils2/_backport"]
     prefixes += ignore_prefixes(unittest)
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -5,16 +5,24 @@
 import re
 
 from distutils2 import __version__ as VERSION
-from distutils2.util import find_packages
 from distutils import log
 from distutils.ccompiler import new_compiler
 from distutils.command.sdist import sdist
 from distutils.command.install import install
 
+# Python 3.x hook to run 2to3 automatically
 try:
-    from setuptools import setup, Extension
+    from distutils.command.build_py import build_py_2to3 as build_py
+    from distutils.core import setup, Extension
 except ImportError:
-    from distutils.core import setup, Extension
+    # 2.x, try to use setuptools if available
+    try :
+        from setuptools.command.build_py import build_py
+        from setuptools import setup, Extension
+    except ImportError:
+        from distutils.command.build_py import build_py
+        from distutils.core import setup, Extension
+
 
 f = open('README.txt')
 try:
@@ -30,7 +38,7 @@
     except OSError:
         return 0
     rev = cmd.stdout.read()
-    if rev == '':
+    if not rev :
         # there has been an error in the command
         return 0
     return int(rev)
@@ -222,7 +230,20 @@
       license="PSF",
       long_description=README,
       classifiers=_CLASSIFIERS.split('\n'),
-      packages=find_packages(),
-      cmdclass={'sdist_hg': sdist_hg, 'install_hg': install_hg},
+      packages=[
+          'distutils2',
+          'distutils2.tests', 
+          'distutils2.compiler', 
+          'distutils2.command', 
+          'distutils2._backport', 
+          'distutils2.index', 
+          'distutils2.tests.fixer', 
+          'distutils2._backport.tests',
+      ],
+      cmdclass={
+          'build_py':build_py, 
+          'install_hg': install_hg,
+          'sdist_hg': sdist_hg, 
+      },
       package_data={'distutils2._backport': ['sysconfig.cfg']},
       **setup_kwargs)
diff --git a/tests.sh b/tests.sh
--- a/tests.sh
+++ b/tests.sh
@@ -37,4 +37,46 @@
 else
     echo Success
 fi
+
+LIB=$( python3.1 -c "from distutils.util import get_platform; import sys; print('lib.%s-%s' % (get_platform(), sys.version[0:3]))" )
+
+
+echo -n "Running tests for Python 3.1... "
+python3.1 setup.py build -q 2> /dev/null > /dev/null
+cp runtests.py build/
+cd build
+PYTHONPATH=${LIB} python3.1 runtests.py -q 2> /dev/null 
+
+if [ $? -ne 0 ];then
+    echo Failed
+    exit 1
+else
+    echo Success
+fi
+
+echo -n "Running tests for Python 3.2... "
+python3.2 setup.py build -q 2> /dev/null > /dev/null
+cp runtests.py build/
+cd build
+PYTHONPATH=${LIB} python3.2 runtests.py -q 2> /dev/null
+
+if [ $? -ne 0 ];then
+    echo Failed
+    exit 1
+else
+    echo Success
+fi
+
+echo -n "Running tests for Python 3.3... "
+python3.2 setup.py build -q 2> /dev/null > /dev/null
+cp runtests.py build/
+cd build
+PYTHONPATH=${LIB} python3.3 runtests.py -q 2> /dev/null
+
+if [ $? -ne 0 ];then
+    echo Failed
+    exit 1
+else
+    echo Success
+fi
 echo "Good job, commit now! (or add tests)"

-- 
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list