[Python-checkins] distutils2: removed core.py

tarek.ziade python-checkins at python.org
Mon Oct 25 02:00:56 CEST 2010


tarek.ziade pushed 7b8016c12237 to distutils2:

http://hg.python.org/distutils2/rev/7b8016c12237
changeset:   784:7b8016c12237
tag:         tip
user:        Tarek Ziade <tarek at ziade.org>
date:        Mon Oct 25 02:00:47 2010 +0200
summary:     removed core.py
files:       distutils2/command/bdist.py, distutils2/command/bdist_dumb.py, distutils2/command/bdist_wininst.py, distutils2/command/build.py, distutils2/command/build_clib.py, distutils2/command/build_ext.py, distutils2/command/build_py.py, distutils2/command/build_scripts.py, distutils2/command/check.py, distutils2/command/clean.py, distutils2/command/config.py, distutils2/command/install_data.py, distutils2/command/install_dist.py, distutils2/command/install_headers.py, distutils2/command/install_lib.py, distutils2/command/install_scripts.py, distutils2/command/sdist.py, distutils2/command/test.py, distutils2/core.py, distutils2/dist.py, distutils2/run.py, distutils2/tests/test_command_bdist_dumb.py, distutils2/tests/test_command_build_ext.py, distutils2/tests/test_command_build_py.py, distutils2/tests/test_command_build_scripts.py, distutils2/tests/test_command_install_dist.py, distutils2/tests/test_command_install_distinfo.py, distutils2/tests/test_command_install_scripts.py, distutils2/tests/test_command_register.py, distutils2/tests/test_command_sdist.py, distutils2/tests/test_command_upload.py, distutils2/tests/test_command_upload_docs.py, distutils2/tests/test_config.py, distutils2/tests/test_core.py, distutils2/tests/test_run.py, distutils2/tests/test_test.py

diff --git a/distutils2/command/bdist.py b/distutils2/command/bdist.py
--- a/distutils2/command/bdist.py
+++ b/distutils2/command/bdist.py
@@ -2,12 +2,10 @@
 
 Implements the Distutils 'bdist' command (create a built [binary]
 distribution)."""
-
-
 import os
 
 from distutils2.util import get_platform
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsPlatformError, DistutilsOptionError
 
 
diff --git a/distutils2/command/bdist_dumb.py b/distutils2/command/bdist_dumb.py
--- a/distutils2/command/bdist_dumb.py
+++ b/distutils2/command/bdist_dumb.py
@@ -12,7 +12,7 @@
 except ImportError:
     from distutils2._backport.sysconfig import get_python_version
 from distutils2.util import get_platform
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsPlatformError
 from distutils2 import log
 
diff --git a/distutils2/command/bdist_wininst.py b/distutils2/command/bdist_wininst.py
--- a/distutils2/command/bdist_wininst.py
+++ b/distutils2/command/bdist_wininst.py
@@ -12,7 +12,7 @@
     from sysconfig import get_python_version
 except ImportError:
     from distutils2._backport.sysconfig import get_python_version
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsOptionError, DistutilsPlatformError
 from distutils2 import log
 from distutils2.util import get_platform
diff --git a/distutils2/command/build.py b/distutils2/command/build.py
--- a/distutils2/command/build.py
+++ b/distutils2/command/build.py
@@ -6,7 +6,7 @@
 import sys, os
 
 from distutils2.util import get_platform
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsOptionError
 
 def show_compilers():
diff --git a/distutils2/command/build_clib.py b/distutils2/command/build_clib.py
--- a/distutils2/command/build_clib.py
+++ b/distutils2/command/build_clib.py
@@ -16,7 +16,7 @@
 # cut 'n paste.  Sigh.
 
 import os
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsSetupError
 from distutils2.compiler.ccompiler import customize_compiler
 from distutils2 import log
diff --git a/distutils2/command/build_ext.py b/distutils2/command/build_ext.py
--- a/distutils2/command/build_ext.py
+++ b/distutils2/command/build_ext.py
@@ -9,7 +9,7 @@
 from warnings import warn
 
 from distutils2.util import get_platform
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import (CCompilerError, CompileError, DistutilsError,
                                DistutilsPlatformError, DistutilsSetupError)
 from distutils2.compiler.ccompiler import customize_compiler
diff --git a/distutils2/command/build_py.py b/distutils2/command/build_py.py
--- a/distutils2/command/build_py.py
+++ b/distutils2/command/build_py.py
@@ -9,7 +9,7 @@
 from glob import glob
 
 import distutils2
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsOptionError, DistutilsFileError
 from distutils2.util import convert_path
 from distutils2.compat import Mixin2to3
diff --git a/distutils2/command/build_scripts.py b/distutils2/command/build_scripts.py
--- a/distutils2/command/build_scripts.py
+++ b/distutils2/command/build_scripts.py
@@ -5,7 +5,8 @@
 
 import os, re
 from stat import ST_MODE
-from distutils2.core import Command
+
+from distutils2.command.cmd import Command
 from distutils2.util import convert_path, newer
 from distutils2 import log
 try:
diff --git a/distutils2/command/check.py b/distutils2/command/check.py
--- a/distutils2/command/check.py
+++ b/distutils2/command/check.py
@@ -3,7 +3,7 @@
 Implements the Distutils 'check' command.
 """
 
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsSetupError
 from distutils2.util import resolve_name
 
