summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2012-09-05 20:03:16 -0400
committerJason R. Coombs <jaraco@jaraco.com>2012-09-05 20:03:16 -0400
commit27f432716d6624ca043ac428a70b6aaf5e0d537b (patch)
treed80693c8b618e7a8e6d12a3c73b51dec869df5ef /setuptools
parent9ebbe014df37c19976a5a9cb0ac2fa228a03144a (diff)
parent6eece1023d4a0d5e7229d33dc53600e8e31d7942 (diff)
downloadpython-setuptools-git-27f432716d6624ca043ac428a70b6aaf5e0d537b.tar.gz
Merged in embray/distribute/fix-sdist (pull request #4)
--HG-- branch : distribute extra : rebase_source : edfbe310b187502d98f3fb19e7aa405238a143be
Diffstat (limited to 'setuptools')
-rwxr-xr-xsetuptools/command/sdist.py8
-rw-r--r--setuptools/tests/test_sdist.py79
2 files changed, 87 insertions, 0 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 91c4fd1b..a176f635 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -198,6 +198,14 @@ class sdist(_sdist):
if self.distribution.has_pure_modules():
build_py = self.get_finalized_command('build_py')
self.filelist.extend(build_py.get_source_files())
+ # This functionality is incompatible with include_package_data, and
+ # will in fact create an infinite recursion if include_package_data
+ # is True. Use of include_package_data will imply that
+ # distutils-style automatic handling of package_data is disabled
+ if not self.distribution.include_package_data:
+ for _, src_dir, _, filenames in build_py.data_files:
+ self.filelist.extend([os.path.join(src_dir, filename)
+ for filename in filenames])
if self.distribution.has_ext_modules():
build_ext = self.get_finalized_command('build_ext')
diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py
new file mode 100644
index 00000000..8d9ed922
--- /dev/null
+++ b/setuptools/tests/test_sdist.py
@@ -0,0 +1,79 @@
+"""sdist tests"""
+
+
+import os
+import shutil
+import sys
+import tempfile
+import unittest
+from StringIO import StringIO
+
+
+from setuptools.command.sdist import sdist
+from setuptools.dist import Distribution
+
+
+SETUP_ATTRS = {
+ 'name': 'sdist_test',
+ 'version': '0.0',
+ 'packages': ['sdist_test'],
+ 'package_data': {'sdist_test': ['*.txt']}
+}
+
+
+SETUP_PY = """\
+from setuptools import setup
+
+setup(**%r)
+""" % SETUP_ATTRS
+
+
+class TestSdistTest(unittest.TestCase):
+ def setUp(self):
+ self.temp_dir = tempfile.mkdtemp()
+ f = open(os.path.join(self.temp_dir, 'setup.py'), 'w')
+ f.write(SETUP_PY)
+ f.close()
+ # Set up the rest of the test package
+ test_pkg = os.path.join(self.temp_dir, 'sdist_test')
+ os.mkdir(test_pkg)
+ # *.rst was not included in package_data, so c.rst should not be
+ # automatically added to the manifest when not under version control
+ for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst']:
+ # Just touch the files; their contents are irrelevant
+ open(os.path.join(test_pkg, fname), 'w').close()
+
+ self.old_cwd = os.getcwd()
+ os.chdir(self.temp_dir)
+
+ def tearDown(self):
+ os.chdir(self.old_cwd)
+ shutil.rmtree(self.temp_dir)
+
+ def test_package_data_in_sdist(self):
+ """Regression test for pull request #4: ensures that files listed in
+ package_data are included in the manifest even if they're not added to
+ version control.
+ """
+
+ dist = Distribution(SETUP_ATTRS)
+ dist.script_name = 'setup.py'
+ cmd = sdist(dist)
+ cmd.ensure_finalized()
+
+ # squelch output
+ old_stdout = sys.stdout
+ old_stderr = sys.stderr
+ sys.stdout = StringIO()
+ sys.stderr = StringIO()
+ try:
+ cmd.run()
+ finally:
+ sys.stdout = old_stdout
+ sys.stderr = old_stderr
+
+ manifest = cmd.filelist.files
+
+ self.assert_(os.path.join('sdist_test', 'a.txt') in manifest)
+ self.assert_(os.path.join('sdist_test', 'b.txt') in manifest)
+ self.assert_(os.path.join('sdist_test', 'c.rst') not in manifest)