[Python-checkins] python/nondist/sandbox/setuptools/setuptools __init__.py, 1.9, 1.10 dist.py, 1.7, 1.8 package_index.py, 1.7, 1.8
pje@users.sourceforge.net
pje at users.sourceforge.net
Mon Jun 27 02:31:05 CEST 2005
- Previous message: [Python-checkins] python/nondist/sandbox/setuptools EasyInstall.txt, 1.15, 1.16 easy_install.py, 1.23, 1.24 ez_setup.py, 1.6, 1.7 pkg_resources.py, 1.34, 1.35 setup.py, 1.16, 1.17
- Next message: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.18, 1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15697/setuptools
Modified Files:
__init__.py dist.py package_index.py
Log Message:
EasyInstall/setuptools 0.5a4: significant new features, including automatic
installation of dependencies, the ability to specify dependencies in a
setup script, and several new options to control EasyInstall's behavior.
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/__init__.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- __init__.py 25 Jun 2005 19:33:06 -0000 1.9
+++ __init__.py 27 Jun 2005 00:31:02 -0000 1.10
@@ -8,7 +8,7 @@
from distutils.util import convert_path
import os.path
-__version__ = '0.5a3'
+__version__ = '0.5a4'
__all__ = [
'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
Index: dist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/dist.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dist.py 15 Jun 2005 02:19:42 -0000 1.7
+++ dist.py 27 Jun 2005 00:31:02 -0000 1.8
@@ -8,50 +8,44 @@
from setuptools.command.install_lib import install_lib
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError
-import setuptools
+import setuptools, pkg_resources
sequence = tuple, list
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
class Distribution(_Distribution):
"""Distribution with support for features, tests, and package data
This is an enhanced version of 'distutils.dist.Distribution' that
effectively adds the following new optional keyword arguments to 'setup()':
+ 'install_requires' -- a string or sequence of strings specifying project
+ versions that the distribution requires when installed, in the format
+ used by 'pkg_resources.require()'. They will be installed
+ automatically when the package is installed. If you wish to use
+ packages that are not available in PyPI, or want to give your users an
+ alternate download location, you can add a 'find_links' option to the
+ '[easy_install]' section of your project's 'setup.cfg' file, and then
+ setuptools will scan the listed web pages for links that satisfy the
+ requirements.
+
+ 'extras_require' -- a dictionary mapping names of optional "extras" to the
+ additional requirement(s) that using those extras incurs. For example,
+ this::
+
+ extras_require = dict(reST = ["docutils>=0.3", "reSTedit"])
+
+ indicates that the distribution can optionally provide an extra
+ capability called "reST", but it can only be used if docutils and
+ reSTedit are installed. If the user installs your package using
+ EasyInstall and requests one of your extras, the corresponding
+ additional requirements will be installed if needed.
+
'features' -- a dictionary mapping option names to 'setuptools.Feature'
objects. Features are a portion of the distribution that can be
included or excluded based on user options, inter-feature dependencies,
and availability on the current system. Excluded features are omitted
from all setup commands, including source and binary distributions, so
you can create multiple distributions from the same source tree.
-
Feature names should be valid Python identifiers, except that they may
contain the '-' (minus) sign. Features can be included or excluded
via the command line options '--with-X' and '--without-X', where 'X' is
@@ -84,6 +78,8 @@
the distribution. They are used by the feature subsystem to configure the
distribution for the included and excluded features.
"""
+
+
def __init__ (self, attrs=None):
have_package_data = hasattr(self, "package_data")
if not have_package_data:
@@ -91,16 +87,68 @@
self.features = {}
self.test_suite = None
self.requires = []
+ self.install_requires = []
+ self.extras_require = {}
_Distribution.__init__(self,attrs)
if not have_package_data:
from setuptools.command.build_py import build_py
self.cmdclass.setdefault('build_py',build_py)
+
self.cmdclass.setdefault('build_ext',build_ext)
self.cmdclass.setdefault('install',install)
self.cmdclass.setdefault('install_lib',install_lib)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def finalize_options(self):
+ _Distribution.finalize_options(self)
+
if self.features:
self._set_global_opts_from_features()
+ if self.extra_path:
+ raise DistutilsSetupError(
+ "The 'extra_path' parameter is not needed when using "
+ "setuptools. Please remove it from your setup script."
+ )
+ try:
+ list(pkg_resources.parse_requirements(self.install_requires))
+ except (TypeError,ValueError):
+ raise DistutilsSetupError(
+ "'install_requires' must be a string or list of strings "
+ "containing valid project/version requirement specifiers"
+ )
+ try:
+ for k,v in self.extras_require.items():
+ list(pkg_resources.parse_requirements(v))
+ except (TypeError,ValueError,AttributeError):
+ raise DistutilsSetupError(
+ "'extras_require' must be a dictionary whose values are "
+ "strings or lists of strings containing valid project/version "
+ "requirement specifiers."
+ )
+
def parse_command_line(self):
"""Process features after parsing command line options"""
result = _Distribution.parse_command_line(self)
@@ -108,19 +156,12 @@
self._finalize_features()
return result
+
def _feature_attrname(self,name):
"""Convert feature name to corresponding option attribute name"""
return 'with_'+name.replace('-','_')
-
-
-
-
-
-
-
-
def _set_global_opts_from_features(self):
"""Add --with-X/--without-X options based on optional features"""
@@ -343,29 +384,29 @@
return nargs
-
def has_dependencies(self):
return not not self.requires
-
def run_commands(self):
- if setuptools.bootstrap_install_from and 'install' in self.commands:
- # Bootstrap self-installation of setuptools
- from easy_install import easy_install
- cmd = easy_install(
- self, args=[setuptools.bootstrap_install_from], zip_ok=1
- )
- cmd.ensure_finalized()
- cmd.run()
- setuptools.bootstrap_install_from = None
-
- _Distribution.run_commands(self)
-
-
-
-
-
+ for cmd in self.commands:
+ if cmd=='install' and not cmd in self.have_run:
+ self.install_eggs()
+ else:
+ self.run_command(cmd)
+ def install_eggs(self):
+ from easy_install import easy_install
+ cmd = easy_install(self, args="x")
+ cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
+ self.run_command('bdist_egg')
+ args = [self.get_command_obj('bdist_egg').egg_output]
+ if setuptools.bootstrap_install_from:
+ # Bootstrap self-installation of setuptools
+ args.insert(0, setuptools.bootstrap_install_from)
+ cmd.args = args
+ cmd.run()
+ self.have_run['install'] = 1
+ setuptools.bootstrap_install_from = None
def get_cmdline_options(self):
"""Return a '{cmd: {opt:val}}' map of all command-line options
Index: package_index.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/package_index.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- package_index.py 25 Jun 2005 19:33:06 -0000 1.7
+++ package_index.py 27 Jun 2005 00:31:03 -0000 1.8
@@ -203,7 +203,7 @@
- def find_packages(self,requirement):
+ def find_packages(self, requirement):
self.scan_url(self.index_url + requirement.distname+'/')
if not self.package_pages.get(requirement.key):
# We couldn't find the target package, so search the index page too
@@ -221,13 +221,13 @@
# scan each page that might be related to the desired package
self.scan_url(url)
- def obtain(self,requirement):
+ def obtain(self, requirement, installer=None):
self.find_packages(requirement)
for dist in self.get(requirement.key, ()):
if dist in requirement:
return dist
self.debug("%s does not match %s", requirement, dist)
-
+ return super(PackageIndex, self).obtain(requirement,installer)
@@ -245,19 +245,20 @@
def download(self, spec, tmpdir):
- """Locate and/or download `spec`, returning a local filename
+ """Locate and/or download `spec` to `tmpdir`, returning a local path
`spec` may be a ``Requirement`` object, or a string containing a URL,
- an existing local filename, or a package/version requirement spec
+ an existing local filename, or a project/version requirement spec
(i.e. the string form of a ``Requirement`` object).
- If necessary, the requirement is searched for in the package index.
- If the download is successful, the return value is a local file path,
- and it is a subpath of `tmpdir` if the distribution had to be
- downloaded. If no matching distribution is found, return ``None``.
- Various errors may be raised if a problem occurs during downloading.
+ If `spec` is a ``Requirement`` object or a string containing a
+ project/version requirement spec, this method is equivalent to
+ the ``fetch()`` method. If `spec` is a local, existing file or
+ directory name, it is simply returned unchanged. If `spec` is a URL,
+ it is downloaded to a subpath of `tmpdir`, and the local filename is
+ returned. Various errors may be raised if a problem occurs during
+ downloading.
"""
-
if not isinstance(spec,Requirement):
scheme = URL_SCHEME(spec)
if scheme:
@@ -275,16 +276,56 @@
"Not a URL, existing file, or requirement spec: %r" %
(spec,)
)
+
+ return self.fetch(spec, tmpdir, force_scan)
+
+
+
+
+
+
+
+ def fetch(self, requirement, tmpdir, force_scan=False):
+ """Obtain a file suitable for fulfilling `requirement`
+
+ `requirement` must be a ``pkg_resources.Requirement`` instance.
+ If necessary, or if the `force_scan` flag is set, the requirement is
+ searched for in the (online) package index as well as the locally
+ installed packages. If a distribution matching `requirement` is found,
+ the return value is the same as if you had called the ``download()``
+ method with the matching distribution's URL. If no matching
+ distribution is found, returns ``None``.
+ """
+
# process a Requirement
- self.info("Searching for %s", spec)
- dist = self.best_match(spec,[])
+ self.info("Searching for %s", requirement)
+
+ if force_scan:
+ self.find_packages(requirement)
+
+ dist = self.best_match(requirement, []) # XXX
+
if dist is not None:
self.info("Best match: %s", dist)
return self.download(dist.path, tmpdir)
- self.warn("No local packages or download links found for %s", spec)
+ self.warn(
+ "No local packages or download links found for %s", requirement
+ )
return None
+
+
+
+
+
+
+
+
+
+
+
+
dl_blocksize = 8192
def _download_to(self, url, filename):
- Previous message: [Python-checkins] python/nondist/sandbox/setuptools EasyInstall.txt, 1.15, 1.16 easy_install.py, 1.23, 1.24 ez_setup.py, 1.6, 1.7 pkg_resources.py, 1.34, 1.35 setup.py, 1.16, 1.17
- Next message: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.18, 1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-checkins
mailing list