aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-07-10 15:43:08 +0000
committerPJ Eby <distutils-sig@python.org>2005-07-10 15:43:08 +0000
commit39fc2a15c4a236ae7b378ebb98aee545776d2ec1 (patch)
treec8806db2eb70d3620795df65425a0ca53d1f648d /setuptools
parent7922a815d08c4a5ac975e785aad90c3f4c6eaabb (diff)
downloadexternal_python_setuptools-39fc2a15c4a236ae7b378ebb98aee545776d2ec1.tar.gz
external_python_setuptools-39fc2a15c4a236ae7b378ebb98aee545776d2ec1.tar.bz2
external_python_setuptools-39fc2a15c4a236ae7b378ebb98aee545776d2ec1.zip
Implement ``namespace_packages`` keyword to ``setup()``. Added keyword
summary to setuptools doc. Begin work on ``zip_safe`` flag. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041113
Diffstat (limited to 'setuptools')
-rwxr-xr-xsetuptools/command/easy_install.py4
-rwxr-xr-xsetuptools/command/egg_info.py69
-rw-r--r--setuptools/dist.py93
3 files changed, 124 insertions, 42 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index e089cedb..b80dcb8d 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -21,7 +21,7 @@ from distutils.errors import DistutilsArgError, DistutilsOptionError, DistutilsE
from setuptools.archive_util import unpack_archive
from setuptools.package_index import PackageIndex, parse_bdist_wininst
from setuptools.package_index import URL_SCHEME
-from setuptools.command import bdist_egg
+from setuptools.command import bdist_egg, egg_info
from pkg_resources import *
__all__ = [
@@ -697,6 +697,7 @@ PYTHONPATH, or by being added to sys.path by your code.)
def build_and_install(self, setup_script, setup_base, zip_ok):
sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
+ sys.modules.setdefault('distutils.command.bdist_egg', egg_info)
args = ['bdist_egg', '--dist-dir']
if self.verbose>2:
@@ -735,7 +736,6 @@ PYTHONPATH, or by being added to sys.path by your code.)
shutil.rmtree(dist_dir)
log.set_verbosity(self.verbose) # restore our log verbosity
-
def update_pth(self,dist):
if self.pth_file is None:
return
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index dca4e2a3..68e2fefb 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -9,7 +9,7 @@ from distutils.errors import *
from distutils import log
from pkg_resources import parse_requirements, safe_name, \
safe_version, yield_lines
-
+from setuptools.dist import iter_distribution_names
class egg_info(Command):
@@ -83,8 +83,8 @@ class egg_info(Command):
def run(self):
# Make the .egg-info directory, then write PKG-INFO and requires.txt
self.mkpath(self.egg_info)
+ log.info("writing %s" % os.path.join(self.egg_info,'PKG-INFO'))
- log.info("writing %s" % os.path.join(self.egg_info,'PKG-INFO'))
if not self.dry_run:
metadata = self.distribution.metadata
metadata.version, oldver = self.egg_version, metadata.version
@@ -96,15 +96,16 @@ class egg_info(Command):
finally:
metadata.name, metadata.version = oldname, oldver
+ self.write_namespace_packages()
self.write_requirements()
self.write_toplevel_names()
+
if os.path.exists(os.path.join(self.egg_info,'depends.txt')):
log.warn(
"WARNING: 'depends.txt' will not be used by setuptools 0.6!\n"
"Use the install_requires/extras_require setup() args instead."
)
-
def write_requirements(self):
dist = self.distribution
if not getattr(dist,'install_requires',None) and \
@@ -120,7 +121,6 @@ class egg_info(Command):
f.write('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs))))
f.close()
-
def tagged_version(self):
version = self.distribution.get_version()
if self.tag_build:
@@ -144,16 +144,12 @@ class egg_info(Command):
def write_toplevel_names(self):
- pkgs = dict.fromkeys(self.distribution.packages or ())
- pkgs.update(dict.fromkeys(self.distribution.py_modules or ()))
- for ext in self.distribution.ext_modules or ():
- if isinstance(ext,tuple):
- name,buildinfo = ext
- else:
- name = ext.name
- pkgs[name]=1
- pkgs = dict.fromkeys([k.split('.',1)[0] for k in pkgs])
- toplevel = os.path.join(self.egg_info,"top_level.txt")
+ pkgs = dict.fromkeys(
+ [k.split('.',1)[0]
+ for k in iter_distribution_names(self.distribution)
+ ]
+ )
+ toplevel = os.path.join(self.egg_info, "top_level.txt")
log.info("writing list of top-level names to %s" % toplevel)
if not self.dry_run:
f = open(toplevel, 'wt')
@@ -162,3 +158,48 @@ class egg_info(Command):
f.close()
+
+
+
+
+ def write_namespace_packages(self):
+ nsp = getattr(self.distribution,'namespace_packages',None)
+ if nsp is None:
+ return
+
+ filename = os.path.join(self.egg_info,"namespace_packages.txt")
+
+ if nsp:
+ log.info("writing %s", filename)
+ if not self.dry_run:
+ f = open(filename, 'wt')
+ f.write('\n'.join(nsp))
+ f.write('\n')
+ f.close()
+
+ elif os.path.exists(filename):
+ log.info("deleting %s", filename)
+ if not self.dry_run:
+ os.unlink(filename)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setuptools/dist.py b/setuptools/dist.py
index 4fef454f..73627752 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -90,6 +90,8 @@ class Distribution(_Distribution):
self.install_requires = []
self.extras_require = {}
self.dist_files = []
+ self.zip_safe = None
+ self.namespace_packages = None
_Distribution.__init__(self,attrs)
if not have_package_data:
from setuptools.command.build_py import build_py
@@ -100,19 +102,17 @@ class Distribution(_Distribution):
self.cmdclass.setdefault('install_lib',install_lib)
self.cmdclass.setdefault('sdist',sdist)
+ def parse_command_line(self):
+ """Process features after parsing command line options"""
+ result = _Distribution.parse_command_line(self)
+ if self.features:
+ self._finalize_features()
+ return result
-
-
-
-
-
-
-
-
-
-
-
+ def _feature_attrname(self,name):
+ """Convert feature name to corresponding option attribute name"""
+ return 'with_'+name.replace('-','_')
@@ -123,10 +123,8 @@ class Distribution(_Distribution):
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 "
@@ -148,19 +146,21 @@ class Distribution(_Distribution):
"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)
- if self.features:
- self._finalize_features()
- return result
-
-
- def _feature_attrname(self,name):
- """Convert feature name to corresponding option attribute name"""
- return 'with_'+name.replace('-','_')
-
+ if self.namespace_packages is not None:
+ try:
+ assert ''.join(self.namespace_packages)!=self.namespace_packages
+ except (TypeError,ValueError,AttributeError,AssertionError):
+ raise DistutilsSetupError(
+ "'namespace_packages' must be a sequence of strings"
+ )
+ for nsp in self.namespace_packages:
+ for name in iter_distribution_names(self):
+ if name.startswith(nsp+'.'): break
+ else:
+ raise DistutilsSetupError(
+ "Distribution contains no modules or packages for " +
+ "namespace package %r" % nsp
+ )
def _set_global_opts_from_features(self):
"""Add --with-X/--without-X options based on optional features"""
@@ -490,6 +490,47 @@ class Distribution(_Distribution):
return d
+def iter_distribution_names(distribution):
+ """Yield all packages, modules, and extensions declared by distribution"""
+
+ for pkg in distribution.packages or ():
+ yield pkg
+
+ for module in distribution.py_modules or ():
+ yield module
+
+ for ext in distribution.ext_modules or ():
+ if isinstance(ext,tuple):
+ name,buildinfo = ext
+ yield name
+ else:
+ yield ext.name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
class Feature:
"""A subset of the distribution that can be excluded if unneeded/wanted