diff --git a/distutils2/command/clean.py b/distutils2/command/clean.py
--- a/distutils2/command/clean.py
+++ b/distutils2/command/clean.py
@@ -7,7 +7,7 @@
 
 import os
 from shutil import rmtree
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2 import log
 
 class clean(Command):
diff --git a/distutils2/command/config.py b/distutils2/command/config.py
--- a/distutils2/command/config.py
+++ b/distutils2/command/config.py
@@ -13,7 +13,7 @@
 import os
 import re
 
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsExecError
 from distutils2.compiler.ccompiler import customize_compiler
 from distutils2 import log
diff --git a/distutils2/command/install_data.py b/distutils2/command/install_data.py
--- a/distutils2/command/install_data.py
+++ b/distutils2/command/install_data.py
@@ -7,7 +7,7 @@
 
 
 import os
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.util import change_root, convert_path
 
 class install_data(Command):
diff --git a/distutils2/command/install_dist.py b/distutils2/command/install_dist.py
--- a/distutils2/command/install_dist.py
+++ b/distutils2/command/install_dist.py
@@ -11,7 +11,7 @@
                                             get_path, get_config_var)
 
 from distutils2 import log
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsPlatformError
 from distutils2.util import write_file
 from distutils2.util import convert_path, change_root, get_platform
