[Python-checkins] distutils2: Fix last bug, check that data file not exists at the same path and has the same
tarek.ziade
python-checkins at python.org
Wed Feb 16 22:23:58 CET 2011
tarek.ziade pushed 84ae7ec1d532 to distutils2:
http://hg.python.org/distutils2/rev/84ae7ec1d532
changeset: 1061:84ae7ec1d532
user: FELD Boris <lothiraldan at gmail.com>
date: Sun Jan 30 14:42:59 2011 +0100
summary:
Fix last bug, check that data file not exists at the same path and has the same content.
files:
distutils2/command/install_data.py
distutils2/tests/test_command_install_data.py
diff --git a/distutils2/command/install_data.py b/distutils2/command/install_data.py
--- a/distutils2/command/install_data.py
+++ b/distutils2/command/install_data.py
@@ -10,6 +10,7 @@
from distutils2.command.cmd import Command
from distutils2.util import change_root, convert_path
from distutils2._backport.sysconfig import get_paths, format_value
+from distutils2._backport.shutil import Error
class install_data(Command):
@@ -47,7 +48,11 @@
dir_dest = os.path.abspath(os.path.dirname(destination))
self.mkpath(dir_dest)
- (out, _) = self.copy_file(file[0], dir_dest)
+ try:
+ (out, _) = self.copy_file(file[0], dir_dest)
+ except Error, e:
+ self.warn(e.message)
+ out = destination
self.outfiles.append(out)
self.data_files_out.append((file[0], destination))
diff --git a/distutils2/tests/test_command_install_data.py b/distutils2/tests/test_command_install_data.py
--- a/distutils2/tests/test_command_install_data.py
+++ b/distutils2/tests/test_command_install_data.py
@@ -1,4 +1,5 @@
"""Tests for distutils.command.install_data."""
+import cmd
import os
from distutils2.command.install_data import install_data
@@ -10,18 +11,29 @@
unittest.TestCase):
def test_simple_run(self):
+ from distutils2._backport.sysconfig import _SCHEMES as sysconfig_SCHEMES
+ from distutils2._backport.sysconfig import _get_default_scheme
+ #dirty but hit marmoute
+
+ old_scheme = sysconfig_SCHEMES
+
pkg_dir, dist = self.create_dist()
cmd = install_data(dist)
cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')
+ sysconfig_SCHEMES.set(_get_default_scheme(), 'inst',
+ os.path.join(pkg_dir, 'inst'))
+ sysconfig_SCHEMES.set(_get_default_scheme(), 'inst2',
+ os.path.join(pkg_dir, 'inst2'))
+
one = os.path.join(pkg_dir, 'one')
self.write_file(one, 'xxx')
inst2 = os.path.join(pkg_dir, 'inst2')
two = os.path.join(pkg_dir, 'two')
self.write_file(two, 'xxx')
- cmd.data_files = {'one' : '{appdata}/one', 'two' : '{appdata}/two'}
- self.assertEqual(cmd.get_inputs(), [one, (inst2, [two])])
+ cmd.data_files = {one : '{inst}/one', two : '{inst2}/two'}
+ self.assertItemsEqual(cmd.get_inputs(), [one, two])
# let's run the command
cmd.ensure_finalized()
@@ -51,17 +63,22 @@
inst4 = os.path.join(pkg_dir, 'inst4')
three = os.path.join(cmd.install_dir, 'three')
self.write_file(three, 'xx')
- cmd.data_files = [one, (inst2, [two]),
- ('inst3', [three]),
- (inst4, [])]
+
+ sysconfig_SCHEMES.set(_get_default_scheme(), 'inst3', cmd.install_dir)
+
+ cmd.data_files = {one : '{inst}/one',
+ two : '{inst2}/two',
+ three : '{inst3}/three'}
cmd.ensure_finalized()
cmd.run()
# let's check the result
- self.assertEqual(len(cmd.get_outputs()), 4)
+ self.assertEqual(len(cmd.get_outputs()), 3)
self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
self.assertTrue(os.path.exists(os.path.join(inst, rone)))
+ sysconfig_SCHEMES = old_scheme
+
def test_suite():
return unittest.makeSuite(InstallDataTestCase)
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list