[Python-checkins] distutils2: Now creating scripts everytime when build_scripts is called, as a side effect,

eric.araujo python-checkins at python.org
Wed May 16 07:07:26 CEST 2012


http://hg.python.org/distutils2/rev/99382aafa4c5
changeset:   1329:99382aafa4c5
parent:      1326:bb9ca80afc84
user:        Pierre Paul <info at pierre-paul.com>
date:        Sat May 12 18:14:31 2012 -0400
summary:
  Now creating scripts everytime when build_scripts is called, as a side effect, --force option has been removed

files:
  CHANGES.txt                                    |   5 +
  CONTRIBUTORS.txt                               |   1 +
  distutils2/command/build_scripts.py            |  11 +---
  distutils2/tests/test_command_build_scripts.py |  27 ++++++++-
  4 files changed, 30 insertions(+), 14 deletions(-)


diff --git a/CHANGES.txt b/CHANGES.txt
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,11 @@
 (and last name initial when needed) are given for each item; see
 CONTRIBUTORS.txt for full names.  Bug numbers refer to http://bugs.python.org/.
 
+1.0a5 - 2012-xx-xx
+------------------
+
+- #10374 Now creating scripts everytime when build_scripts is called,
+  as a side effect, --force option has been removed [PierrePaul]
 
 1.0a4 - 2012-03-13
 ------------------
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -42,6 +42,7 @@
 - Jeremy Kloth
 - Amos Latteier
 - Mathieu Leduc-Hamel
+- Pierre Paul Lefebvre
 - Tshepang Lekhonkhobe
 - Alain Leufroy
 - Martin von Löwis
diff --git a/distutils2/command/build_scripts.py b/distutils2/command/build_scripts.py
--- a/distutils2/command/build_scripts.py
+++ b/distutils2/command/build_scripts.py
@@ -20,17 +20,12 @@
 
     user_options = [
         ('build-dir=', 'd', "directory to build (copy) to"),
-        ('force', 'f', "forcibly build everything (ignore file timestamps"),
         ('executable=', 'e', "specify final destination interpreter path"),
         ]
 
-    boolean_options = ['force']
-
-
     def initialize_options(self):
         self.build_dir = None
         self.scripts = None
-        self.force = None
         self.executable = None
         self.outfiles = None
         self.use_2to3 = False
@@ -41,7 +36,7 @@
         self.set_undefined_options('build',
                                    ('build_scripts', 'build_dir'),
                                    'use_2to3', 'use_2to3_fixers',
-                                   'convert_2to3_doctests', 'force',
+                                   'convert_2to3_doctests',
                                    'executable')
         self.scripts = self.distribution.scripts
 
@@ -69,10 +64,6 @@
             outfile = os.path.join(self.build_dir, os.path.basename(script))
             outfiles.append(outfile)
 
-            if not self.force and not newer(script, outfile):
-                logger.debug("not copying %s (up-to-date)", script)
-                continue
-
             # Always open the file, but ignore failures in dry-run mode --
             # that way, we'll get accurate feedback if we can read the
             # script.
diff --git a/distutils2/tests/test_command_build_scripts.py b/distutils2/tests/test_command_build_scripts.py
--- a/distutils2/tests/test_command_build_scripts.py
+++ b/distutils2/tests/test_command_build_scripts.py
@@ -20,7 +20,7 @@
 
         cmd.finalize_options()
 
-        self.assertTrue(cmd.force)
+        self.assertFalse(cmd.force)
         self.assertEqual(cmd.build_dir, "/foo/bar")
 
     def test_build(self):
@@ -38,13 +38,13 @@
         for name in expected:
             self.assertIn(name, built)
 
-    def get_build_scripts_cmd(self, target, scripts):
+    def get_build_scripts_cmd(self, target, scripts, executable=sys.executable):
         dist = Distribution()
         dist.scripts = scripts
         dist.command_obj["build"] = support.DummyCommand(
             build_scripts=target,
-            force=True,
-            executable=sys.executable,
+            force=False,
+            executable=executable,
             use_2to3=False,
             use_2to3_fixers=None,
             convert_2to3_doctests=None
@@ -105,6 +105,25 @@
         for name in expected:
             self.assertIn(name, built)
 
+    def test_build_dir_recreated(self):
+        source = self.mkdtemp()
+        target = self.mkdtemp()
+        self.write_script(source, 'taunt', '#! /usr/bin/python')
+
+        built = os.path.join(target, 'taunt')
+
+        cmd = self.get_build_scripts_cmd(target, [os.path.join(source, 'taunt')], 'pythona')
+        cmd.finalize_options()
+        cmd.run()
+
+        self.assertEqual(open(built).readline(), '#!pythona\n')
+
+        cmd = self.get_build_scripts_cmd(target, [os.path.join(source, 'taunt')], 'pythonx')
+        cmd.finalize_options()
+        cmd.run()
+
+        self.assertEqual(open(built).readline(), '#!pythonx\n')
+        
 def test_suite():
     return unittest.makeSuite(BuildScriptsTestCase)
 

-- 
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list