diff --git a/distutils2/command/install_headers.py b/distutils2/command/install_headers.py
--- a/distutils2/command/install_headers.py
+++ b/distutils2/command/install_headers.py
@@ -4,7 +4,7 @@
 files to the Python include directory."""
 
 
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 
 
 # XXX force is never used
diff --git a/distutils2/command/install_lib.py b/distutils2/command/install_lib.py
--- a/distutils2/command/install_lib.py
+++ b/distutils2/command/install_lib.py
@@ -7,7 +7,7 @@
 import os
 import sys
 
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsOptionError
 
 
diff --git a/distutils2/command/install_scripts.py b/distutils2/command/install_scripts.py
--- a/distutils2/command/install_scripts.py
+++ b/distutils2/command/install_scripts.py
@@ -7,7 +7,7 @@
 
 
 import os
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2 import log
 from stat import ST_MODE
 
diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py
--- a/distutils2/command/sdist.py
+++ b/distutils2/command/sdist.py
@@ -15,7 +15,7 @@
 except ImportError:
     from distutils2._backport.shutil import get_archive_formats
 
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import (DistutilsPlatformError, DistutilsOptionError,
                                DistutilsTemplateError)
 from distutils2.manifest import Manifest
diff --git a/distutils2/command/test.py b/distutils2/command/test.py
--- a/distutils2/command/test.py
+++ b/distutils2/command/test.py
@@ -2,7 +2,7 @@
 import sys
 import unittest
 
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.errors import DistutilsOptionError
 from distutils2.util import resolve_name
 
diff --git a/distutils2/core.py b/distutils2/core.py
deleted file mode 100644
--- a/distutils2/core.py
+++ /dev/null
@@ -1,219 +0,0 @@
-"""distutils2.core
-
-The only module that needs to be imported to use the Distutils; provides
-the 'setup' function (which is to be called from the setup script).  Also
-exports useful classes so that setup scripts can import them from here
-although they are really defined in other modules: Distribution, Command,
-PyPIRCommand, Extension, find_packages.
-"""
-
-
-import sys
-import os
-
-from distutils2.errors import (DistutilsSetupError, DistutilsArgError,
-                               DistutilsError, CCompilerError)
-from distutils2.util import grok_environment_error
-
-# Mainly import these so setup scripts can "from distutils2.core import" them.
-from distutils2.dist import Distribution
-from distutils2.command.cmd import Command
-from distutils2.extension import Extension
-from distutils2.util import find_packages
-
-# This is a barebones help message generated displayed when the user
-# runs the setup script with no arguments at all.  More useful help
-# is generated with various --help options: global help, list commands,
-# and per-command help.
-USAGE = """\
-usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
-   or: %(script)s --help [cmd1 cmd2 ...]
-   or: %(script)s --help-commands
-   or: %(script)s cmd --help
-"""
-
-
-def gen_usage(script_name):
-    script = os.path.basename(script_name)
-    return USAGE % {'script': script}
-
-
-# Some mild magic to control the behaviour of 'setup()' from 'run_setup()'.
-_setup_stop_after = None
-_setup_distribution = None
-
-# Legal keyword arguments for the setup() function
-setup_keywords = ('distclass', 'script_name', 'script_args', 'options',
-                  'name', 'version', 'author', 'author_email',
-                  'maintainer', 'maintainer_email', 'url', 'license',
-                  'description', 'long_description', 'keywords',
-                  'platforms', 'classifiers', 'download_url',
-                  'requires', 'provides', 'obsoletes', 'use_2to3_fixers',
-                  'convert_2to3_doctests', 'use_2to3_fixers'
-                  )
-
-# Legal keyword arguments for the Extension constructor
-extension_keywords = ('name', 'sources', 'include_dirs',
-                      'define_macros', 'undef_macros',
-                      'library_dirs', 'libraries', 'runtime_library_dirs',
-                      'extra_objects', 'extra_compile_args', 'extra_link_args',
-                      'swig_opts', 'export_symbols', 'depends', 'language')
-
-
-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
-    line; run each Distutils command found there, customized by the options
-    supplied to 'setup()' (as keyword arguments), in config files, and on
-    the command line.
-
-    The Distribution instance might be an instance of a class supplied via
-    the 'distclass' keyword argument to 'setup'; if no such class is
-    supplied, then the Distribution class (in dist.py) is instantiated.
-    All other arguments to 'setup' (except for 'cmdclass') are used to set
-    attributes of the Distribution instance.
-
-    The 'cmdclass' argument, if supplied, is a dictionary mapping command
-    names to command classes.  Each command encountered on the command line
-    will be turned into a command class, which is in turn instantiated; any
-    class found in 'cmdclass' is used in place of the default, which is
-    (for command 'foo_bar') class 'foo_bar' in module
-    'distutils2.command.foo_bar'.  The command class must provide a
-    'user_options' attribute which is a list of option specifiers for
-    'distutils2.fancy_getopt'.  Any command-line options between the current
-    and the next command are used to set attributes of the current command
-    object.
-
-    When the entire command line has been successfully parsed, calls the
-    'run()' method on each command object in turn.  This method will be
-    driven entirely by the Distribution object (which each command object
-    has a reference to, thanks to its constructor), and the
-    command-specific options that became attributes of each command
-    object.
-    """
-
-    global _setup_stop_after, _setup_distribution
-
-    # Determine the distribution class -- either caller-supplied or
-    # our Distribution (see below).
-    distclass = attrs.pop('distclass', Distribution)
-
-    if 'script_name' not in attrs:
-        attrs['script_name'] = os.path.basename(sys.argv[0])
-    if 'script_args' not in attrs:
-        attrs['script_args'] = sys.argv[1:]
-
-    # Create the Distribution instance, using the remaining arguments
-    # (ie. everything except distclass) to initialize it
-    try:
-        _setup_distribution = dist = distclass(attrs)
-    except DistutilsSetupError, msg:
-        if 'name' in attrs:
-            raise SystemExit, "error in %s setup command: %s" % \
-                  (attrs['name'], msg)
-        else:
-            raise SystemExit, "error in setup command: %s" % msg
-
-    if _setup_stop_after == "init":
-        return dist
-
-    # Find and parse the config file(s): they will override options from
-    # the setup script, but be overridden by the command line.
-    dist.parse_config_files()
-
-    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.
-    try:
-        ok = dist.parse_command_line()
-    except DistutilsArgError, msg:
-        raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
-
-    if _setup_stop_after == "commandline":
-        return dist
-
-    # And finally, run all the commands found on the command line.
-    if ok:
-        try:
-            dist.run_commands()
-        except KeyboardInterrupt:
-            raise SystemExit, "interrupted"
-        except (IOError, os.error), exc:
-            error = grok_environment_error(exc)
-            raise SystemExit, error
-
-        except (DistutilsError,
-                CCompilerError), msg:
-            raise SystemExit, "error: " + str(msg)
-
-    return dist
-
-
-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 metadata (passed as
-    keyword args from 'script' to 'setup()', or the contents of the
-    config files or command line.
-
-    'script_name' is a file that will be run with 'execfile()';
-    'sys.argv[0]' will be replaced with 'script' for the duration of the
-    call.  'script_args' is a list of strings; if supplied,
-    'sys.argv[1:]' will be replaced by 'script_args' for the duration of
-    the call.
-
-    'stop_after' tells 'setup()' when to stop processing; possible
-    values:
-      init
-        stop after the Distribution instance has been created and
-        populated with the keyword arguments to 'setup()'
-      config
-        stop after config files have been parsed (and their data
-        stored in the Distribution instance)
-      commandline
-        stop after the command line ('sys.argv[1:]' or 'script_args')
-        has been parsed (and the data stored in the Distribution)
-      run [default]
-        stop after all commands have been run (the same as if 'setup()'
-        had been called in the usual way
-
-    Returns the Distribution instance, which provides all information
-    used to drive the Distutils.
-    """
-    if stop_after not in ('init', 'config', 'commandline', 'run'):
-        raise ValueError, "invalid value for 'stop_after': %r" % (stop_after,)
-
-    global _setup_stop_after, _setup_distribution
-    _setup_stop_after = stop_after
-
-    save_argv = sys.argv
-    g = {'__file__': script_name}
-    l = {}
-    try:
-        try:
-            if script_args is not None:
-                sys.argv = [script_name] + script_args
-            else:
-                sys.argv = [script_name]
-            exec open(script_name, 'r').read() in g, l
-        finally:
-            sys.argv = save_argv
-            _setup_stop_after = None
-    except SystemExit:
-        # Hmm, should we do something if exiting with a non-zero code
-        # (ie. error)?
-        pass
-
-    if _setup_distribution is None:
-        raise RuntimeError, \
-              ("'distutils2.core.setup()' was never called -- "
-               "perhaps '%s' is not a Distutils setup script?") % \
-              script_name
-
-    # I wonder if the setup script's namespace -- g and l -- would be of
-    # any interest to callers?
-    return _setup_distribution
diff --git a/distutils2/dist.py b/distutils2/dist.py
--- a/distutils2/dist.py
+++ b/distutils2/dist.py
@@ -36,7 +36,7 @@
     Distribution for some specialized purpose, and then pass the subclass
     to 'setup()' as the 'distclass' keyword argument.  If so, it is
     necessary to respect the expectations that 'setup' has of Distribution.
-    See the code for 'setup()', in core.py, for details.
+    See the code for 'setup()', in run.py, for details.
     """
 
     # 'global_options' describes the command-line options that may be
@@ -322,7 +322,7 @@
     def parse_command_line(self):
         """Parse the setup script's command line, taken from the
         'script_args' instance attribute (which defaults to 'sys.argv[1:]'
-        -- see 'setup()' in core.py).  This list is first processed for
+        -- see 'setup()' in run.py).  This list is first processed for
         "global options" -- options that set attributes of the Distribution
         instance.  Then, it is alternately scanned for Distutils commands
         and options for that command.  Each new command terminates the
@@ -517,7 +517,7 @@
         in 'commands'.
         """
         # late import because of mutual dependence between these modules
-        from distutils2.core import gen_usage
+        from distutils2.run import gen_usage
         from distutils2.command.cmd import Command
 
         if global_options:
@@ -558,7 +558,7 @@
         line, display the requested info and return true; else return
         false.
         """
-        from distutils2.core import gen_usage
+        from distutils2.run import gen_usage
 
         # User just wants a list of commands -- we'll print it out and stop
         # processing now (ie. if they ran "setup --help-commands foo bar",
diff --git a/distutils2/run.py b/distutils2/run.py
--- a/distutils2/run.py
+++ b/distutils2/run.py
@@ -1,4 +1,109 @@
-from distutils2.core import setup
+import os
+import sys
+
+from distutils2.util import grok_environment_error
+from distutils2.errors import (DistutilsSetupError, DistutilsArgError,
+                               DistutilsError, CCompilerError)
+from distutils2.dist import Distribution
+
+# This is a barebones help message generated displayed when the user
+# runs the setup script with no arguments at all.  More useful help
+# is generated with various --help options: global help, list commands,
+# and per-command help.
+USAGE = """\
+usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
+   or: %(script)s --help [cmd1 cmd2 ...]
+   or: %(script)s --help-commands
+   or: %(script)s cmd --help
+"""
+
+
+def gen_usage(script_name):
+    script = os.path.basename(script_name)
+    return USAGE % {'script': script}
+
+
+def main(**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
+    line; run each Distutils command found there, customized by the options
+    supplied to 'setup()' (as keyword arguments), in config files, and on
+    the command line.
+
+    The Distribution instance might be an instance of a class supplied via
+    the 'distclass' keyword argument to 'setup'; if no such class is
+    supplied, then the Distribution class (in dist.py) is instantiated.
+    All other arguments to 'setup' (except for 'cmdclass') are used to set
+    attributes of the Distribution instance.
+
+    The 'cmdclass' argument, if supplied, is a dictionary mapping command
+    names to command classes.  Each command encountered on the command line
+    will be turned into a command class, which is in turn instantiated; any
+    class found in 'cmdclass' is used in place of the default, which is
+    (for command 'foo_bar') class 'foo_bar' in module
+    'distutils2.command.foo_bar'.  The command class must provide a
+    'user_options' attribute which is a list of option specifiers for
+    'distutils2.fancy_getopt'.  Any command-line options between the current
+    and the next command are used to set attributes of the current command
+    object.
+
+    When the entire command line has been successfully parsed, calls the
+    'run()' method on each command object in turn.  This method will be
+    driven entirely by the Distribution object (which each command object
+    has a reference to, thanks to its constructor), and the
+    command-specific options that became attributes of each command
+    object.
+    """
+    # Determine the distribution class -- either caller-supplied or
+    # our Distribution (see below).
+    distclass = attrs.pop('distclass', Distribution)
+
+    if 'script_name' not in attrs:
+        attrs['script_name'] = os.path.basename(sys.argv[0])
+
+    if 'script_args' not in attrs:
+        attrs['script_args'] = sys.argv[1:]
+
+    # Create the Distribution instance, using the remaining arguments
+    # (ie. everything except distclass) to initialize it
+    try:
+        dist = distclass(attrs)
+    except DistutilsSetupError, msg:
+        if 'name' in attrs:
+            raise SystemExit, "error in %s setup command: %s" % \
+                  (attrs['name'], msg)
+        else:
+            raise SystemExit, "error in setup command: %s" % msg
+
+    # Find and parse the config file(s): they will override options from
+    # the setup script, but be overridden by the command line.
+    dist.parse_config_files()
+
+    # 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.
+    try:
+        res = dist.parse_command_line()
+    except DistutilsArgError, msg:
+        raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
+
+    # And finally, run all the commands found on the command line.
+    if res:
+        try:
+            dist.run_commands()
+        except KeyboardInterrupt:
+            raise SystemExit, "interrupted"
+        except (IOError, os.error), exc:
+            error = grok_environment_error(exc)
+            raise SystemExit, error
+
+        except (DistutilsError,
+                CCompilerError), msg:
+            raise SystemExit, "error: " + str(msg)
+
+    return dist
+
 
 if __name__ == '__main__':
-    setup()
+    main()
diff --git a/distutils2/tests/test_command_bdist_dumb.py b/distutils2/tests/test_command_bdist_dumb.py
--- a/distutils2/tests/test_command_bdist_dumb.py
+++ b/distutils2/tests/test_command_bdist_dumb.py
@@ -12,12 +12,12 @@
 
 from distutils2.tests import run_unittest, unittest
 
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 from distutils2.command.bdist_dumb import bdist_dumb
 from distutils2.tests import support
 
 SETUP_PY = """\
-from distutils.core import setup
+from distutils.run import setup
 import foo
 
 setup(name='foo', version='0.1', py_modules=['foo'],
diff --git a/distutils2/tests/test_command_build_ext.py b/distutils2/tests/test_command_build_ext.py
--- a/distutils2/tests/test_command_build_ext.py
+++ b/distutils2/tests/test_command_build_ext.py
@@ -5,7 +5,8 @@
 
 import distutils2.tests
 from distutils2.tests import unittest
-from distutils2.core import Extension, Distribution
+from distutils2.extension import Extension
+from distutils2.dist import Distribution
 from distutils2.command.build_ext import build_ext
 from distutils2.tests import support
 from distutils2.extension import Extension
diff --git a/distutils2/tests/test_command_build_py.py b/distutils2/tests/test_command_build_py.py
--- a/distutils2/tests/test_command_build_py.py
+++ b/distutils2/tests/test_command_build_py.py
@@ -5,7 +5,7 @@
 import StringIO
 
 from distutils2.command.build_py import build_py
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 from distutils2.errors import DistutilsFileError
 
 from distutils2.tests import unittest, support
diff --git a/distutils2/tests/test_command_build_scripts.py b/distutils2/tests/test_command_build_scripts.py
--- a/distutils2/tests/test_command_build_scripts.py
+++ b/distutils2/tests/test_command_build_scripts.py
@@ -3,7 +3,7 @@
 import os
 
 from distutils2.command.build_scripts import build_scripts
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 try:
     import sysconfig
 except ImportError:
diff --git a/distutils2/tests/test_command_install_dist.py b/distutils2/tests/test_command_install_dist.py
--- a/distutils2/tests/test_command_install_dist.py
+++ b/distutils2/tests/test_command_install_dist.py
@@ -14,7 +14,7 @@
 
 from distutils2.command.install_dist import install_dist
 from distutils2.command import install_dist as install_module
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 from distutils2.errors import DistutilsOptionError
 
 from distutils2.tests import unittest, support
diff --git a/distutils2/tests/test_command_install_distinfo.py b/distutils2/tests/test_command_install_distinfo.py
--- a/distutils2/tests/test_command_install_distinfo.py
+++ b/distutils2/tests/test_command_install_distinfo.py
@@ -5,7 +5,7 @@
 import csv
 
 from distutils2.command.install_distinfo import install_distinfo
-from distutils2.core import Command
+from distutils2.command.cmd import Command
 from distutils2.metadata import DistributionMetadata
 from distutils2.tests import unittest, support
 
diff --git a/distutils2/tests/test_command_install_scripts.py b/distutils2/tests/test_command_install_scripts.py
--- a/distutils2/tests/test_command_install_scripts.py
+++ b/distutils2/tests/test_command_install_scripts.py
@@ -3,7 +3,7 @@
 import os
 
 from distutils2.command.install_scripts import install_scripts
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 
 from distutils2.tests import unittest, support
 
diff --git a/distutils2/tests/test_command_register.py b/distutils2/tests/test_command_register.py
--- a/distutils2/tests/test_command_register.py
+++ b/distutils2/tests/test_command_register.py
@@ -13,7 +13,7 @@
 
 from distutils2.command import register as register_module
 from distutils2.command.register import register
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 from distutils2.errors import DistutilsSetupError
 
 from distutils2.tests import unittest, support
diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py
--- a/distutils2/tests/test_command_sdist.py
+++ b/distutils2/tests/test_command_sdist.py
@@ -25,7 +25,7 @@
 
 from distutils2.command.sdist import sdist
 from distutils2.command.sdist import show_formats
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 from distutils2.tests import unittest
 from distutils2.errors import DistutilsExecError, DistutilsOptionError
 from distutils2.util import find_executable
diff --git a/distutils2/tests/test_command_upload.py b/distutils2/tests/test_command_upload.py
--- a/distutils2/tests/test_command_upload.py
+++ b/distutils2/tests/test_command_upload.py
@@ -4,7 +4,7 @@
 import sys
 
 from distutils2.command.upload import upload
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 
 from distutils2.tests import unittest, support
 from distutils2.tests.pypi_server import PyPIServer, PyPIServerTestCase
@@ -128,7 +128,7 @@
         handler, request_data = self.pypi.requests[-1]
         action, name, content =\
             request_data.split("----------------GHSKFJDLGDS7543FJKLFHRE75642756743254")[1:4]
-        
+
         self.assertIn('name=":action"', action)
         self.assertIn("doc_upload", action)
 
diff --git a/distutils2/tests/test_command_upload_docs.py b/distutils2/tests/test_command_upload_docs.py
--- a/distutils2/tests/test_command_upload_docs.py
+++ b/distutils2/tests/test_command_upload_docs.py
@@ -13,7 +13,7 @@
 from distutils2.command import upload_docs as upload_docs_mod
 from distutils2.command.upload_docs import (upload_docs, zip_dir,
                                             encode_multipart)
-from distutils2.core import Distribution
+from distutils2.dist import Distribution
 from distutils2.errors import DistutilsFileError, DistutilsOptionError
 
 from distutils2.tests import unittest, support
diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py
--- a/distutils2/tests/test_config.py
+++ b/distutils2/tests/test_config.py
@@ -109,8 +109,8 @@
         sys.argv[:] = ['setup.py', '--version']
         old_sys = sys.argv[:]
         try:
-            from distutils2.core import setup
-            dist = setup()
+            from distutils2.run import main
+            dist = main()
         finally:
             sys.argv[:] = old_sys
 
diff --git a/distutils2/tests/test_core.py b/distutils2/tests/test_run.py
rename from distutils2/tests/test_core.py
rename to distutils2/tests/test_run.py
--- a/distutils2/tests/test_core.py
+++ b/distutils2/tests/test_run.py
@@ -1,10 +1,11 @@
-"""Tests for distutils2.core."""
+"""Tests for distutils2.run."""
 
 import StringIO
-import distutils2.core
 import os
 import shutil
 import sys
+
+import distutils2
 from distutils2.tests import captured_stdout
 from distutils2.tests import unittest, support
 
@@ -13,7 +14,7 @@
 
 __file__
 
-from distutils2.core import setup
+from distutils2.run import setup
 setup()
 """
 
@@ -22,7 +23,7 @@
 import os
 print os.getcwd()
 
-from distutils2.core import setup
+from distutils2.run import setup
 setup()
 """
 
@@ -53,43 +54,6 @@
         open(path, "w").write(text)
         return path
 
-    def test_run_setup_provides_file(self):
-        # Make sure the script can use __file__; if that's missing, the test
-        # setup.py script will raise NameError.
-        distutils2.core.run_setup(
-            self.write_setup(setup_using___file__))
-
-    def test_run_setup_stop_after(self):
-        f = self.write_setup(setup_using___file__)
-        for s in ['init', 'config', 'commandline', 'run']:
-            distutils2.core.run_setup(f, stop_after=s)
-        self.assertRaises(ValueError, distutils2.core.run_setup,
-                          f, stop_after='bob')
-
-    def test_run_setup_args(self):
-        f = self.write_setup(setup_using___file__)
-        d = distutils2.core.run_setup(f, script_args=["--help"],
-                                      stop_after="init")
-        self.assertEqual(['--help'], d.script_args)
-
-    def test_run_setup_uses_current_dir(self):
-        # This tests that the setup script is run with the current directory
-        # as its own current directory; this was temporarily broken by a
-        # previous patch when TESTFN did not use the current directory.
-        sys.stdout = StringIO.StringIO()
-        cwd = os.getcwd()
-
-        # Create a directory and write the setup.py file there:
-        os.mkdir(distutils2.tests.TESTFN)
-        setup_py = os.path.join(distutils2.tests.TESTFN, "setup.py")
-        distutils2.core.run_setup(
-            self.write_setup(setup_prints_cwd, path=setup_py))
-
-        output = sys.stdout.getvalue()
-        if output.endswith("\n"):
-            output = output[:-1]
-        self.assertEqual(cwd, output)
-
 def test_suite():
     return unittest.makeSuite(CoreTestCase)
 
diff --git a/distutils2/tests/test_test.py b/distutils2/tests/test_test.py
--- a/distutils2/tests/test_test.py
+++ b/distutils2/tests/test_test.py
@@ -8,7 +8,8 @@
 from os.path import join
 from operator import getitem, setitem, delitem
 from StringIO import StringIO
-from distutils2.core import Command
+
+from distutils2.command.cmd import Command
 from distutils2.tests import unittest
 from distutils2.tests.support import TempdirManager, LoggingCatcher
 from distutils2.command.test import test

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


More information about the Python-checkins mailing list