distutils2: ea717d8e71d0 (original) (raw)
Mercurial > distutils2
changeset 1274:ea717d8e71d0 python3
Merge fixes for #13901, #11805, #13712 and other improvements
Éric Araujo merwok@netwok.org | |
---|---|
date | Sun, 05 Feb 2012 12:23:06 +0100 |
parents | bcea7cbddd47(current diff)730c2e4aaf9c(diff) |
children | a22859e3ebb9 |
files | distutils2/config.py distutils2/create.py distutils2/pypi/dist.py distutils2/pypi/simple.py distutils2/tests/support.py distutils2/tests/test_command_build_py.py distutils2/tests/test_command_sdist.py distutils2/tests/test_config.py distutils2/tests/test_create.py |
diffstat | 11 files changed, 127 insertions(+), 54 deletions(-)[+] [-] CHANGES.txt 6 distutils2/_trove.py 12 distutils2/config.py 24 distutils2/create.py 35 distutils2/pypi/dist.py 2 distutils2/pypi/simple.py 2 distutils2/tests/support.py 13 distutils2/tests/test_command_build_py.py 24 distutils2/tests/test_command_sdist.py 1 distutils2/tests/test_config.py 37 distutils2/tests/test_create.py 25 |
line wrap: on
line diff
--- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,7 @@ their clones, and all changes that have CONTRIBUTORS.txt for full names. Bug numbers refer to http://bugs.python.org/.[](#l1.4) -1.0a4 - 2011-12-?? +1.0a4 - 2012-02-?? ------------------
- Remove type check for commands in favor of minimal duck type check [tarek] @@ -160,6 +160,10 @@ 1.0a4 - 2011-12-??
- Remove verbose arguments for Command and Compiler classes as well as util functions, obsoleted by logging [éric]
- #12659: Add tests for tests.support [francisco]
+- #13901: Prevent test failure on OS X for Python built in shared mode [ned] +- #11805: Add multiple value syntax for package_data in setup.cfg [éric] +- #13712: Don't map package_data to extra_files when converting a setup.py
--- a/distutils2/_trove.py +++ b/distutils2/_trove.py @@ -47,6 +47,12 @@ all_classifiers = [ 'Framework :: IDLE', 'Framework :: Paste', 'Framework :: Plone', +'Framework :: Plone :: 3.2', +'Framework :: Plone :: 3.3', +'Framework :: Plone :: 4.0', +'Framework :: Plone :: 4.1', +'Framework :: Plone :: 4.2', +'Framework :: Plone :: 4.3', 'Framework :: Pylons', 'Framework :: Setuptools Plugin', 'Framework :: Trac', @@ -261,6 +267,12 @@ all_classifiers = [ 'Programming Language :: Python :: 3.0', 'Programming Language :: Python :: 3.1', 'Programming Language :: Python :: 3.2', +'Programming Language :: Python :: Implementation', +'Programming Language :: Python :: Implementation :: CPython', +'Programming Language :: Python :: Implementation :: IronPython', +'Programming Language :: Python :: Implementation :: Jython', +'Programming Language :: Python :: Implementation :: PyPy', +'Programming Language :: Python :: Implementation :: Stackless', 'Programming Language :: REBOL', 'Programming Language :: Rexx', 'Programming Language :: Ruby',
--- a/distutils2/config.py +++ b/distutils2/config.py @@ -226,13 +226,25 @@ class Config: self.dist.scripts = [self.dist.scripts] self.dist.package_data = {}
# bookkeeping for the loop below[](#l3.7)
firstline = True[](#l3.8)
prev = None[](#l3.9)
+ for line in files.get('package_data', []):
data = line.split('=')[](#l3.12)
if len(data) != 2:[](#l3.13)
raise ValueError('invalid line for package_data: %s '[](#l3.14)
'(misses "=")' % line)[](#l3.15)
key, value = data[](#l3.16)
self.dist.package_data[key.strip()] = value.strip()[](#l3.17)
if '=' in line:[](#l3.18)
# package name -- file globs or specs[](#l3.19)
key, value = line.split('=')[](#l3.20)
prev = self.dist.package_data[key.strip()] = value.split()[](#l3.21)
elif firstline:[](#l3.22)
# invalid continuation on the first line[](#l3.23)
raise PackagingOptionError([](#l3.24)
'malformed package_data first line: %r (misses "=")' %[](#l3.25)
line)[](#l3.26)
else:[](#l3.27)
# continuation, add to last seen package name[](#l3.28)
prev.extend(line.split())[](#l3.29)
firstline = False[](#l3.31)
self.dist.data_files = [] for data in files.get('data_files', []):
--- a/distutils2/create.py +++ b/distutils2/create.py @@ -287,6 +287,7 @@ class MainProgram: # optional string entries if 'keywords' in self.data and self.data['keywords']:
# XXX shoud use comma to separate, not space[](#l4.7) fp.write('keywords = %s\n' % ' '.join(self.data['keywords']))[](#l4.8) for name in ('home_page', 'author', 'author_email',[](#l4.9) 'maintainer', 'maintainer_email', 'description-file'):[](#l4.10)
@@ -306,17 +307,29 @@ class MainProgram: fp.write('%s = ' % name) fp.write(''.join(' %s\n' % val for val in self.data[name]).lstrip()) + fp.write('\n[files]\n')
for name in ('packages', 'modules', 'scripts',[](#l4.17)
'package_data', 'extra_files'):[](#l4.18)
for name in ('packages', 'modules', 'scripts', 'extra_files'):[](#l4.20) if not(name in self.data and self.data[name]):[](#l4.21) continue[](#l4.22) fp.write('%s = %s\n'[](#l4.23) % (name, '\n '.join(self.data[name]).strip()))[](#l4.24)
fp.write('\nresources =\n')[](#l4.25)
for src, dest in self.data['resources']:[](#l4.26)
fp.write(' %s = %s\n' % (src, dest))[](#l4.27)
fp.write('\n')[](#l4.28)
if self.data.get('package_data'):[](#l4.30)
fp.write('package_data =\n')[](#l4.31)
for pkg, spec in sorted(self.data['package_data'].items()):[](#l4.32)
# put one spec per line, indented under the package name[](#l4.33)
indent = ' ' * (len(pkg) + 7)[](#l4.34)
spec = ('\n' + indent).join(spec)[](#l4.35)
fp.write(' %s = %s\n' % (pkg, spec))[](#l4.36)
fp.write('\n')[](#l4.37)
if self.data.get('resources'):[](#l4.39)
fp.write('resources =\n')[](#l4.40)
for src, dest in self.data['resources']:[](#l4.41)
fp.write(' %s = %s\n' % (src, dest))[](#l4.42)
fp.write('\n')[](#l4.43)
os.chmod(_FILENAME, 0o644) logger.info('Wrote "%s".' % _FILENAME) @@ -384,14 +397,8 @@ class MainProgram: for src in srcs] data['resources'].extend(files)
# 2.2 package_data -> extra_files[](#l4.51)
package_dirs = dist.package_dir or {}[](#l4.52)
for package, extras in dist.package_data.items() or []:[](#l4.53)
package_dir = package_dirs.get(package, package)[](#l4.54)
for file_ in extras:[](#l4.55)
if package_dir:[](#l4.56)
file_ = package_dir + '/' + file_[](#l4.57)
data['extra_files'].append(file_)[](#l4.58)
# 2.2 package_data[](#l4.59)
data['package_data'] = dist.package_data.copy()[](#l4.60)
# Use README file if its content is the desciption if "description" in data:
--- a/distutils2/pypi/dist.py
+++ b/distutils2/pypi/dist.py
@@ -426,7 +426,7 @@ class ReleasesList(IndexReference):
"""Sort the results with the given properties.
The prefer_final
argument can be used to specify if final
distributions (eg. not dev, bet or alpha) would be prefered or not.[](#l5.7)
distributions (eg. not dev, beta or alpha) would be preferred or not.[](#l5.8)
Results can be inverted by using reverse
.
--- a/distutils2/pypi/simple.py +++ b/distutils2/pypi/simple.py @@ -269,7 +269,7 @@ class Crawler(BaseClient): def _register_release(self, release=None, release_info={}): """Register a new release.
Both a release or a dict of release_info can be provided, the prefered[](#l6.7)
Both a release or a dict of release_info can be provided, the preferred[](#l6.8) way (eg. the quicker) is the dict one.[](#l6.9)
Return the list of existing releases for the given project.
--- a/distutils2/tests/support.py +++ b/distutils2/tests/support.py @@ -353,7 +353,9 @@ def fixup_build_ext(cmd): When Python was built with --enable-shared on Unix, -L. is not enough to find libpython.so, because regrtest runs in a tempdir, not in the
- source directory where the .so lives. (Mac OS X embeds absolute paths
- to shared libraries into executables, so the fixup is a no-op on that
- platform.)
When Python was built with in debug mode on Windows, build_ext commands need their debug attribute set, and it is not done automatically for @@ -380,9 +382,12 @@ def fixup_build_ext(cmd): if runshared is None: cmd.library_dirs = ['.'] else:
# FIXME no partition in 2.4[](#l7.18)
name, equals, value = runshared.partition('=')[](#l7.19)
cmd.library_dirs = value.split(os.pathsep)[](#l7.20)
if sys.platform == 'darwin':[](#l7.21)
cmd.library_dirs = [][](#l7.22)
else:[](#l7.23)
# FIXME no partition in 2.4[](#l7.24)
name, equals, value = runshared.partition('=')[](#l7.25)
cmd.library_dirs = value.split(os.pathsep)[](#l7.26)
# Allow tests to run with an uninstalled Python 3.3 if sys.version_info[:2] == (3, 3) and sysconfig.is_python_build():
--- a/distutils2/tests/test_command_build_py.py +++ b/distutils2/tests/test_command_build_py.py @@ -24,11 +24,17 @@ class BuildPyTestCase(support.TempdirMan f.write("# Pretend this is a package.") finally: f.close()
# let's have two files to make sure globbing works[](#l8.7) f = open(os.path.join(pkg_dir, "README.txt"), "w")[](#l8.8) try:[](#l8.9) f.write("Info about this package")[](#l8.10) finally:[](#l8.11) f.close()[](#l8.12)
f = open(os.path.join(pkg_dir, "HACKING.txt"), "w")[](#l8.13)
try:[](#l8.14)
f.write("How to contribute")[](#l8.15)
finally:[](#l8.16)
f.close()[](#l8.17)
destination = self.mkdtemp() @@ -42,7 +48,7 @@ class BuildPyTestCase(support.TempdirMan convert_2to3_doctests=None, use_2to3=False) dist.packages = ["pkg"]
dist.package_data = {"pkg": ["README.txt"]}[](#l8.25)
dist.package_data = {"pkg": ["*.txt"]}[](#l8.26) dist.package_dir = sources[](#l8.27)
cmd = build_py(dist) @@ -55,17 +61,23 @@ class BuildPyTestCase(support.TempdirMan # This makes sure the list of outputs includes byte-compiled # files for Python modules but not for package data files # (there shouldn't be byte-code files for those!).
self.assertEqual(len(cmd.get_outputs()), 3)[](#l8.34)
# FIXME the test below is not doing what the comment above says, and[](#l8.35)
# if it did it would show a code bug: if we add a demo.py file to[](#l8.36)
# package_data, it gets byte-compiled
outputs = cmd.get_outputs()[](#l8.38)
self.assertEqual(len(outputs), 4, outputs)[](#l8.39) pkgdest = os.path.join(destination, "pkg")[](#l8.40) files = os.listdir(pkgdest)[](#l8.41)
self.assertIn("__init__.py", files)[](#l8.42)
self.assertIn("README.txt", files)[](#l8.43)
wanted = ["__init__.py", "HACKING.txt", "README.txt"][](#l8.44) if sys.version_info[1] == 1:[](#l8.45)
self.assertIn("__init__.pyc", files)[](#l8.46)
wanted.append("__init__.pyc")[](#l8.47) else:[](#l8.48)
wanted.append("__pycache__")[](#l8.49)
self.assertEqual(sorted(files), sorted(wanted))[](#l8.50)
if sys.version_info[1] >= 2:[](#l8.51) pycache_dir = os.path.join(pkgdest, "__pycache__")[](#l8.52) pyc_files = os.listdir(pycache_dir)[](#l8.53)
self.assertIn("__init__.%s.pyc" % imp.get_tag(), pyc_files)[](#l8.54)
self.assertEqual(["__init__.%s.pyc" % imp.get_tag()], pyc_files)[](#l8.55)
def test_empty_package_dir(self): # See SF 1668596/1720897.
--- a/distutils2/tests/test_command_sdist.py +++ b/distutils2/tests/test_command_sdist.py @@ -74,7 +74,6 @@ class SDistTestCase(support.TempdirManag 'author_email': 'xxx'} dist = Distribution(metadata) dist.packages = ['somecode']
dist.include_package_data = True[](#l9.7) cmd = sdist(dist)[](#l9.8) cmd.dist_dir = 'dist'[](#l9.9) return dist, cmd[](#l9.10)
--- a/distutils2/tests/test_config.py +++ b/distutils2/tests/test_config.py @@ -66,11 +66,15 @@ scripts = bin/taunt package_data =
+ extra_files = %(extra-files)s
Replaces MANIFEST.in
+# FIXME no, it's extra_files +# (but sdist_extra is a better name, should use it) sdist_extra = include THANKS HACKING recursive-include examples *.txt .py @@ -96,6 +100,17 @@ setup_hooks = %(setup-hooks)s sub_commands = foo """ +SETUP_CFG_PKGDATA_BUGGY_1 = """ +[files] +package_data = foo. +""" + +SETUP_CFG_PKGDATA_BUGGY_2 = """ +[files] +package_data =
Can not be merged with SETUP_CFG else install_dist
command will fail when trying to compile C sources
TODO use a DummyCommand to mock build_ext
@@ -276,13 +291,14 @@ class ConfigTestCase(support.TempdirMana self.assertEqual(dist.packages, ['one', 'two', 'three']) self.assertEqual(dist.py_modules, ['haven'])
self.assertEqual(dist.package_data, {'cheese': 'data/templates/*'})[](#l10.42)
self.assertEqual([](#l10.43)
self.assertEqual(dist.package_data,[](#l10.44)
{'cheese': ['data/templates/*', 'doc/*',[](#l10.45)
'doc/images/*.png']})[](#l10.46)
self.assertEqual(dist.data_files,[](#l10.47) {'bm/b1.gif': '{icon}/b1.gif',[](#l10.48) 'bm/b2.gif': '{icon}/b2.gif',[](#l10.49) 'Cfg/data.CFG': '{config}/baBar/data.CFG',[](#l10.50)
'init_script': '{script}/JunGle/init_script'},[](#l10.51)
dist.data_files)[](#l10.52)
'init_script': '{script}/JunGle/init_script'})[](#l10.53)
self.assertEqual(dist.package_dir, 'src') @@ -293,8 +309,8 @@ class ConfigTestCase(support.TempdirMana # this file would be main.Foo when run as "python test_config.py". # The name FooBarBazTest should be unique enough to prevent # collisions.
self.assertEqual('FooBarBazTest',[](#l10.61)
dist.get_command_obj('foo').__class__.__name__)[](#l10.62)
self.assertEqual(dist.get_command_obj('foo').__class__.__name__,[](#l10.63)
'FooBarBazTest')[](#l10.64)
# did the README got loaded ? self.assertEqual(dist.metadata['description'], 'yeah') @@ -304,6 +320,13 @@ class ConfigTestCase(support.TempdirMana d = new_compiler(compiler='d') self.assertEqual(d.description, 'D Compiler')
# check error reporting for invalid package_data value[](#l10.72)
self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_1)[](#l10.73)
self.assertRaises(PackagingOptionError, self.get_dist)[](#l10.74)
self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_2)[](#l10.76)
self.assertRaises(PackagingOptionError, self.get_dist)[](#l10.77)
+ def test_multiple_description_file(self): self.write_setup({'description-file': 'README CHANGES'}) self.write_file('README', 'yeah')
--- a/distutils2/tests/test_create.py +++ b/distutils2/tests/test_create.py @@ -116,7 +116,6 @@ class CreateTestCase(support.TempdirMana package_data={ 'babar': ['Pom', 'Flora', 'Alexander'], 'me': ['dady', 'mumy', 'sys', 'bro'],
'': ['setup.py', 'README'],[](#l11.7) 'pyxfoil': ['fengine.so'],[](#l11.8) },[](#l11.9) scripts=['my_script', 'bin/run'],[](#l11.10)
@@ -150,16 +149,15 @@ class CreateTestCase(support.TempdirMana mymodule scripts = my_script bin/run
extra_files = Martinique/Lamentin/dady[](#l11.15)
Martinique/Lamentin/mumy[](#l11.16)
Martinique/Lamentin/sys[](#l11.17)
Martinique/Lamentin/bro[](#l11.18)
setup.py[](#l11.19)
README[](#l11.20)
Pom[](#l11.21)
Flora[](#l11.22)
Alexander[](#l11.23)
pyxfoil/fengine.so[](#l11.24)
package_data =[](#l11.25)
babar = Pom[](#l11.26)
Flora[](#l11.27)
Alexander[](#l11.28)
me = dady[](#l11.29)
mumy[](#l11.30)
sys[](#l11.31)
bro[](#l11.32)
pyxfoil = fengine.so[](#l11.33)
resources =
README.rst = {doc}
@@ -217,8 +215,9 @@ ho, baby
[files]
packages = pyxfoil
extra_files = pyxfoil/fengine.so[](#l11.41)
pyxfoil/babar.so[](#l11.42)
package_data =[](#l11.43)
pyxfoil = fengine.so[](#l11.44)
babar.so[](#l11.45)