From 459fdae35f191b00f6e8acb4c7d19f55494fc00e Mon Sep 17 00:00:00 2001 From: Yuta Date: Sat, 19 Mar 2011 02:26:44 +0900 Subject: [PATCH] Added pybrew to bashrc and Help command by default --- PKG-INFO | 60 +++++++++++++++++++---------- README.rst | 58 +++++++++++++++++++--------- pythonbrew/__init__.py | 5 +-- pythonbrew/commands/switch.py | 2 +- pythonbrew/commands/use.py | 2 +- pythonbrew/define.py | 1 - pythonbrew/downloader.py | 2 +- pythonbrew/installer.py | 3 +- pythonbrew/scripts/bashrc | 6 ++- tests/__init__.py | 5 +-- tests/test_00_install_pythonbrew.py | 2 +- tests/test_04_install.py | 5 ++- tests/test_05_switch.py | 5 ++- tests/test_06_use.py | 5 ++- tests/test_09_py.py | 7 ++++ tests/test_10_uninstall.py | 5 ++- 16 files changed, 111 insertions(+), 62 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index 4f200e8..b864294 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,21 +1,27 @@ Overview ======== -pythonbrew is a program to automate the building and installation of Python in the users HOME. +pythonbrew is a program to automate the building and installation of python in the users HOME. -pythonbrew is based on `perlbrew `_. +pythonbrew is inspired by `perlbrew `_. Installation ============ -The recommended way to download and install pythonbrew is to run these statements in your shell.:: +The recommended way to download and install pythonbrew is to run these statements in your shell:: easy_install pythonbrew pythonbrew_install -After that, pythonbrew installs itself to ~/.pythonbrew, and you should follow the instruction on screen to setup your .bashrc or .cshrc to put it in your PATH. +or not use easy_install like this:: -If you need to install pythonbrew into somewhere else, you can do that by setting a PYTHONBREW_ROOT environment variable.:: + curl -kLO http://github.com/utahta/pythonbrew/raw/master/pythonbrew-install + chmod +x pythonbrew-install + ./pythonbrew-install + +After that, pythonbrew installs itself to ~/.pythonbrew, and you should follow the instruction on screen to setup your .bashrc to put it in your PATH. + +If you need to install pythonbrew into somewhere else, you can do that by setting a PYTHONBREW_ROOT environment variable:: export PYTHONBREW_ROOT=/path/to/pythonbrew pythonbrew_install @@ -25,7 +31,7 @@ Usage pythonbrew command [options] -Install some Pythons:: +Install some pythons:: pythonbrew install 2.6.6 pythonbrew install --force 2.5.5 @@ -35,12 +41,12 @@ Install some Pythons:: pythonbrew install file:///path/to/Python-2.7.tgz pythonbrew install /path/to/Python-2.7.tgz -Switch python in the PATH:: +Permanently use the specified python as default:: pythonbrew switch 2.6.6 pythonbrew switch 2.5.5 -Using python in the PATH (current shell only):: +Use the specified python in current shell:: pythonbrew use 2.6.6 @@ -48,17 +54,17 @@ Runs a named python file against specified and/or all pythons:: pythonbrew py test.py pythonbrew py -v test.py # Show version - pythonbrew py -p 2.6.6 -p 3.1.2 test.py # Using specified python versions + pythonbrew py -p 2.6.6 -p 3.1.2 test.py # Use the specified pythons -List the installed versions of Python:: +List the installed pythons:: pythonbrew list -List the available install versions of Python:: +List the available install pythons:: pythonbrew list -k -Uninstall some Pythons:: +Uninstall the specified python:: pythonbrew uninstall 2.6.6 @@ -92,11 +98,10 @@ installed List the installed versions of python. switch - Switch to the given version of python. + Permanently use the specified python as default. use - Using the given version of python. - (current shell only) + Use the specified python in current shell. py Runs a named python file against specified and/or all pythons. @@ -134,12 +139,27 @@ Options \-n | --no-setuptools Skip installation of setuptools. -COPYRIGHT -========= - -Copyright (c) 2010, utahta "". - LICENCE ======= The MIT License + +Copyright (c) <2010-2011> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.rst b/README.rst index ed72020..2580769 100644 --- a/README.rst +++ b/README.rst @@ -3,18 +3,24 @@ Overview pythonbrew is a program to automate the building and installation of Python in the users HOME. -pythonbrew is based on `perlbrew `_. +pythonbrew is inspired by `perlbrew `_. Installation ============ -The recommended way to download and install pythonbrew is to run these statements in your shell.:: +The recommended way to download and install pythonbrew is to run these statements in your shell:: + + curl -kLO http://github.com/utahta/pythonbrew/raw/master/pythonbrew-install + chmod +x pythonbrew-install + ./pythonbrew-install + +or more simply like this:: curl -kL http://github.com/utahta/pythonbrew/raw/master/pythonbrew-install | bash -After that, pythonbrew installs itself to ~/.pythonbrew, and you should follow the instruction on screen to setup your .bashrc or .cshrc to put it in your PATH. +After that, pythonbrew installs itself to ~/.pythonbrew, and you should follow the instruction on screen to setup your .bashrc to put it in your PATH. -If you need to install pythonbrew into somewhere else, you can do that by setting a PYTHONBREW_ROOT environment variable.:: +If you need to install pythonbrew into somewhere else, you can do that by setting a PYTHONBREW_ROOT environment variable:: export PYTHONBREW_ROOT=/path/to/pythonbrew ./pythonbrew-install @@ -24,7 +30,7 @@ Usage pythonbrew command [options] -Install some Pythons:: +Install some pythons:: pythonbrew install 2.6.6 pythonbrew install --force 2.5.5 @@ -34,12 +40,12 @@ Install some Pythons:: pythonbrew install file:///path/to/Python-2.7.tgz pythonbrew install /path/to/Python-2.7.tgz -Switch python in the PATH:: +Permanently use the specified python as default:: pythonbrew switch 2.6.6 pythonbrew switch 2.5.5 -Using python in the PATH (current shell only):: +Use the specified python in current shell:: pythonbrew use 2.6.6 @@ -47,17 +53,17 @@ Runs a named python file against specified and/or all pythons:: pythonbrew py test.py pythonbrew py -v test.py # Show version - pythonbrew py -p 2.6.6 -p 3.1.2 test.py # Using specified python versions + pythonbrew py -p 2.6.6 -p 3.1.2 test.py # Use the specified pythons -List the installed versions of Python:: +List the installed pythons:: pythonbrew list -List the available install versions of Python:: +List the available install pythons:: pythonbrew list -k -Uninstall some Pythons:: +Uninstall the specified python:: pythonbrew uninstall 2.6.6 @@ -91,11 +97,10 @@ installed List the installed versions of python. switch - Switch to the given version of python. + Permanently use the specified python as default. use - Using the given version of python. - (current shell only) + Use the specified python in current shell. py Runs a named python file against specified and/or all pythons. @@ -133,12 +138,27 @@ Options \-n | --no-setuptools Skip installation of setuptools. -COPYRIGHT -========= - -Copyright (c) 2010, utahta "". - LICENCE ======= The MIT License + +Copyright (c) <2010-2011> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/pythonbrew/__init__.py b/pythonbrew/__init__.py index 1335db3..26fd0f4 100644 --- a/pythonbrew/__init__.py +++ b/pythonbrew/__init__.py @@ -5,10 +5,9 @@ from pythonbrew.baseparser import parser def main(): options, args = parser.parse_args(sys.argv[1:]) if options.help and not args: - args = ["help"] + args = ['help'] if not args: - parser.error('You must give a command (use "pythonbrew help" to see a list of commands)') - return + args = ['help'] # as default load_all_commands() command = args[0].lower() diff --git a/pythonbrew/commands/switch.py b/pythonbrew/commands/switch.py index d553ccb..2fcfc29 100644 --- a/pythonbrew/commands/switch.py +++ b/pythonbrew/commands/switch.py @@ -8,7 +8,7 @@ from pythonbrew.log import logger class SwitchCommand(Command): name = "switch" usage = "%prog VERSION" - summary = "Switch to the given version of python" + summary = "Permanently use the specified python as default" def run_command(self, options, args): if not args: diff --git a/pythonbrew/commands/use.py b/pythonbrew/commands/use.py index bbea076..0b7c200 100644 --- a/pythonbrew/commands/use.py +++ b/pythonbrew/commands/use.py @@ -8,7 +8,7 @@ from pythonbrew.log import logger class UseCommand(Command): name = "use" usage = "%prog VERSION" - summary = "Using the given version of python" + summary = "Use the specified python in current shell" def run_command(self, options, args): if not args: diff --git a/pythonbrew/define.py b/pythonbrew/define.py index 725159e..4b8b97b 100644 --- a/pythonbrew/define.py +++ b/pythonbrew/define.py @@ -26,7 +26,6 @@ PATH_PATCHES_MACOSX_PYTHON24 = os.path.join(PATH_PATCHES_MACOSX,"python24") # files PATH_BIN_PYTHONBREW = os.path.join(PATH_BIN,'pythonbrew') -PATH_BIN_PYBREW = os.path.join(PATH_BIN,'pybrew') # pybrew is symbolic link of pythonbrew PATH_ETC_CURRENT = os.path.join(PATH_ETC,'current') PATH_ETC_TEMP = os.path.join(PATH_ETC,'temp') diff --git a/pythonbrew/downloader.py b/pythonbrew/downloader.py index 7b9134e..5ea72f6 100644 --- a/pythonbrew/downloader.py +++ b/pythonbrew/downloader.py @@ -9,7 +9,7 @@ def get_headerinfo_from_url(url): def get_stable_version(): c = Curl() - return c.read(PYTHONBREW_STABLE_VERSION_URL) + return c.read(PYTHONBREW_STABLE_VERSION_URL).strip() class Downloader(object): def download(self, msg, url, path): diff --git a/pythonbrew/installer.py b/pythonbrew/installer.py index 828001f..b917192 100644 --- a/pythonbrew/installer.py +++ b/pythonbrew/installer.py @@ -12,7 +12,7 @@ from pythonbrew.util import makedirs, symlink, Package, is_url, Link,\ from pythonbrew.define import PATH_BUILD, PATH_BIN, PATH_DISTS, PATH_PYTHONS,\ PATH_ETC, PATH_SCRIPTS, PATH_SCRIPTS_PYTHONBREW,\ PATH_SCRIPTS_PYTHONBREW_COMMANDS, INSTALLER_ROOT, PATH_BIN_PYTHONBREW,\ - PATH_BIN_PYBREW, ROOT, PATH_LOG, DISTRIBUTE_SETUP_DLSITE, PATH_PATCHES,\ + ROOT, PATH_LOG, DISTRIBUTE_SETUP_DLSITE, PATH_PATCHES,\ PATH_PATCHES_MACOSX_PYTHON25, PATH_PATCHES_MACOSX_PYTHON24 from pythonbrew.downloader import get_python_version_url, Downloader,\ get_headerinfo_from_url @@ -99,7 +99,6 @@ if __name__ == "__main__": """ % (sys.executable, PATH_SCRIPTS)) fp.close() os.chmod(PATH_BIN_PYTHONBREW, 0755) - symlink(PATH_BIN_PYTHONBREW, PATH_BIN_PYBREW) # pybrew is symbolic link of pythonbrew # create bashrc fp = open(os.path.join(PATH_ETC,'bashrc'), 'w') diff --git a/pythonbrew/scripts/bashrc b/pythonbrew/scripts/bashrc index c6d9096..6639033 100644 --- a/pythonbrew/scripts/bashrc +++ b/pythonbrew/scripts/bashrc @@ -89,6 +89,10 @@ pythonbrew() builtin hash -r } +pybrew() +{ + pythonbrew "$@" +} + # main __pythonbrew_set_current_path - diff --git a/tests/__init__.py b/tests/__init__.py index d21f0fd..c54c0ff 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -3,7 +3,7 @@ import shutil PYTHONBREW_ROOT = '/tmp/pythonbrew.test' TESTPY_FILE = '/tmp/pythonbrew_test.py' -TESTPY_VERSION = '2.6.6' +TESTPY_VERSION = ['2.4.6', '2.5.5', '2.6.6'] def cleanall(): if os.path.isdir(PYTHONBREW_ROOT): shutil.rmtree(PYTHONBREW_ROOT) @@ -13,9 +13,6 @@ def cleanall(): def setup(): os.environ['PYTHONBREW_ROOT'] = PYTHONBREW_ROOT cleanall() - fp = open(TESTPY_FILE, 'w') - fp.write("print 'test'") - fp.close() def teardown(): cleanall() diff --git a/tests/test_00_install_pythonbrew.py b/tests/test_00_install_pythonbrew.py index bef3c06..30d0471 100644 --- a/tests/test_00_install_pythonbrew.py +++ b/tests/test_00_install_pythonbrew.py @@ -1,3 +1,3 @@ def test_install_pythonbrew(): from pythonbrew.installer import install_pythonbrew - install_pythonbrew() + install_pythonbrew() \ No newline at end of file diff --git a/tests/test_04_install.py b/tests/test_04_install.py index 0b1722f..5f6b68f 100644 --- a/tests/test_04_install.py +++ b/tests/test_04_install.py @@ -7,5 +7,6 @@ class InstallOptions(object): def test_install(): from pythonbrew.commands.install import InstallCommand - c = InstallCommand() - c.run_command(InstallOptions(), [TESTPY_VERSION]) + for py_version in TESTPY_VERSION: + c = InstallCommand() + c.run_command(InstallOptions(), [py_version]) diff --git a/tests/test_05_switch.py b/tests/test_05_switch.py index e6d9fe2..09795ff 100644 --- a/tests/test_05_switch.py +++ b/tests/test_05_switch.py @@ -2,5 +2,6 @@ from tests import TESTPY_VERSION def test_switch(): from pythonbrew.commands.switch import SwitchCommand - c = SwitchCommand() - c.run_command(None, [TESTPY_VERSION]) + for py_version in TESTPY_VERSION: + c = SwitchCommand() + c.run_command(None, [py_version]) diff --git a/tests/test_06_use.py b/tests/test_06_use.py index ebd5ce3..87c0722 100644 --- a/tests/test_06_use.py +++ b/tests/test_06_use.py @@ -2,5 +2,6 @@ from tests import TESTPY_VERSION def test_use(): from pythonbrew.commands.use import UseCommand - c = UseCommand() - c.run_command(None, [TESTPY_VERSION]) + for py_version in TESTPY_VERSION: + c = UseCommand() + c.run_command(None, [py_version]) diff --git a/tests/test_09_py.py b/tests/test_09_py.py index 54f7e8c..cd82640 100644 --- a/tests/test_09_py.py +++ b/tests/test_09_py.py @@ -4,7 +4,14 @@ class PyOptions(object): pythons = [] verbose = False +def _create_pyfile(): + fp = open(TESTPY_FILE, 'w') + fp.write("print 'test'") + fp.close() + def test_py(): from pythonbrew.commands.py import PyCommand + _create_pyfile() + c = PyCommand() c.run_command(PyOptions(), [TESTPY_FILE]) diff --git a/tests/test_10_uninstall.py b/tests/test_10_uninstall.py index 3327b77..4f8a05b 100644 --- a/tests/test_10_uninstall.py +++ b/tests/test_10_uninstall.py @@ -2,5 +2,6 @@ from tests import TESTPY_VERSION def test_uninstall(): from pythonbrew.commands.uninstall import UninstallCommand - c = UninstallCommand() - c.run_command(None, [TESTPY_VERSION]) + for py_version in TESTPY_VERSION: + c = UninstallCommand() + c.run_command(None, [py_version])