[Python-checkins] distutils2: #14270: Fixes to add dest_dir params working when using install_from_infos
eric.araujo
python-checkins at python.org
Wed May 16 07:07:26 CEST 2012
http://hg.python.org/distutils2/rev/fd5d379c36f4
changeset: 1316:fd5d379c36f4
parent: 1314:6e5312167b4a
user: Mathieu Leduc-Hamel <mlhamel at mtlpy.org>
date: Sat Apr 21 17:42:52 2012 -0400
summary:
#14270: Fixes to add dest_dir params working when using install_from_infos
files:
distutils2/install.py | 18 ++++++++--------
distutils2/tests/test_install.py | 22 ++++++++++++++++++++
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/distutils2/install.py b/distutils2/install.py
--- a/distutils2/install.py
+++ b/distutils2/install.py
@@ -58,7 +58,7 @@
yield old, new
-def _run_distutils_install(path):
+def _run_distutils_install(path, dest):
# backward compat: using setuptools or plain-distutils
cmd = '%s setup.py install --record=%s'
record_file = os.path.join(path, 'RECORD')
@@ -69,7 +69,7 @@
egginfo_to_distinfo(record_file, remove_egginfo=True)
-def _run_setuptools_install(path):
+def _run_setuptools_install(path, dest):
cmd = '%s setup.py install --record=%s --single-version-externally-managed'
record_file = os.path.join(path, 'RECORD')
@@ -80,12 +80,12 @@
egginfo_to_distinfo(record_file, remove_egginfo=True)
-def _run_packaging_install(path):
+def _run_packaging_install(path, dest):
# XXX check for a valid setup.cfg?
dist = Distribution()
dist.parse_config_files()
try:
- dist.run_command('install_dist')
+ dist.run_command('install_dist', dict(prefix=(None,dest)))
name = dist.metadata['Name']
return database.get_distribution(name) is not None
except (IOError, os.error, PackagingError, CCompilerError), msg:
@@ -106,7 +106,7 @@
if where is None:
raise ValueError('Cannot locate the unpacked archive')
- return _run_install_from_archive(where)
+ return _run_install_from_archive(where, path)
def install_local_project(path):
@@ -134,14 +134,14 @@
return False
-def _run_install_from_archive(source_dir):
+def _run_install_from_archive(source_dir, dest_dir):
# XXX need a better way
for item in os.listdir(source_dir):
fullpath = os.path.join(source_dir, item)
if os.path.isdir(fullpath):
source_dir = fullpath
break
- return _run_install_from_dir(source_dir)
+ return _run_install_from_dir(source_dir, dest_dir)
install_methods = {
@@ -150,7 +150,7 @@
'distutils': _run_distutils_install}
-def _run_install_from_dir(source_dir):
+def _run_install_from_dir(source_dir, destination_dir=None):
old_dir = os.getcwd()
os.chdir(source_dir)
install_method = get_install_method(source_dir)
@@ -158,7 +158,7 @@
try:
func = install_methods[install_method]
try:
- func(source_dir)
+ func(source_dir, destination_dir)
return True
except ValueError, err:
# failed to install
diff --git a/distutils2/tests/test_install.py b/distutils2/tests/test_install.py
--- a/distutils2/tests/test_install.py
+++ b/distutils2/tests/test_install.py
@@ -1,6 +1,8 @@
"""Tests for the distutils2.install module."""
import os
import logging
+import sys
+
from tempfile import mkstemp
from distutils2 import install
@@ -258,6 +260,26 @@
for key in expect:
self.assertEqual(expect[key], dict1[key])
+ def test_install_custom_dir(self):
+ dest = self.mkdtemp()
+ src = self.mkdtemp()
+
+ project_dir, dist = self.create_dist(
+ name='Spamlib', version='0.1',
+ data_files={'spamd': '{scripts}/spamd'})
+
+ dist.name = MagicMock(return_value='Spamlib')
+ dist.version = MagicMock(return_value='0.1')
+ dist.unpack = MagicMock(return_value=project_dir)
+
+ self.write_file([project_dir, 'setup.cfg'],
+ ("[metadata]\n"
+ "name = mypackage\n"
+ "version = 0.1.0\n"))
+
+ install.install_from_infos(dest, install=[dist])
+ self.assertEqual(len(os.listdir(dest)), 1)
+
def test_install_dists_rollback(self):
# if one of the distribution installation fails, call uninstall on all
# installed distributions.
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list