summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/install.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-06-16 21:43:15 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-06-16 21:43:15 (GMT)
commit6f67765389f63b49c094ee08017309bcb45d7ed6 (patch)
treeaf25aaec48f44dfb11bac27c5919e6884f7249d3 /Lib/packaging/install.py
parentb6be20ca337348b7cf2b356f9354a4121627add0 (diff)
downloadcpython-6f67765389f63b49c094ee08017309bcb45d7ed6.zip
cpython-6f67765389f63b49c094ee08017309bcb45d7ed6.tar.gz
cpython-6f67765389f63b49c094ee08017309bcb45d7ed6.tar.bz2
Stop binding sys.path as default parameter value in packaging.
The two public functions in database default to sys.path if the given *paths* argument is None; the private functions don’t have default values for their arguments anymore, which is fine as the public functions that call them pass their arguments down. Likewise in install, the functions will pass down their *paths* arguments down to database functions. A one-line unneeded function in install was removed instead of being changed, and the few remaining tests that used brute-force restoration of sys.path have been cleaned up to use sys.path.remove.
Diffstat (limited to 'Lib/packaging/install.py')
-rw-r--r--Lib/packaging/install.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/Lib/packaging/install.py b/Lib/packaging/install.py
index c5bda45..551ece1 100644
--- a/Lib/packaging/install.py
+++ b/Lib/packaging/install.py
@@ -54,10 +54,8 @@ def _move_files(files, destination):
try:
os.makedirs(os.path.dirname(new))
except OSError as e:
- if e.errno == errno.EEXIST:
- pass
- else:
- raise e
+ if e.errno != errno.EEXIST:
+ raise
os.rename(old, new)
yield old, new
@@ -169,7 +167,7 @@ def _run_install_from_dir(source_dir):
os.chdir(old_dir)
-def install_dists(dists, path, paths=sys.path):
+def install_dists(dists, path, paths=None):
"""Install all distributions provided in dists, with the given prefix.
If an error occurs while installing one of the distributions, uninstall all
@@ -196,13 +194,13 @@ def install_dists(dists, path, paths=sys.path):
# reverting
for installed_dist in installed_dists:
logger.info('Reverting %s', installed_dist)
- _remove_dist(installed_dist, paths)
+ remove(installed_dist.name, paths)
raise e
return installed_dists
def install_from_infos(install_path=None, install=[], remove=[], conflicts=[],
- paths=sys.path):
+ paths=None):
"""Install and remove the given distributions.
The function signature is made to be compatible with the one of get_infos.
@@ -383,11 +381,7 @@ def _update_infos(infos, new_infos):
infos[key].extend(new_infos[key])
-def _remove_dist(dist, paths=sys.path):
- remove(dist.name, paths)
-
-
-def remove(project_name, paths=sys.path, auto_confirm=True):
+def remove(project_name, paths=None, auto_confirm=True):
"""Removes a single project from the installation.
Returns True on success
@@ -539,7 +533,6 @@ def install(project):
def _main(**attrs):
if 'script_args' not in attrs:
- import sys
attrs['requirements'] = sys.argv[1]
get_infos(**attrs)