diff options
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/ccompiler.py | 2 | ||||
-rw-r--r-- | Lib/distutils/cmd.py | 2 | ||||
-rw-r--r-- | Lib/distutils/command/build_py.py | 4 | ||||
-rw-r--r-- | Lib/distutils/command/build_scripts.py | 4 | ||||
-rw-r--r-- | Lib/distutils/command/install_scripts.py | 2 | ||||
-rw-r--r-- | Lib/distutils/command/register.py | 2 | ||||
-rw-r--r-- | Lib/distutils/dir_util.py | 4 | ||||
-rw-r--r-- | Lib/distutils/mwerkscompiler.py | 2 | ||||
-rw-r--r-- | Lib/distutils/tests/support.py | 8 | ||||
-rw-r--r-- | Lib/distutils/tests/test_build_py.py | 35 |
10 files changed, 51 insertions, 14 deletions
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index 50905c1..d4f4ade 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -1040,7 +1040,7 @@ main (int argc, char **argv) { def move_file (self, src, dst): return move_file (src, dst, dry_run=self.dry_run) - def mkpath (self, name, mode=0777): + def mkpath (self, name, mode=0o777): mkpath (name, mode, self.dry_run) diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py index 8d77e7f..b2c952c 100644 --- a/Lib/distutils/cmd.py +++ b/Lib/distutils/cmd.py @@ -356,7 +356,7 @@ class Command: util.execute(func, args, msg, dry_run=self.dry_run) - def mkpath (self, name, mode=0777): + def mkpath (self, name, mode=0o777): dir_util.mkpath(name, mode, dry_run=self.dry_run) diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py index 52534bd..8f56090 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/command/build_scripts.py b/Lib/distutils/command/build_scripts.py index bda4480..511b82f 100644 --- a/Lib/distutils/command/build_scripts.py +++ b/Lib/distutils/command/build_scripts.py @@ -119,8 +119,8 @@ class build_scripts (Command): if self.dry_run: log.info("changing mode of %s", file) else: - oldmode = os.stat(file)[ST_MODE] & 07777 - newmode = (oldmode | 0555) & 07777 + oldmode = os.stat(file)[ST_MODE] & 0o7777 + newmode = (oldmode | 0o555) & 0o7777 if newmode != oldmode: log.info("changing mode of %s from %o to %o", file, oldmode, newmode) diff --git a/Lib/distutils/command/install_scripts.py b/Lib/distutils/command/install_scripts.py index fe93ef5..da2da35 100644 --- a/Lib/distutils/command/install_scripts.py +++ b/Lib/distutils/command/install_scripts.py @@ -53,7 +53,7 @@ class install_scripts (Command): if self.dry_run: log.info("changing mode of %s", file) else: - mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 + mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777 log.info("changing mode of %s to %o", file, mode) os.chmod(file, mode) diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py index 2ddabad..53f4293 100644 --- a/Lib/distutils/command/register.py +++ b/Lib/distutils/command/register.py @@ -183,7 +183,7 @@ Your selection [default 1]: ''', end=' ') username, password)) f.close() try: - os.chmod(rc, 0600) + os.chmod(rc, 0o600) except: pass elif choice == '2': diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py index c6f014b..0cfca2e 100644 --- a/Lib/distutils/dir_util.py +++ b/Lib/distutils/dir_util.py @@ -18,7 +18,7 @@ _path_created = {} # I don't use os.makedirs because a) it's new to Python 1.5.2, and # b) it blows up if the directory already exists (I want to silently # succeed in that case). -def mkpath (name, mode=0777, verbose=0, dry_run=0): +def mkpath (name, mode=0o777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do @@ -85,7 +85,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0): # mkpath () -def create_tree (base_dir, files, mode=0777, verbose=0, dry_run=0): +def create_tree (base_dir, files, mode=0o777, verbose=0, dry_run=0): """Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the a name of a directory diff --git a/Lib/distutils/mwerkscompiler.py b/Lib/distutils/mwerkscompiler.py index 028ea82..662046a 100644 --- a/Lib/distutils/mwerkscompiler.py +++ b/Lib/distutils/mwerkscompiler.py @@ -18,7 +18,6 @@ from distutils.ccompiler import \ import distutils.util import distutils.dir_util from distutils import log -import mkcwproject class MWerksCompiler (CCompiler) : """Concrete class that implements an interface to MetroWerks CodeWarrior, @@ -188,6 +187,7 @@ class MWerksCompiler (CCompiler) : # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) log.debug("\tCreate XML file %s", xmlfilename) + import mkcwproject xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() xmldata = settings['tmp_projectxmldata'] diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py index 475ceee..91e704c 100644 --- a/Lib/distutils/tests/support.py +++ b/Lib/distutils/tests/support.py @@ -9,12 +9,12 @@ from distutils import log class LoggingSilencer(object): def setUp(self): - super(LoggingSilencer, self).setUp() + super().setUp() self.threshold = log.set_threshold(log.FATAL) def tearDown(self): log.set_threshold(self.threshold) - super(LoggingSilencer, self).tearDown() + super().tearDown() class TempdirManager(object): @@ -24,11 +24,11 @@ class TempdirManager(object): """ def setUp(self): - super(TempdirManager, self).setUp() + super().setUp() self.tempdirs = [] def tearDown(self): - super(TempdirManager, self).tearDown() + super().tearDown() while self.tempdirs: d = self.tempdirs.pop() shutil.rmtree(d) 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) |