mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
added use command. added some functions to bashrc.
This commit is contained in:
@@ -2,13 +2,13 @@ import os
|
||||
import sys
|
||||
from pythonbrew.basecommand import Command
|
||||
from pythonbrew.define import PATH_PYTHONS, PATH_BIN
|
||||
from pythonbrew.util import off, symlink, Package
|
||||
from pythonbrew.util import Package, write_current
|
||||
from pythonbrew.log import logger
|
||||
|
||||
class SwitchCommand(Command):
|
||||
name = "switch"
|
||||
usage = "%prog VERSION"
|
||||
summary = "Switch to the given version"
|
||||
summary = "Switch to the given version of python"
|
||||
|
||||
def run_command(self, options, args):
|
||||
if not args:
|
||||
@@ -20,19 +20,10 @@ class SwitchCommand(Command):
|
||||
if not os.path.isdir(pkgdir):
|
||||
logger.info("`%s` is not installed." % pkgname)
|
||||
sys.exit(1)
|
||||
self._switch_dir(pkgdir)
|
||||
logger.info("Switched to %s" % pkgname)
|
||||
|
||||
def _switch_dir(self, pkgdir):
|
||||
off()
|
||||
symlink(pkgdir, "%s/current" % PATH_PYTHONS)
|
||||
pkgbin = os.path.join(pkgdir,'bin')
|
||||
|
||||
# I want better code...
|
||||
current_bin = os.path.join(PATH_PYTHONS,'current','bin')
|
||||
if not os.path.isfile(os.path.join(current_bin,"python")):
|
||||
if os.path.isfile(os.path.join(current_bin,"python3")):
|
||||
symlink(os.path.realpath("%s/python3" % current_bin), os.path.join(PATH_BIN,"python"))
|
||||
elif os.path.isfile(os.path.join(current_bin,"python3.0")):
|
||||
symlink(os.path.realpath("%s/python3.0" % current_bin), os.path.join(PATH_BIN,"python"))
|
||||
write_current('%s:%s' % (PATH_BIN, pkgbin))
|
||||
|
||||
logger.info("Switched to %s" % pkgname)
|
||||
|
||||
SwitchCommand()
|
||||
|
||||
Reference in New Issue
Block a user