summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-06-01 07:29:12 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-06-01 07:29:12 (GMT)
commit4a700bb4698c1ec7f94b26f78f866929b013647f (patch)
treed97f9e24781653a915d34c51ac67f7cfccb3e512
parent19a7daa50749d9e5e013daf87b064afa4b354729 (diff)
downloadcpython-4a700bb4698c1ec7f94b26f78f866929b013647f.zip
cpython-4a700bb4698c1ec7f94b26f78f866929b013647f.tar.gz
cpython-4a700bb4698c1ec7f94b26f78f866929b013647f.tar.bz2
SF 1668596/1720897: distutils now copies data files
even if package_dir is empty. This needs to be backported. I'm too tired tonight. It would be great if someone backports this if the buildbots are ok with it. Otherwise, I will try to get to it tomorrow.
-rw-r--r--Lib/distutils/command/build_py.py4
-rw-r--r--Lib/distutils/tests/test_build_py.py35
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 42 insertions, 1 deletions
diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py
index 621bcb4..b9f39ba 100644
--- a/Lib/distutils/command/build_py.py
+++ b/Lib/distutils/command/build_py.py
@@ -114,7 +114,9 @@ class build_py (Command):
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
# Length of path to strip from found files
- plen = len(src_dir)+1
+ plen = 0
+ if src_dir:
+ plen = len(src_dir)+1
# Strip directory from globbed filenames
filenames = [
diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
index 78e4c55..54a4ed8 100644
--- a/Lib/distutils/tests/test_build_py.py
+++ b/Lib/distutils/tests/test_build_py.py
@@ -1,10 +1,13 @@
"""Tests for distutils.command.build_py."""
import os
+import sys
+import StringIO
import unittest
from distutils.command.build_py import build_py
from distutils.core import Distribution
+from distutils.errors import DistutilsFileError
from distutils.tests import support
@@ -53,6 +56,38 @@ class BuildPyTestCase(support.TempdirManager,
self.assert_("__init__.pyc" in files)
self.assert_("README.txt" in files)
+ def test_empty_package_dir (self):
+ # See SF 1668596/1720897.
+ cwd = os.getcwd()
+
+ # create the distribution files.
+ sources = self.mkdtemp()
+ open(os.path.join(sources, "__init__.py"), "w").close()
+
+ testdir = os.path.join(sources, "doc")
+ os.mkdir(testdir)
+ open(os.path.join(testdir, "testfile"), "w").close()
+
+ os.chdir(sources)
+ sys.stdout = StringIO.StringIO()
+
+ try:
+ dist = Distribution({"packages": ["pkg"],
+ "package_dir": {"pkg": ""},
+ "package_data": {"pkg": ["doc/*"]}})
+ # script_name need not exist, it just need to be initialized
+ dist.script_name = os.path.join(sources, "setup.py")
+ dist.script_args = ["build"]
+ dist.parse_command_line()
+
+ try:
+ dist.run_commands()
+ except DistutilsFileError:
+ self.fail("failed package_data test when package_dir is ''")
+ finally:
+ # Restore state.
+ os.chdir(cwd)
+ sys.stdout = sys.__stdout__
def test_suite():
return unittest.makeSuite(BuildPyTestCase)
diff --git a/Misc/ACKS b/Misc/ACKS
index b0a0372..41c4f18 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -159,6 +159,7 @@ John DeGood
Vincent Delft
Erik Demaine
Roger Dev
+Raghuram Devarakonda
Toby Dickenson
Mark Dickinson
Yves Dionne
diff --git a/Misc/NEWS b/Misc/NEWS
index e3577db..33c45ca 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -220,6 +220,9 @@ Core and builtins
Library
-------
+- SF 1668596/1720897: distutils now copies data files
+ even if package_dir is empty.
+
- sha now raises a DeprecationWarning upon import.
- md5 now raises a DeprecationWarning upon import.