diff options
author | PJ Eby <distutils-sig@python.org> | 2005-11-19 20:38:40 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-11-19 20:38:40 +0000 |
commit | 016ae6c42a868bc36c950cd3dc04e75b6ecce7dc (patch) | |
tree | 72fb86d76ad349a9a7bff41e2a5caddbccf9df33 | |
parent | 1c5aaf1332c6c00139883eeffe44c563737176ae (diff) | |
download | external_python_setuptools-016ae6c42a868bc36c950cd3dc04e75b6ecce7dc.tar.gz external_python_setuptools-016ae6c42a868bc36c950cd3dc04e75b6ecce7dc.tar.bz2 external_python_setuptools-016ae6c42a868bc36c950cd3dc04e75b6ecce7dc.zip |
Added ``tests_require`` keyword to ``setup()``, so that e.g. packages
requiring ``nose`` to run unit tests can make this dependency optional
unless the ``test`` command is run.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041483
-rwxr-xr-x | setup.py | 28 | ||||
-rwxr-xr-x | setuptools.egg-info/entry_points.txt | 3 | ||||
-rwxr-xr-x | setuptools.txt | 22 | ||||
-rw-r--r-- | setuptools/command/test.py | 8 | ||||
-rw-r--r-- | setuptools/dist.py | 6 |
5 files changed, 42 insertions, 25 deletions
@@ -40,6 +40,7 @@ setup( py_modules = ['pkg_resources', 'easy_install', 'site'], zip_safe = False, # We want 'python -m easy_install' to work, for now :( + entry_points = { "distutils.commands" : [ "%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals() @@ -49,7 +50,8 @@ setup( "eager_resources = setuptools.dist:assert_string_list", "namespace_packages = setuptools.dist:check_nsp", "extras_require = setuptools.dist:check_extras", - "install_requires = setuptools.dist:check_install_requires", + "install_requires = setuptools.dist:check_requirements", + "tests_require = setuptools.dist:check_requirements", "entry_points = setuptools.dist:check_entry_points", "test_suite = setuptools.dist:check_test_suite", "zip_safe = setuptools.dist:assert_bool", @@ -67,6 +69,17 @@ setup( "console_scripts": ["easy_install = setuptools.command.easy_install:main"], }, + + + + + + + + + + + classifiers = [f.strip() for f in """ Development Status :: 3 - Alpha Intended Audience :: Developers @@ -108,16 +121,3 @@ setup( - - - - - - - - - - - - - diff --git a/setuptools.egg-info/entry_points.txt b/setuptools.egg-info/entry_points.txt index 87174d8c..34796831 100755 --- a/setuptools.egg-info/entry_points.txt +++ b/setuptools.egg-info/entry_points.txt @@ -1,12 +1,13 @@ [distutils.setup_keywords] entry_points = setuptools.dist:check_entry_points extras_require = setuptools.dist:check_extras -install_requires = setuptools.dist:check_install_requires +install_requires = setuptools.dist:check_requirements include_package_data = setuptools.dist:assert_bool namespace_packages = setuptools.dist:check_nsp test_suite = setuptools.dist:check_test_suite eager_resources = setuptools.dist:assert_string_list zip_safe = setuptools.dist:assert_bool +tests_require = setuptools.dist:check_requirements [egg_info.writers] requires.txt = setuptools.command.egg_info:write_requirements diff --git a/setuptools.txt b/setuptools.txt index 82ee5acd..69323d5b 100755 --- a/setuptools.txt +++ b/setuptools.txt @@ -355,6 +355,17 @@ unless you need the associated ``setuptools`` feature. specified test suite, e.g. via ``setup.py test``. See the section on the `test`_ command below for more details. +``tests_require`` + If your project's tests need one or more additional packages besides those + needed to install it, you can use this option to specify them. It should + be a string or list of strings specifying what other distributions need to + be present for the package's tests to run. When you run the ``test`` + command, ``setuptools`` will attempt to obtain these (even going + so far as to download them using ``EasyInstall``). Note that these + required projects will *not* be installed on the system where the tests + are run, but only downloaded to the project's setup directory if they're + not already installed locally. + ``eager_resources`` A list of strings naming resources that should be extracted together, if any of them is needed, or if any C extensions included in the project are @@ -1996,7 +2007,7 @@ Adding ``setup()`` Arguments ---------------------------- Sometimes, your commands may need additional arguments to the ``setup()`` -script. You can enable this by defining entry points in the +call. You can enable this by defining entry points in the ``distutils.setup_keywords`` group. For example, if you wanted a ``setup()`` argument called ``bar_baz``, you might add something like this to your distutils extension project's setup script:: @@ -2041,8 +2052,9 @@ what values of that argument are valid. Also note that as with commands, it is not necessary to subclass or monkeypatch the distutils ``Distribution`` class in order to add your arguments; it is -sufficient to define the entry points in your extension, as long as the setup -script lists your extension in its ``setup_requires`` argument. +sufficient to define the entry points in your extension, as long as any setup +script using your extension lists your project in its ``setup_requires`` +argument. Adding new EGG-INFO Files @@ -2157,6 +2169,10 @@ Release Notes/Change History * Added warning for namespace packages with missing ``declare_namespace()`` + * Added ``tests_require`` keyword to ``setup()``, so that e.g. packages + requiring ``nose`` to run unit tests can make this dependency optional + unless the ``test`` command is run. + 0.6a8 * Fixed some problems building extensions when Pyrex was installed, especially with Python 2.4 and/or packages using SWIG. diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 200d255d..31f1ae40 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -47,6 +47,9 @@ class test(Command): self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') + if self.distribution.tests_require: + self.distribution.fetch_build_eggs(self.distribution.tests_require) + if self.test_suite: cmd = ' '.join(self.test_args) if self.dry_run: @@ -55,6 +58,7 @@ class test(Command): self.announce('running "unittest %s"' % cmd) self.run_tests() + def run_tests(self): import unittest old_path = sys.path[:] @@ -76,7 +80,3 @@ class test(Command): - - - - diff --git a/setuptools/dist.py b/setuptools/dist.py index f0ad6f8b..17c9f149 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -80,14 +80,14 @@ def assert_bool(dist, attr, value): -def check_install_requires(dist, attr, value): +def check_requirements(dist, attr, value): """Verify that install_requires is a valid requirements list""" try: list(pkg_resources.parse_requirements(value)) except (TypeError,ValueError): raise DistutilsSetupError( - "'install_requires' must be a string or list of strings " - "containing valid project/version requirement specifiers" + "%r must be a string or list of strings " + "containing valid project/version requirement specifiers" % (attr,) ) def check_entry_points(dist, attr, value): |