summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpje <pje@571e12c6-e1fa-0310-aee7-ff1267fa46bd>2004-03-10 00:41:56 +0000
committerpje <pje@571e12c6-e1fa-0310-aee7-ff1267fa46bd>2004-03-10 00:41:56 +0000
commit4a244bf842b51afb3f94078d1d629d33089750a8 (patch)
treeb01799f0072022d2620cc7a1cf1e728e20ac962d
parent097b7f1a823c7b800dbb0a624e56205fe926692e (diff)
downloadwsgiref-4a244bf842b51afb3f94078d1d629d33089750a8.tar.gz
Added skeleton 'depends' command, that will check/install dependencies.
git-svn-id: svn://svn.eby-sarna.com/svnroot/wsgiref@240 571e12c6-e1fa-0310-aee7-ff1267fa46bd
-rw-r--r--setuptools/__init__.py5
-rw-r--r--setuptools/command/__init__.py2
-rw-r--r--setuptools/command/depends.py27
-rw-r--r--setuptools/command/install.py11
-rw-r--r--setuptools/command/test.py2
-rw-r--r--setuptools/dist.py10
-rw-r--r--setuptools/tests/__init__.py26
7 files changed, 62 insertions, 21 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py
index 576d353..009eced 100644
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -3,12 +3,15 @@
import distutils.core, setuptools.command
from setuptools.dist import Distribution, Feature
from setuptools.extension import Extension
+from setuptools.depends import Require
from distutils.core import Command
from distutils.util import convert_path
import os.path
+
__all__ = [
- 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'find_packages'
+ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
+ 'find_packages'
]
diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py
index a7e3c3d..3429634 100644
--- a/setuptools/command/__init__.py
+++ b/setuptools/command/__init__.py
@@ -1,6 +1,6 @@
import distutils.command
-__all__ = [] # XXX 'happy', 'test', 'install_pkg_data'
+__all__ = ['test', 'depends']
# Make our commands available as though they were part of the distutils
diff --git a/setuptools/command/depends.py b/setuptools/command/depends.py
new file mode 100644
index 0000000..e149fac
--- /dev/null
+++ b/setuptools/command/depends.py
@@ -0,0 +1,27 @@
+from distutils.cmd import Command
+import os
+
+class depends(Command):
+ """Download and install dependencies, if needed"""
+
+ description = "download and install dependencies, if needed"
+
+ user_options = [
+ ('temp=', 't',
+ "directory where dependencies will be downloaded and built"),
+ ('ignore-extra-args', 'i',
+ "ignore options that won't be passed to child setup scripts"),
+ ]
+
+ def initialize_options(self):
+ self.temp = None
+ self.install_purelib = self.install_platlib = None
+ self.install_lib = self.install_libbase = None
+ self.install_scripts = self.install_data = self.install_headers = None
+ self.compiler = self.debug = self.force = None
+
+ def finalize_options(self):
+ self.set_undefined_options('build',('build_temp', 'temp'))
+
+ def run(self):
+ self.announce("downloading and building here")
diff --git a/setuptools/command/install.py b/setuptools/command/install.py
new file mode 100644
index 0000000..82e7ebe
--- /dev/null
+++ b/setuptools/command/install.py
@@ -0,0 +1,11 @@
+from distutils.command.install import install as _install
+
+class install(_install):
+ """Build dependencies before installation"""
+
+ def has_dependencies(self):
+ return self.distribution.has_dependencies()
+
+ sub_commands = [('depends',has_dependencies)] + _install.sub_commands
+
+
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
index 4a6cd25..6b37a9f 100644
--- a/setuptools/command/test.py
+++ b/setuptools/command/test.py
@@ -6,7 +6,7 @@ class test(Command):
"""Command to run unit tests after installation"""
- description = "Run unit tests after installation"
+ description = "run unit tests after installation"
user_options = [
('test-module=','m', "Run 'test_suite' in specified module"),
diff --git a/setuptools/dist.py b/setuptools/dist.py
index bed32e8..266e422 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -4,6 +4,7 @@ from distutils.core import Distribution as _Distribution
from distutils.core import Extension
from setuptools.command.build_py import build_py
from setuptools.command.build_ext import build_ext
+from setuptools.command.install import install
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError
sequence = tuple, list
@@ -59,15 +60,15 @@ class Distribution(_Distribution):
self.features = {}
self.package_data = {}
self.test_suite = None
-
+ self.requires = []
_Distribution.__init__(self,attrs)
self.cmdclass.setdefault('build_py',build_py)
self.cmdclass.setdefault('build_ext',build_ext)
+ self.cmdclass.setdefault('install',install)
if self.features:
self._set_global_opts_from_features()
-
def parse_command_line(self):
"""Process features after parsing command line options"""
result = _Distribution.parse_command_line(self)
@@ -75,7 +76,6 @@ class Distribution(_Distribution):
self._finalize_features()
return result
-
def _feature_attrname(self,name):
"""Convert feature name to corresponding option attribute name"""
return 'with_'+name.replace('-','_')
@@ -267,7 +267,6 @@ class Distribution(_Distribution):
else:
self._exclude_misc(k,v)
-
def _exclude_packages(self,packages):
if not isinstance(packages,sequence):
raise DistutilsSetupError(
@@ -275,13 +274,14 @@ class Distribution(_Distribution):
)
map(self.exclude_package, packages)
-
def _parse_command_opts(self, parser, args):
# Remove --with-X/--without-X options when processing command args
self.global_options = self.__class__.global_options
self.negative_opt = self.__class__.negative_opt
return _Distribution._parse_command_opts(self, parser, args)
+ def has_dependencies(self):
+ return not not self.requires
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index 186310d..662d4ec 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -15,7 +15,12 @@ import sys, os.path
def makeSetup(**args):
"""Return distribution from 'setup(**args)', without executing commands"""
+
distutils.core._setup_stop_after = "commandline"
+
+ # Don't let system command line leak into tests!
+ args.setdefault('script_args',['install'])
+
try:
return setuptools.setup(**args)
finally:
@@ -34,11 +39,6 @@ def makeSetup(**args):
-
-
-
-
-
class DependsTests(TestCase):
def testExtractConst(self):
@@ -80,6 +80,14 @@ class DependsTests(TestCase):
get_module_constant('setuptools.tests','__doc__'),__doc__
)
+ def testDependsCmd(self):
+ dist = makeSetup()
+ cmd = dist.get_command_obj('depends')
+ cmd.ensure_finalized()
+ self.assertEqual(cmd.temp, dist.get_command_obj('build').build_temp)
+ self.assertEqual(cmd.install_lib, dist.get_command_obj('install').install_lib)
+
+
def testRequire(self):
req = Require('Distutils','1.0.3','distutils')
@@ -113,14 +121,6 @@ class DependsTests(TestCase):
-
-
-
-
-
-
-
-
class DistroTests(TestCase):
def setUp(self):