summaryrefslogtreecommitdiff
path: root/distutils2/command
diff options
context:
space:
mode:
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>2011-01-29 15:03:21 +0100
committerPierre-Yves David <pierre-yves.david@ens-lyon.org>2011-01-29 15:03:21 +0100
commite7f36053c06716a3c62deb43bb7a3d5ef98c21b8 (patch)
treecdaf232cd07cb5fcbbf80434e853c798abb16404 /distutils2/command
parente33e323e3c24ac46e5a4da7a62d1c2e83192b078 (diff)
parent7eaa6dfc487f946a775c5e72d7f7231420e76b23 (diff)
downloaddisutils2-e7f36053c06716a3c62deb43bb7a3d5ef98c21b8.tar.gz
merge with main branch
Diffstat (limited to 'distutils2/command')
-rw-r--r--distutils2/command/build_py.py46
-rw-r--r--distutils2/command/check.py2
-rw-r--r--distutils2/command/sdist.py38
3 files changed, 18 insertions, 68 deletions
diff --git a/distutils2/command/build_py.py b/distutils2/command/build_py.py
index c3e4878..0956fa8 100644
--- a/distutils2/command/build_py.py
+++ b/distutils2/command/build_py.py
@@ -66,10 +66,9 @@ class build_py(Command, Mixin2to3):
self.packages = self.distribution.packages
self.py_modules = self.distribution.py_modules
self.package_data = self.distribution.package_data
- self.package_dir = {}
- if self.distribution.package_dir:
- for name, path in self.distribution.package_dir.iteritems():
- self.package_dir[name] = convert_path(path)
+ self.package_dir = None
+ if self.distribution.package_dir is not None:
+ self.package_dir = convert_path(self.distribution.package_dir)
self.data_files = self.get_data_files()
# Ick, copied straight from install_lib.py (fancy_getopt needs a
@@ -179,41 +178,14 @@ class build_py(Command, Mixin2to3):
"""Return the directory, relative to the top of the source
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any)."""
-
path = package.split('.')
+ if self.package_dir is not None:
+ path.insert(0, self.package_dir)
- if not self.package_dir:
- if path:
- return os.path.join(*path)
- else:
- return ''
- else:
- tail = []
- while path:
- try:
- pdir = self.package_dir['.'.join(path)]
- except KeyError:
- tail.insert(0, path[-1])
- del path[-1]
- else:
- tail.insert(0, pdir)
- return os.path.join(*tail)
- else:
- # Oops, got all the way through 'path' without finding a
- # match in package_dir. If package_dir defines a directory
- # for the root (nameless) package, then fallback on it;
- # otherwise, we might as well have not consulted
- # package_dir at all, as we just use the directory implied
- # by 'tail' (which should be the same as the original value
- # of 'path' at this point).
- pdir = self.package_dir.get('')
- if pdir is not None:
- tail.insert(0, pdir)
-
- if tail:
- return os.path.join(*tail)
- else:
- return ''
+ if len(path) > 0:
+ return os.path.join(*path)
+
+ return ''
def check_package(self, package, package_dir):
"""Helper function for `find_package_modules()` and `find_modules()'.
diff --git a/distutils2/command/check.py b/distutils2/command/check.py
index d809416..5642f92 100644
--- a/distutils2/command/check.py
+++ b/distutils2/command/check.py
@@ -57,7 +57,7 @@ class check(Command):
Warns if any are missing.
"""
- missing, __ = self.distribution.metadata.check()
+ missing, __ = self.distribution.metadata.check(strict=True)
if missing != []:
self.warn("missing required metadata: %s" % ', '.join(missing))
diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py
index df8e07a..5aff9bd 100644
--- a/distutils2/command/sdist.py
+++ b/distutils2/command/sdist.py
@@ -18,7 +18,8 @@ except ImportError:
from distutils2.command import get_command_names
from distutils2.command.cmd import Command
from distutils2.errors import (DistutilsPlatformError, DistutilsOptionError,
- DistutilsTemplateError, DistutilsModuleError)
+ DistutilsTemplateError, DistutilsModuleError,
+ DistutilsFileError)
from distutils2.manifest import Manifest
from distutils2 import logger
from distutils2.util import convert_path, resolve_name
@@ -214,8 +215,6 @@ class sdist(Command):
def add_defaults(self):
"""Add all the default files to self.filelist:
- - README or README.txt
- - test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
@@ -225,32 +224,6 @@ class sdist(Command):
Warns if (README or README.txt) or setup.py are missing; everything
else is optional.
"""
- standards = [('README', 'README.txt')]
- for fn in standards:
- if isinstance(fn, tuple):
- alts = fn
- got_it = 0
- for fn in alts:
- if os.path.exists(fn):
- got_it = 1
- self.filelist.append(fn)
- break
-
- if not got_it:
- self.warn("standard file not found: should have one of " +
- string.join(alts, ', '))
- else:
- if os.path.exists(fn):
- self.filelist.append(fn)
- else:
- self.warn("standard file '%s' not found" % fn)
-
- optional = ['test/test*.py', 'setup.cfg']
- for pattern in optional:
- files = filter(os.path.isfile, glob(pattern))
- if files:
- self.filelist.extend(files)
-
for cmd_name in get_command_names():
try:
cmd_obj = self.get_finalized_command(cmd_name)
@@ -319,6 +292,12 @@ class sdist(Command):
logger.warn("no files to distribute -- empty manifest?")
else:
logger.info(msg)
+
+ for file in self.distribution.metadata.requires_files:
+ if file not in files:
+ msg = "'%s' must be included explicitly in 'extra_files'" % file
+ raise DistutilsFileError(msg)
+
for file in files:
if not os.path.isfile(file):
logger.warn("'%s' not a regular file -- skipping" % file)
@@ -376,4 +355,3 @@ class sdist(Command):
# Now create them
for dir in need_dirs:
self.mkpath(dir, mode, verbose=verbose, dry_run=dry_run)
-