diff --git a/.gitignore b/.gitignore index 398889b..1e2444e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ *.pyc pythonbrew.egg-info dist +__pycache__ diff --git a/README.rst b/README.rst index b460033..3a60d0d 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ Overview pythonbrew is a program to automate the building and installation of Python in the users HOME. -pythonbrew is inspired by `perlbrew `_. +pythonbrew is inspired by `perlbrew `_ and `rvm `_. Installation ============ diff --git a/pythonbrew/commands/symlink.py b/pythonbrew/commands/symlink.py index f4cde22..b64768f 100644 --- a/pythonbrew/commands/symlink.py +++ b/pythonbrew/commands/symlink.py @@ -35,8 +35,7 @@ class SymlinkCommand(Command): def run_command(self, options, args): if options.default: - """create only one instance as default of an application. - """ + # create only one instance as default of an application. pythons = self._get_pythons([options.default]) for pkgname in pythons: if args: @@ -48,11 +47,13 @@ class SymlinkCommand(Command): pythons = self._get_pythons(options.pythons) for pkgname in pythons: if options.remove: + # remove symlinks for bin in os.listdir(PATH_BIN): path = os.path.join(PATH_BIN, bin) if os.path.islink(path): unlink(path) else: + # create symlinks if args: bin = args[0] self._symlink_version_suffix(bin, bin, pkgname) diff --git a/pythonbrew/commands/uninstall.py b/pythonbrew/commands/uninstall.py index 9e6f40f..19f506d 100644 --- a/pythonbrew/commands/uninstall.py +++ b/pythonbrew/commands/uninstall.py @@ -1,7 +1,7 @@ import os from pythonbrew.basecommand import Command -from pythonbrew.define import PATH_PYTHONS -from pythonbrew.util import off, rm_r, Package, get_current_python_path +from pythonbrew.define import PATH_PYTHONS, PATH_BIN +from pythonbrew.util import off, rm_r, Package, get_current_python_path, unlink from pythonbrew.log import logger class UninstallCommand(Command): @@ -21,6 +21,14 @@ class UninstallCommand(Command): continue if get_current_python_path() == os.path.join(pkgpath,'bin','python'): off() + for d in os.listdir(PATH_BIN): + # remove symlink + path = os.path.join(PATH_BIN, d) + if os.path.islink(path): + basename = os.path.basename(os.path.realpath(path)) + tgtpath = os.path.join(pkgpath, 'bin', basename) + if os.path.isfile(tgtpath) and os.path.samefile(path, tgtpath): + unlink(path) rm_r(pkgpath) else: self.parser.print_help()