Skip to content

Commit 5af5617

Browse files
committed
Bug fix: Uninstall old packages before installing new ones (issue #7)
See issue #7 on GitHub: #7
1 parent 8f0cdf0 commit 5af5617

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pip_accel/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"""
2222

2323
# Semi-standard module versioning.
24-
__version__ = '0.8.16'
24+
__version__ = '0.8.17'
2525

2626
# Standard library modules.
2727
import logging
@@ -384,16 +384,17 @@ def install_requirements(requirements, install_prefix=ENVIRONMENT):
384384
if not filename:
385385
logger.error("Error: No binary distribution of %s (%s) available!", name, version)
386386
return False
387-
install_binary_dist(filename, install_prefix=install_prefix)
387+
install_binary_dist(name, filename, install_prefix=install_prefix)
388388
logger.info("Finished installing all requirements in %s.", install_timer)
389389
return True
390390

391-
def install_binary_dist(filename, install_prefix=ENVIRONMENT):
391+
def install_binary_dist(package, filename, install_prefix=ENVIRONMENT):
392392
"""
393393
Install a binary distribution created with ``python setup.py bdist`` into
394394
the given prefix (a directory like ``/usr``, ``/usr/local`` or a virtual
395395
environment).
396396
397+
:param package: The name of the package to install.
397398
:param filename: The pathname of the tar archive.
398399
:param install_prefix: The "prefix" under which the requirements should be
399400
installed. This will be a pathname like ``/usr``,
@@ -408,7 +409,10 @@ def install_binary_dist(filename, install_prefix=ENVIRONMENT):
408409
# places based on the "seed" environment.
409410
install_timer = Timer()
410411
python = os.path.join(install_prefix, 'bin', 'python')
411-
logger.info("Installing binary distribution %s to %s ..", filename, install_prefix)
412+
pip = os.path.join(install_prefix, 'bin', 'pip')
413+
if os.system('"%s" uninstall --yes "%s" >/dev/null 2>&1' % (pip, package)) == 0:
414+
logger.info("Uninstalled previously installed package %s.", package)
415+
logger.info("Installing package %s from binary distribution %s to %s ..", package, filename, install_prefix)
412416
archive = tarfile.open(filename, 'r:gz')
413417
for member in archive.getmembers():
414418
install_path = os.path.join(install_prefix, member.name)

0 commit comments

Comments
 (0)