diff options
| author | ?ric Araujo <merwok@netwok.org> | 2012-02-05 12:23:06 +0100 |
|---|---|---|
| committer | ?ric Araujo <merwok@netwok.org> | 2012-02-05 12:23:06 +0100 |
| commit | 65fb9ed769aad763558bd9fbd1299e86ead5808d (patch) | |
| tree | 7e28f69dd7cefb68c434686bc08854ad782a29e7 | |
| parent | e8d47ece79b15955bd7527d40279f2769d15661c (diff) | |
| parent | 858a259ca7d7d06d6dc2436106860176b6c6427d (diff) | |
| download | disutils2-65fb9ed769aad763558bd9fbd1299e86ead5808d.tar.gz | |
Merge fixes for #13901, #11805, #13712 and other improvements
| -rw-r--r-- | CHANGES.txt | 6 | ||||
| -rw-r--r-- | distutils2/_trove.py | 12 | ||||
| -rw-r--r-- | distutils2/config.py | 24 | ||||
| -rw-r--r-- | distutils2/create.py | 35 | ||||
| -rw-r--r-- | distutils2/pypi/dist.py | 2 | ||||
| -rw-r--r-- | distutils2/pypi/simple.py | 2 | ||||
| -rw-r--r-- | distutils2/tests/support.py | 13 | ||||
| -rw-r--r-- | distutils2/tests/test_command_build_py.py | 24 | ||||
| -rw-r--r-- | distutils2/tests/test_command_sdist.py | 1 | ||||
| -rw-r--r-- | distutils2/tests/test_config.py | 37 | ||||
| -rw-r--r-- | distutils2/tests/test_create.py | 25 |
11 files changed, 127 insertions, 54 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index fbd06c6..62e2b54 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,7 +9,7 @@ their clones, and all changes that have a bug report. Contributors' first names CONTRIBUTORS.txt for full names. Bug numbers refer to http://bugs.python.org/. -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 @@ CONTRIBUTORS.txt for full names. Bug numbers refer to http://bugs.python.org/. - 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 + script with pysetup create [éric] 1.0a3 - 2010-10-08 diff --git a/distutils2/_trove.py b/distutils2/_trove.py index bc9bce8..f527bc4 100644 --- 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', diff --git a/distutils2/config.py b/distutils2/config.py index 91d1cbb..5be6310 100644 --- 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 + firstline = True + prev = None + for line in files.get('package_data', []): - data = line.split('=') - if len(data) != 2: - raise ValueError('invalid line for package_data: %s ' - '(misses "=")' % line) - key, value = data - self.dist.package_data[key.strip()] = value.strip() + if '=' in line: + # package name -- file globs or specs + key, value = line.split('=') + prev = self.dist.package_data[key.strip()] = value.split() + elif firstline: + # invalid continuation on the first line + raise PackagingOptionError( + 'malformed package_data first line: %r (misses "=")' % + line) + else: + # continuation, add to last seen package name + prev.extend(line.split()) + + firstline = False self.dist.data_files = [] for data in files.get('data_files', []): diff --git a/distutils2/create.py b/distutils2/create.py index c27855e..dfcce97 100644 --- 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 fp.write('keywords = %s\n' % ' '.join(self.data['keywords'])) for name in ('home_page', 'author', 'author_email', 'maintainer', 'maintainer_email', 'description-file'): @@ -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', - 'package_data', 'extra_files'): + + for name in ('packages', 'modules', 'scripts', 'extra_files'): if not(name in self.data and self.data[name]): continue fp.write('%s = %s\n' % (name, '\n '.join(self.data[name]).strip())) - fp.write('\nresources =\n') - for src, dest in self.data['resources']: - fp.write(' %s = %s\n' % (src, dest)) - fp.write('\n') + + if self.data.get('package_data'): + fp.write('package_data =\n') + for pkg, spec in sorted(self.data['package_data'].items()): + # put one spec per line, indented under the package name + indent = ' ' * (len(pkg) + 7) + spec = ('\n' + indent).join(spec) + fp.write(' %s = %s\n' % (pkg, spec)) + fp.write('\n') + + if self.data.get('resources'): + fp.write('resources =\n') + for src, dest in self.data['resources']: + fp.write(' %s = %s\n' % (src, dest)) + fp.write('\n') 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 - package_dirs = dist.package_dir or {} - for package, extras in dist.package_data.items() or []: - package_dir = package_dirs.get(package, package) - for file_ in extras: - if package_dir: - file_ = package_dir + '/' + file_ - data['extra_files'].append(file_) + # 2.2 package_data + data['package_data'] = dist.package_data.copy() # Use README file if its content is the desciption if "description" in data: diff --git a/distutils2/pypi/dist.py b/distutils2/pypi/dist.py index 23e7bd9..e2dd6a3 100644 --- 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. + distributions (eg. not dev, beta or alpha) would be preferred or not. Results can be inverted by using `reverse`. diff --git a/distutils2/pypi/simple.py b/distutils2/pypi/simple.py index 5e2aed2..5e0b02e 100644 --- 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 + Both a release or a dict of release_info can be provided, the preferred way (eg. the quicker) is the dict one. Return the list of existing releases for the given project. diff --git a/distutils2/tests/support.py b/distutils2/tests/support.py index a620868..ec8a694 100644 --- 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<blah>.so, because regrtest runs in a tempdir, not in the - source directory where the .so lives. + 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 - name, equals, value = runshared.partition('=') - cmd.library_dirs = value.split(os.pathsep) + if sys.platform == 'darwin': + cmd.library_dirs = [] + else: + # FIXME no partition in 2.4 + name, equals, value = runshared.partition('=') + cmd.library_dirs = value.split(os.pathsep) # Allow tests to run with an uninstalled Python 3.3 if sys.version_info[:2] == (3, 3) and sysconfig.is_python_build(): diff --git a/distutils2/tests/test_command_build_py.py b/distutils2/tests/test_command_build_py.py index 4b6c6aa..90a8720 100644 --- a/distutils2/tests/test_command_build_py.py +++ b/distutils2/tests/test_command_build_py.py @@ -24,11 +24,17 @@ class BuildPyTestCase(support.TempdirManager, f.write("# Pretend this is a package.") finally: f.close() + # let's have two files to make sure globbing works f = open(os.path.join(pkg_dir, "README.txt"), "w") try: f.write("Info about this package") finally: f.close() + f = open(os.path.join(pkg_dir, "HACKING.txt"), "w") + try: + f.write("How to contribute") + finally: + f.close() destination = self.mkdtemp() @@ -42,7 +48,7 @@ class BuildPyTestCase(support.TempdirManager, convert_2to3_doctests=None, use_2to3=False) dist.packages = ["pkg"] - dist.package_data = {"pkg": ["README.txt"]} + dist.package_data = {"pkg": ["*.txt"]} dist.package_dir = sources cmd = build_py(dist) @@ -55,17 +61,23 @@ class BuildPyTestCase(support.TempdirManager, # 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) + # FIXME the test below is not doing what the comment above says, and + # if it did it would show a code bug: if we add a demo.py file to + # package_data, it gets byte-compiled! + outputs = cmd.get_outputs() + self.assertEqual(len(outputs), 4, outputs) pkgdest = os.path.join(destination, "pkg") files = os.listdir(pkgdest) - self.assertIn("__init__.py", files) - self.assertIn("README.txt", files) + wanted = ["__init__.py", "HACKING.txt", "README.txt"] if sys.version_info[1] == 1: - self.assertIn("__init__.pyc", files) + wanted.append("__init__.pyc") else: + wanted.append("__pycache__") + self.assertEqual(sorted(files), sorted(wanted)) + if sys.version_info[1] >= 2: pycache_dir = os.path.join(pkgdest, "__pycache__") pyc_files = os.listdir(pycache_dir) - self.assertIn("__init__.%s.pyc" % imp.get_tag(), pyc_files) + self.assertEqual(["__init__.%s.pyc" % imp.get_tag()], pyc_files) def test_empty_package_dir(self): # See SF 1668596/1720897. diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py index ba6e9fa..f059db4 100644 --- a/distutils2/tests/test_command_sdist.py +++ b/distutils2/tests/test_command_sdist.py @@ -74,7 +74,6 @@ class SDistTestCase(support.TempdirManager, 'author_email': 'xxx'} dist = Distribution(metadata) dist.packages = ['somecode'] - dist.include_package_data = True cmd = sdist(dist) cmd.dist_dir = 'dist' return dist, cmd diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py index 08c8a70..dfee483 100644 --- a/distutils2/tests/test_config.py +++ b/distutils2/tests/test_config.py @@ -66,11 +66,15 @@ scripts = bin/taunt package_data = - cheese = data/templates/* + cheese = data/templates/* doc/* + doc/images/*.png + 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 = + foo.* +""" + # 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.TempdirManager, self.assertEqual(dist.packages, ['one', 'two', 'three']) self.assertEqual(dist.py_modules, ['haven']) - self.assertEqual(dist.package_data, {'cheese': 'data/templates/*'}) - self.assertEqual( + self.assertEqual(dist.package_data, + {'cheese': ['data/templates/*', 'doc/*', + 'doc/images/*.png']}) + self.assertEqual(dist.data_files, {'bm/b1.gif': '{icon}/b1.gif', 'bm/b2.gif': '{icon}/b2.gif', 'Cfg/data.CFG': '{config}/baBar/data.CFG', - 'init_script': '{script}/JunGle/init_script'}, - dist.data_files) + 'init_script': '{script}/JunGle/init_script'}) self.assertEqual(dist.package_dir, 'src') @@ -293,8 +309,8 @@ class ConfigTestCase(support.TempdirManager, # 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', - dist.get_command_obj('foo').__class__.__name__) + self.assertEqual(dist.get_command_obj('foo').__class__.__name__, + 'FooBarBazTest') # did the README got loaded ? self.assertEqual(dist.metadata['description'], 'yeah') @@ -304,6 +320,13 @@ class ConfigTestCase(support.TempdirManager, d = new_compiler(compiler='d') self.assertEqual(d.description, 'D Compiler') + # check error reporting for invalid package_data value + self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_1) + self.assertRaises(PackagingOptionError, self.get_dist) + + self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_2) + self.assertRaises(PackagingOptionError, self.get_dist) + def test_multiple_description_file(self): self.write_setup({'description-file': 'README CHANGES'}) self.write_file('README', 'yeah') diff --git a/distutils2/tests/test_create.py b/distutils2/tests/test_create.py index 83d2f50..43dad60 100644 --- a/distutils2/tests/test_create.py +++ b/distutils2/tests/test_create.py @@ -116,7 +116,6 @@ class CreateTestCase(support.TempdirManager, package_data={ 'babar': ['Pom', 'Flora', 'Alexander'], 'me': ['dady', 'mumy', 'sys', 'bro'], - '': ['setup.py', 'README'], 'pyxfoil': ['fengine.so'], }, scripts=['my_script', 'bin/run'], @@ -150,16 +149,15 @@ class CreateTestCase(support.TempdirManager, mymodule scripts = my_script bin/run - extra_files = Martinique/Lamentin/dady - Martinique/Lamentin/mumy - Martinique/Lamentin/sys - Martinique/Lamentin/bro - setup.py - README - Pom - Flora - Alexander - pyxfoil/fengine.so + package_data = + babar = Pom + Flora + Alexander + me = dady + mumy + sys + bro + pyxfoil = fengine.so resources = README.rst = {doc} @@ -217,8 +215,9 @@ ho, baby! [files] packages = pyxfoil - extra_files = pyxfoil/fengine.so - pyxfoil/babar.so + package_data = + pyxfoil = fengine.so + babar.so resources = README.rst = {doc} |
