pythonz
is a program to automate the building and installation of Python versions in the user's $HOME
. This is
a fork of the original project, pythonbrew.
The original project seems to be unmaintained, and it also has some extra features which I don't really need, so I made this fork to make something a bit simpler that works for me. You may also find it useful.
CPython, Stackless, PyPy and Jython are supported.
The recommended way to download and install pythonz
is to run these statements in your shell:
curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
or:
fetch -o - https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
After that, pythonz
installs itself to ~/.pythonz
.
Please add the following line to the end of your ~/.bashrc
:
[[ -s $HOME/.pythonz/etc/bashrc ]] && source $HOME/.pythonz/etc/bashrc
If you need to install pythonz
into somewhere else, you can do that by setting a PYTHONZ_ROOT
environment variable:
export PYTHONZ_ROOT=/path/to/pythonz curl -kLO https://raw.github.com/saghul/pythonz/master/pythonz-install chmod +x pythonz-install ./pythonz-install
If the install script is run as root, pythonz
will automatically install into /usr/local/pythonz
.
pythonz
will be automatically configured for every user on the system if you install it as root.
After installing it, where you would normally use sudo
, non-root users will need to use sudo-pythonz
:
sudo-pythonz install 3.8.0
You might want to install some optional dependencies, for functionality that is often expected to be included in a Python build (it can be a bummer to discover these missing and have to rebuild your Python setup). These include the following, ordered by (very roughly guessed) probability that you will need them:
sudo apt-get install build-essential zlib1g-dev libbz2-dev libssl-dev libreadline-dev libncurses5-dev libsqlite3-dev libgdbm-dev libdb-dev libexpat-dev libpcap-dev liblzma-dev libpcre3-dev libffi-dev
If you need tkinter support, add tk-dev
.
yum groupinstall "Development tools" yum install zlib-devel bzip2-devel openssl-devel readline-devel ncurses-devel sqlite-devel gdbm-devel db4-devel expat-devel libpcap-devel xz-devel pcre-devel libffi-devel
If you need tkinter support, add tk-devel
.
Apple stopped including the OpenSSL development headers in OS X El Captian and macOS Sierra. You will need to install OpenSSL with Homebrew (or MacPorts). This document assumes usage of Homebrew.
xcode-select --install brew install openssl
You should then add variables for CPPFLAGS
and LDFLAGS
to your shell environment. This allows pythonz
to find the OpenSSL installed by Homebrew.
export CPPFLAGS="-I/usr/local/opt/openssl/include" export LDFLAGS="-L/usr/local/opt/openssl/lib"
pythonz command [options] version
pythonz help
pythonz help <command>
pythonz install 2.7.3 pythonz install -t stackless 2.7.2 pythonz install -t jython 2.5.2 pythonz install -t pypy --url https://bitbucket.org/pypy/pypy/downloads/pypy-1.8-osx64.tar.bz2 1.8 pythonz install --verbose 2.7.2 pythonz install --configure="CC=gcc_4.1" 2.7.2 pythonz install --url http://www.python.org/ftp/python/2.7/Python-2.7.2.tgz 2.7.2 pythonz install --file /path/to/Python-2.7.2.tgz 2.7.2 pythonz install 2.7.3 3.2.3 pythonz install -t pypy3 2.3.1
pythonz list
pythonz list -a
pythonz list -a -t jython
pythonz uninstall 2.7.3 pythonz uninstall -t stackless 3.2.2
pythonz cleanup
pythonz update
pythonz version
pythonz locate 2.7.7
Use virtualenv
, e.g.:
mkvirtualenv -p $(pythonz locate 2.7.3) python2.7.3
For more information about virtualenv
, check out the virtualenv documentation.
Use venv
directly from Python, e.g.:
/usr/local/pythonz/pythons/CPython-3.4.1/bin/python3 -m venv python3.4.1
For more information about venv
, check out the venv documentation.
CPython versions 2.7.6 and 3.3.4 can be built with DTrace suport. Patches adding support for DTrace have been taken from this page by Jesús Cea.
Building Python with DTrace support:
pythonz install --configure="--with-dtrace" 2.7.6