summaryrefslogtreecommitdiff
path: root/distutils2/install.py
diff options
context:
space:
mode:
author?ric Araujo <merwok@netwok.org>2012-05-21 16:54:12 -0400
committer?ric Araujo <merwok@netwok.org>2012-05-21 16:54:12 -0400
commitee6fb9f7f0863a1d0020d57f224947f7b795df6d (patch)
treeb8d155316b2f697621264a83a0ef2ef2802c6859 /distutils2/install.py
parentc57cf8ba29e0b51e614cac580413a183061834d5 (diff)
parent1ed1781f2170be33392c3056f239766b1b1c6a58 (diff)
downloaddisutils2-ee6fb9f7f0863a1d0020d57f224947f7b795df6d.tar.gz
Merge default
Diffstat (limited to 'distutils2/install.py')
-rw-r--r--distutils2/install.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/distutils2/install.py b/distutils2/install.py
index 01f9090..e70dda5 100644
--- a/distutils2/install.py
+++ b/distutils2/install.py
@@ -58,10 +58,12 @@ def _move_files(files, destination):
yield old, new
-def _run_distutils_install(path):
+def _run_distutils_install(path, dest):
# backward compat: using setuptools or plain-distutils
+ # FIXME pass dest argument to the command
cmd = '%s setup.py install --record=%s'
record_file = os.path.join(path, 'RECORD')
+ # FIXME use subprocess
os.system(cmd % (sys.executable, record_file))
if not os.path.exists(record_file):
raise ValueError('failed to install')
@@ -69,7 +71,7 @@ def _run_distutils_install(path):
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 +82,12 @@ def _run_setuptools_install(path):
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', {'prefix': (None, dest)})
name = dist.metadata['Name']
return database.get_distribution(name) is not None
except (IOError, os.error, PackagingError, CCompilerError) as msg:
@@ -106,11 +108,13 @@ def _install_dist(dist, path):
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):
- """Install a distribution from a source directory.
+ """Install a distribution from a source directory or archive.
+
+ If *path* is an archive, it will be unarchived first.
If the source directory contains a setup.py install using distutils1.
If a setup.cfg is found, install using the install_dist command.
@@ -134,14 +138,14 @@ def install_local_project(path):
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,15 +154,14 @@ install_methods = {
'distutils': _run_distutils_install}
-def _run_install_from_dir(source_dir):
+def _run_install_from_dir(source_dir, dest_dir=None):
old_dir = os.getcwd()
os.chdir(source_dir)
- install_method = get_install_method(source_dir)
- func = install_methods[install_method]
try:
+ install_method = get_install_method(source_dir)
func = install_methods[install_method]
try:
- func(source_dir)
+ func(source_dir, dest_dir)
return True
except ValueError as err:
# failed to install
@@ -183,7 +186,7 @@ def install_dists(dists, path, paths=None):
installed_dists = []
for dist in dists:
- logger.info('Installing %r %s...', dist.name, dist.version)
+ logger.info('Installing %s...', dist)
try:
_install_dist(dist, path)
installed_dists.append(dist)
@@ -244,7 +247,8 @@ def install_from_infos(install_path=None, install=[], remove=[], conflicts=[],
temp_dir = tempfile.mkdtemp()
for dist in remove:
files = dist.list_installed_files()
- temp_files[dist] = _move_files(files, temp_dir)
+ paths = [path for path, md5, size in files]
+ temp_files[dist] = _move_files(paths, temp_dir)
try:
if install:
install_dists(install, install_path, paths)