[Python-checkins] distutils2: merge to lastest head
tarek.ziade
python-checkins at python.org
Sat Jan 29 14:21:48 CET 2011
tarek.ziade pushed edda0a74267a to distutils2:
http://hg.python.org/distutils2/rev/edda0a74267a
changeset: 912:edda0a74267a
parent: 911:efe36550d8cc
parent: 906:f7b8081c17fc
user: Gael Pasgrimaud <gael at gawel.org>
date: Sat Jan 29 14:03:03 2011 +0100
summary:
merge to lastest head
files:
distutils2/config.py
diff --git a/distutils2/command/build_py.py b/distutils2/command/build_py.py
--- a/distutils2/command/build_py.py
+++ b/distutils2/command/build_py.py
@@ -66,10 +66,9 @@
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 @@
"""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)
- path = package.split('.')
+ if len(path) > 0:
+ return os.path.join(*path)
- 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 ''
+ return ''
def check_package(self, package, package_dir):
"""Helper function for `find_package_modules()` and `find_modules()'.
diff --git a/distutils2/config.py b/distutils2/config.py
--- a/distutils2/config.py
+++ b/distutils2/config.py
@@ -139,16 +139,12 @@
files = dict([(key, self._multiline(value))
for key, value in content['files'].iteritems()])
self.dist.packages = []
- self.dist.package_dir = {}
-
+ self.dist.package_dir = pkg_dir = files.get('packages_root')
packages = files.get('packages', [])
if isinstance(packages, str):
packages = [packages]
for package in packages:
- if ':' in package:
- dir_, package = package.split(':')
- self.dist.package_dir[package] = dir_
self.dist.packages.append(package)
self.dist.py_modules = files.get('modules', [])
diff --git a/distutils2/install.py b/distutils2/install.py
--- a/distutils2/install.py
+++ b/distutils2/install.py
@@ -208,6 +208,13 @@
infos[key].extend(new_infos[key])
+def remove(project_name):
+ """Removes a single project from the installation"""
+ pass
+
+
+
+
def main(**attrs):
if 'script_args' not in attrs:
import sys
diff --git a/distutils2/run.py b/distutils2/run.py
--- a/distutils2/run.py
+++ b/distutils2/run.py
@@ -109,6 +109,7 @@
except (DistutilsError,
CCompilerError), msg:
+ raise
raise SystemExit, "error: " + str(msg)
return dist
diff --git a/distutils2/tests/test_command_build_ext.py b/distutils2/tests/test_command_build_ext.py
--- a/distutils2/tests/test_command_build_ext.py
+++ b/distutils2/tests/test_command_build_ext.py
@@ -289,7 +289,7 @@
# inplace = 0, cmd.package = 'bar'
build_py = cmd.get_finalized_command('build_py')
- build_py.package_dir = {'': 'bar'}
+ build_py.package_dir = 'bar'
path = cmd.get_ext_fullpath('foo')
# checking that the last directory is the build_dir
path = os.path.split(path)[0]
@@ -318,7 +318,7 @@
dist = Distribution()
cmd = build_ext(dist)
cmd.inplace = 1
- cmd.distribution.package_dir = {'': 'src'}
+ cmd.distribution.package_dir = 'src'
cmd.distribution.packages = ['lxml', 'lxml.html']
curdir = os.getcwd()
wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
@@ -334,7 +334,7 @@
# building twisted.runner.portmap not inplace
build_py = cmd.get_finalized_command('build_py')
- build_py.package_dir = {}
+ build_py.package_dir = None
cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
path = cmd.get_ext_fullpath('twisted.runner.portmap')
wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
diff --git a/distutils2/tests/test_command_build_py.py b/distutils2/tests/test_command_build_py.py
--- a/distutils2/tests/test_command_build_py.py
+++ b/distutils2/tests/test_command_build_py.py
@@ -17,12 +17,14 @@
def test_package_data(self):
sources = self.mkdtemp()
- f = open(os.path.join(sources, "__init__.py"), "w")
+ pkg_dir = os.path.join(sources, 'pkg')
+ os.mkdir(pkg_dir)
+ f = open(os.path.join(pkg_dir, "__init__.py"), "w")
try:
f.write("# Pretend this is a package.")
finally:
f.close()
- f = open(os.path.join(sources, "README.txt"), "w")
+ f = open(os.path.join(pkg_dir, "README.txt"), "w")
try:
f.write("Info about this package")
finally:
@@ -31,8 +33,9 @@
destination = self.mkdtemp()
dist = Distribution({"packages": ["pkg"],
- "package_dir": {"pkg": sources}})
+ "package_dir": sources})
# script_name need not exist, it just need to be initialized
+
dist.script_name = os.path.join(sources, "setup.py")
dist.command_obj["build"] = support.DummyCommand(
force=0,
@@ -42,7 +45,7 @@
use_2to3=False)
dist.packages = ["pkg"]
dist.package_data = {"pkg": ["README.txt"]}
- dist.package_dir = {"pkg": sources}
+ dist.package_dir = sources
cmd = build_py(dist)
cmd.compile = 1
@@ -68,19 +71,20 @@
# create the distribution files.
sources = self.mkdtemp()
- open(os.path.join(sources, "__init__.py"), "w").close()
-
- testdir = os.path.join(sources, "doc")
+ pkg = os.path.join(sources, 'pkg')
+ os.mkdir(pkg)
+ open(os.path.join(pkg, "__init__.py"), "w").close()
+ testdir = os.path.join(pkg, "doc")
os.mkdir(testdir)
open(os.path.join(testdir, "testfile"), "w").close()
os.chdir(sources)
old_stdout = sys.stdout
- sys.stdout = StringIO.StringIO()
+ #sys.stdout = StringIO.StringIO()
try:
dist = Distribution({"packages": ["pkg"],
- "package_dir": {"pkg": ""},
+ "package_dir": sources,
"package_data": {"pkg": ["doc/*"]}})
# script_name need not exist, it just need to be initialized
dist.script_name = os.path.join(sources, "setup.py")
@@ -89,7 +93,7 @@
try:
dist.run_commands()
- except DistutilsFileError:
+ except DistutilsFileError, e:
self.fail("failed package_data test when package_dir is ''")
finally:
# Restore state.
diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py
--- a/distutils2/tests/test_config.py
+++ b/distutils2/tests/test_config.py
@@ -49,9 +49,11 @@
Fork in progress, http://bitbucket.org/Merwok/sample-distutils2-project
[files]
+packages_root = src
+
packages = one
- src:two
- src2:three
+ two
+ three
modules = haven
@@ -140,6 +142,7 @@
opts.update(kwargs)
self.write_file('setup.cfg', SETUP_CFG % opts)
+
def run_setup(self, *args):
# run setup with args
sys.stdout = StringIO()
@@ -198,7 +201,6 @@
'http://bitbucket.org/Merwok/sample-distutils2-project')]
self.assertEqual(dist.metadata['Project-Url'], urls)
-
self.assertEqual(dist.packages, ['one', 'two', 'three'])
self.assertEqual(dist.py_modules, ['haven'])
self.assertEqual(dist.package_data, {'cheese': 'data/templates/*'})
@@ -206,7 +208,8 @@
[('bitmaps ', ['bm/b1.gif', 'bm/b2.gif']),
('config ', ['cfg/data.cfg']),
('/etc/init.d ', ['init-script'])])
- self.assertEqual(dist.package_dir['two'], 'src')
+
+ self.assertEqual(dist.package_dir, 'src')
# Make sure we get the foo command loaded. We use a string comparison
# instead of assertIsInstance because the class is not the same when
@@ -262,7 +265,9 @@
os.mkdir('bin')
self.write_file(os.path.join('bin', 'taunt'), '#')
- for pkg in ('one', 'src', 'src2'):
+ os.mkdir('src')
+ for pkg in ('one', 'two', 'three'):
+ pkg = os.path.join('src', pkg)
os.mkdir(pkg)
self.write_file(os.path.join(pkg, '__init__.py'), '#')
@@ -285,7 +290,9 @@
os.mkdir('bin')
self.write_file(os.path.join('bin', 'taunt'), '#')
- for pkg in ('one', 'src', 'src2'):
+ os.mkdir('src')
+ for pkg in ('one', 'two', 'three'):
+ pkg = os.path.join('src', pkg)
os.mkdir(pkg)
self.write_file(os.path.join(pkg, '__init__.py'), '#')
@@ -310,8 +317,10 @@
self.write_file(os.path.join('scripts', 'find-coconuts'), '#')
os.mkdir('bin')
self.write_file(os.path.join('bin', 'taunt'), '#')
+ os.mkdir('src')
- for pkg in ('one', 'src', 'src2'):
+ for pkg in ('one', 'two', 'three'):
+ pkg = os.path.join('src', pkg)
os.mkdir(pkg)
self.write_file(os.path.join(pkg, '__init__.py'), '#')
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list