Added pybrew to bashrc and Help command by default

This commit is contained in:
Yuta
2011-03-19 02:26:44 +09:00
parent 7e494c1c7e
commit 459fdae35f
16 changed files with 111 additions and 62 deletions
+40 -20
View File
@@ -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 <http://github.com/gugod/App-perlbrew>`_.
pythonbrew is inspired by `perlbrew <http://github.com/gugod/App-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 <version>
Switch to the given version of python.
Permanently use the specified python as default.
use <version>
Using the given version of python.
(current shell only)
Use the specified python in current shell.
py <python file>
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 "<labs.ninxit@gmail.com>".
LICENCE
=======
The MIT License
Copyright (c) <2010-2011> <utahta>
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.
+39 -19
View File
@@ -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 <http://github.com/gugod/App-perlbrew>`_.
pythonbrew is inspired by `perlbrew <http://github.com/gugod/App-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 <version>
Switch to the given version of python.
Permanently use the specified python as default.
use <version>
Using the given version of python.
(current shell only)
Use the specified python in current shell.
py <python file>
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 "<labs.ninxit@gmail.com>".
LICENCE
=======
The MIT License
Copyright (c) <2010-2011> <utahta>
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.
+2 -3
View File
@@ -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()
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -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:
-1
View File
@@ -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')
+1 -1
View File
@@ -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):
+1 -2
View File
@@ -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')
+5 -1
View File
@@ -89,6 +89,10 @@ pythonbrew()
builtin hash -r
}
pybrew()
{
pythonbrew "$@"
}
# main
__pythonbrew_set_current_path
+1 -4
View File
@@ -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()
+1 -1
View File
@@ -1,3 +1,3 @@
def test_install_pythonbrew():
from pythonbrew.installer import install_pythonbrew
install_pythonbrew()
install_pythonbrew()
+3 -2
View File
@@ -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])
+3 -2
View File
@@ -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])
+3 -2
View File
@@ -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])
+7
View File
@@ -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])
+3 -2
View File
@@ -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])