Code Monkey home page Code Monkey logo

pythonz's Introduction

pythonz: a Python installation manager

Overview

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.

Installation

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

For Systemwide (Multi-User) installation

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

Before installing Python versions via pythonz

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:

Debian family (Ubuntu...)

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.

RPM family (CentOS, RHEL...)

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.

macOS

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"

Usage

pythonz command [options] version

See the available commands

pythonz help

To get help on each individual command

pythonz help <command>

Install some Python versions

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

List the installed Python versions

pythonz list

List all the available Python versions for installing

pythonz list -a

List all the available Jython versions

pythonz list -a -t jython

Uninstall the specified Python

pythonz uninstall 2.7.3
pythonz uninstall -t stackless 3.2.2

Remove stale source folders and archives

pythonz cleanup

Upgrade pythonz to the latest version

pythonz update

Check the installed pythonz version

pythonz version

Print the path to the interpreter of a given version

pythonz locate 2.7.7

Recommended way to use a pythonz-installed version of Python

For Python <= 3.2

Use virtualenv, e.g.:

mkvirtualenv -p $(pythonz locate 2.7.3) python2.7.3

For more information about virtualenv, check out the virtualenv documentation.

For Python >= 3.3

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.

DTrace support

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

pythonz's People

Contributors

02strich avatar 0cjs avatar aflyhorse avatar astrojuanlu avatar berdario avatar davidszotten avatar edliaw avatar eliasdorneles avatar flub avatar gthb avatar holmboe avatar ibuchanan avatar ifduyue avatar inirudebwoy avatar kdm9 avatar kgaughan avatar lepture avatar lgw4 avatar ludovic-gasc avatar mikix avatar msabramo avatar robsonpeixoto avatar saghul avatar sivel avatar tgs avatar tonyseek avatar totakke avatar ulope avatar utahta avatar yamaneko1212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pythonz's Issues

Pythonz without pythonz-install? (or silent pythonz-install)

Hi, I'd like to drive pythonz from another program (specifically, I was thinking of adding pythonz as a dependency of pew).

For this I tried to install pythonz with the setup.py, and apparently it can work even without running the pythonz-install step (you have to workaround some errors, but it's doable).

I'd prefer if there was no pythonz-install step altogether, it should be relatively easy to adapt it:

just use the INSTALLER_ROOT ( os.path.dirname(os.path.abspath(__file__)) works just fine even inside a setuptools-installed source code), instead of the PYTHONZ_ROOT to get the path for patches, shell scripts, etc. (the MANIFEST.in apparently already ships the needed ).

The update command then wouldn't obviously relied upon anymore (but as long as it can be securely downloaded, a file that specifies the new versions and the needed patches could still be downloaded into PYTHONZ_ROOT, but this is an even bigger change).

Failing this, it'd be nice to at least be able to run a silent installation (without having to muck with the stdout). The installation message asks the user to load the supplied bashrc, but I'm also not sure: it seems mostly to be useful wrappers for completion and the like, but I don't know if by avoiding to use them I might stumble into other problems.

It'd also be useful to have it available on Pypi: Pythonbrew is already there. (This should be another issue, and I could do it myself, but it's probably best to discuss this in advance as well)

I don't know the history of Pythonbrew/Pythonz, so I'm not sure about the policy that you have about such changes. I had a look at the codebase, and apparently there're things kept only for compatibility with older python versions (as the host interpreter for pythonz, I mean), and since what I'm proposing might be controversial I haven't prepared any PR nor tweaked any line of code before opening this issue. (I'd also like to get rid of the code that uses shell=True in subprocess.call for example)

Sorry if this is a sort of brain-dump and not properly structured.

Stackless 3.3.5 install fails

When installing Stackless Python version 3.3.5, I get the following error:

$ pythonz install -t stackless 3.3.5 
Downloading stackless-335-export.tar.bz2 as /Users/lgw4/.pythonz/dists/stackless-335-export.tar.bz2
########################################################################## 100%
Extracting stackless-335-export.tar.bz2 into /Users/lgw4/.pythonz/build/Stackless-3.3.5

This could take a while. You can run the following command on another shell to track the status:
  tail -f /Users/lgw4/.pythonz/log/build.log

Installing Stackless-3.3.5 into /Users/lgw4/.pythonz/pythons/Stackless-3.3.5
Traceback (most recent call last):
  File "/Users/lgw4/.pythonz/scripts/pythonz/installer/pythoninstaller.py", line 195, in install
    self.make()
  File "/Users/lgw4/.pythonz/scripts/pythonz/installer/pythoninstaller.py", line 342, in make
    s.check_call(make)
  File "/Users/lgw4/.pythonz/scripts/pythonz/util.py", line 298, in check_call
    raise ShellCommandException('%s: failed to `%s`' % (returncode, cmd))
ShellCommandException: 2: failed to `make -j4`
ERROR: Failed to install Stackless-3.3.5. Check /Users/lgw4/.pythonz/log/build.log to see why.

Here is a gist for the build.log: https://gist.github.com/lgw4/d47947929cba58196d5f

I'm on OS X 10.9.3.

Command for executing commands in specific Python versions

It would be immensely time saving if instead of ~/.pythonz/pythons/PyPy-1.9/bin/ipython I could do pz pypy-1.9 ipython or pz pypy ipython (automatically selects the latest pypy). Ideally, it would also provide bash autocompletion for completing of both the Python version and the command to execute.

Install --prefix

It'd be nice to be able to provide an installation directory, for scriptability purposes :)

Other pythons

While working on the checksums PR, I realized that there are some python versions that aren't currently covered:

  • Newer stackless versions
  • Portable Pypy
  • Precompiled ARM versions for Pypy
  • Ironpython
  • Conda distribution? (actually, this is the same version as Cpython, but it has a "different stdlib" and doesn't integrate properly with pip, so I guess that pyenv has it for that reason... but maybe now that venv and ensurepip are in the stdlib Conda is just legacy? not sure)
  • I just realized that there might be something else as well that is missing, like Nuitka

I don't actually have a need for these versions, I just wanted to note this stuff down

Compiler failing for CPython 2.5, sometimes not reproducible

I was having gcc errors in my Arch Linux system which always ended like this:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes  -I. -I./Include   -DPy_BUILD_CORE  -c ./Modules/xxsubtype.c -o Modules/xxsubtype.o
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes  -I. -I./Include   -DPy_BUILD_CORE -DSVNVERSION=\"`LANG=C svnversion .`\" -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
gcc: error: directory": No such file or directory
make: *** [Modules/getbuildinfo.o] Error 1

and in pythonz

ShellCommandException: 2: failed to `make -j8`

But then I switched to a clean ISO Linux Mint and these errors didn't appear. Actually first I got a syntax error identical to #21, but when I applied the corresponding patch the built went on successfully. I tried to force -j1 just in case there was some strange race condition but the result was the same.

OTOH, it is not related to the bug but interestingly enough tail -f didn't follow file changes in Mint.

Missing builtin modules

Default Pythonz 2.7.5 build only has a few builtin modules enabled.

'__builtin__', '__main__', '_ast', '_codecs', '_sre', '_symtable', '_warnings', '_weakref', 'errno', 'exceptions', 'gc', 'imp', 'marshal', 'posix', 'pwd', 'signal', 'sys', 'thread', 'xxsubtype', 'zipimport'

My out-of-the-box Python2.7.3 package on Ubuntu12.04:

'__builtin__', '__main__', '_ast', '_bisect', '_codecs', '_collections', '_functools', '_hashlib', '_locale', '_random', '_socket', '_sre', '_ssl', '_struct', '_symtable', '_warnings', '_weakref', 'array', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'errno', 'exceptions', 'fcntl', 'gc', 'grp', 'imp', 'itertools', 'marshal', 'math', 'operator', 'posix', 'pwd', 'select', 'signal', 'spwd', 'strop', 'sys', 'syslog', 'thread', 'time', 'unicodedata', 'xxsubtype', 'zipimport', 'zlib'

I read a lot of makefile/installer source code, but I'm still unsure how to enable more builtin modules in pythonz.

Support reinstall of already-installed Python

I find that a production Python setup lacks the _bsddb module, so I apt-get install libdb4.8-dev and then want to rebuild Python 2.7.6 to have that module. But pythonz refuses to install it because it's already installed, and there's no flag to force it. I would prefer not to uninstall it and then start a build from scratch, because my existing Python is in use and would presumably be broken in the meantime.

So ideally I'd want to force a reinstall of 2.7.6, which would go through the whole build and then only affect the system at the end, replacing the previous Python install. Something like sudo-pythonz reinstall 2.7.6 or sudo-pythonz install --reinstall 2.7.6

I could probably fudge this with a whole second pythonz install (export PYTHONZ_ROOT=/usr/local/pythonz2) but that seems unnecessarily messy.

Bash 3 compatibility broken

As of a1224c4 pythonz bash completion requires Bash 4 because of the use of associative arrays. Under older Bash this is emitted on login (or whenever $HOME/.pythonz/etc/bashrc is executed):

-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]

Versions list is no longer sorted

Since (at least) the last update the versions list appears unsorted:

○ pythonz list -a
# Available Python versions
  # cpython:
     3.1.3
     3.1.2
     3.1.1
     3.1.5
     3.1.4
     2.4.3
     2.4.2
     2.4.1
     2.4.6
     2.4.5
     2.4.4
     2.6.9
     2.6.8
     2.6.1
     2.6.3
     2.6.2
     2.6.5
     2.6.4
     2.6.7
     2.6.6
     3.3.1
     3.3.0
     3.3.3
     3.3.2
     3.3.5
     3.3.4
     3.3.6
     3.0.1
     2.7.10
     3.2
     3.0
     3.1
     3.5.0
     2.7
     2.6
     2.5
     2.4
     2.5.6
     2.5.4
     2.5.5
     2.5.2
     2.5.3
     2.5.1
     3.4.2
     3.4.3
     3.4.0
     3.4.1
     2.7.8
     2.7.9
     2.7.4
     2.7.5
     2.7.6
     2.7.7
     2.7.1
     2.7.2
     2.7.3
     3.2.4
     3.2.5
     3.2.1
     3.2.2
     3.2.3
  # stackless:
     3.1.3
     2.6.5
     2.7.2
     3.2.5
     3.3.5
     3.2.2
  # pypy:
     4.0.0
     2.4.0
     2.0.2
     2.0.1
     2.6.1
     2.3.1
     1.8
     1.9
     2.2.1
     2.6.0
     2.3
     2.2
     2.1
     2.0
     2.5.0
     2.5.1
  # pypy3:
     2.3.1
     2.4.0
  # jython:
     2.7.0
     2.5.2
     2.5.3
     2.5.0
     2.5.1

Idempotent install

Scenario: a build system reads a file in a repository to know which version of Python is required. The build system uses pythonz to install that version, unless it already exists. Then the build system proceeds with other build tasks.

The ideal solution would be that pythonz install 2.7.9 has a return code of 0 whenever CPython 2.7.9 already exists, so that installation is idempotent. However, that might break behavior someone currently depends on.

An alternative is an additional parameter, like pythonz install 2.7.9 --no-error-if-installed (or maybe --idempotent if shorter is better). That would have a return code of 0 if CPython 2.7.9 already exists. I get my idempotent command but current behavior remains.

My current quick fix is to alter the behavior of locate so that it can be used as a test whether a version exists (pull request pending). Then my code can do the following:

$VERSION = 2.7.9
if ! pythonz locate $VERSION; then
    pythonz install $VERSION
fi

Merge changes from pythonbrew

Pythonbrew is deprecated, but its author unexplicably still commits/merges a few changes:

utahta/pythonbrew@2b87183

I frankly don't like that, since it leads to duplicated effort and causes resources to be spread more thinly.

Alas, the change I linked to could benefit Pythonz (more tests and travis integration)

Fail on install python 2.5

$ lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.4 (Final)
Release: 6.4
Codename: Final

$ rpm -q python
python-2.6.6-37.el6_4.x86_64

[user@machine /home/user]$ pythonz install 2.5
Use the previously fetched /inco/home01/user/.pythonz/dists/Python-2.5.tgz
Extracting Python-2.5.tgz into /inco/home01/user/.pythonz/build/CPython-2.5

This could take a while. You can run the following command on another shell to track the status:
tail -f /inco/home01/user/.pythonz/log/build.log

Installing CPython-2.5 into /inco/home01/user/.pythonz/pythons/CPython-2.5
ERROR: Failed to patch /inco/home01/user/.pythonz/build/CPython-2.5.
1: failed to (patch -p0 < /inco/home01/user/.pythonz/patches/all/python25/patch-svnversion.patch) >> '/inco/home01/user/.pythonz/log/build.log' 2>&1

Feature req.: Multi-architecture installs

Would it be at all desirable/feasible to have pythonz install unique versions of CPython (and Stackless, I suppose) binaries based on the current system architecture?

I'm thinking here of a very traditional UNIX network environment, where a user might have a single home directory that's NFS-shared among machines with various architectures.

I currently handle this situation by setting PYTHONZ_ROOT to a value that has "uname -smp" interpolated. I.e. I keep a separate pythonz directory for each of the the various architectures in use.

pythonz update broken

$ pythonz version
1.10.0

$ pythonz update
Downloading pythonz-latest.tgz as /usr/local/pythonz/dists/pythonz-latest.tgz
Traceback (most recent call last):
File "/usr/local/pythonz/scripts/pythonz_main.py", line 3, in
pythonz.main()
File "/usr/local/pythonz/scripts/pythonz/init.py", line 42, in main
command.run(args[1:])
File "/usr/local/pythonz/scripts/pythonz/commands/init.py", line 22, in run
self.run_command(options, args)
File "/usr/local/pythonz/scripts/pythonz/commands/update.py", line 27, in run_command
Downloader.fetch(PYTHONZ_UPDATE_URL, download_file)
TypeError: fetch() takes exactly 4 arguments (3 given)

Broken after today commit.

Fix please.

Python dependencies

Hello!

It'd be quite useful if pythonz asked to install dependencies (espicially if it's run as root), for example zlib is rather important for installing pip, and openssl is also necessary to get packages from PyPI (because of HTTPS).

It seems that the up-to-date dependencies are always nicely listed here: http://www.linuxfromscratch.org/blfs/view/svn/general/python3.html
http://www.linuxfromscratch.org/blfs/view/svn/general/python2.html

I know it is a bit of a feature creep, but doing a simple distribution detection and running

apt-get -y install zlib1g-dev libssl-dev libexpat1-dev libffi-dev or the yum/pacman/whatever equivalent does look fairly maintainable, and probably won't turn into a nightmare :)

Make Pythonz more friendly to be used as a library

This would be a sister issue to #73

Basically, while working on that, I realized that for a lot of error conditions, the current action is to sys.exit(1)

That's fine for application level code, but not so for a library.

The code that I added for the checksums PR for example prefers to raise an exception rather than terminating right away, but I refrained from modifying existing code... preferring to hear your opinion before making any such changes

Can't install python 2.6

It seems like install does not install all stuff (the patches dir for example)

root /tmp # curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2596  100  2596    0     0   2662      0 --:--:-- --:--:-- --:--:--  2662
Downloading https://github.com/saghul/pythonz/tarball/master
######################################################################## 100.0%
Extracting /usr/local/pythonz/dists/pythonz-latest.tar.gz
Installing pythonz into /usr/local/pythonz

Well-done! Congratulations!

The pythonz is installed as:

  /usr/local/pythonz

After that, exit this shell, start a new one, and install some fresh
pythons:

  pythonz install 2.7.2
  pythonz install 3.2

For further instructions, run:

  pythonz help

The default help messages will popup and tell you what to do!

Enjoy pythonz at /usr/local/pythonz!!

root /tmp # /usr/local/pythonz/bin/pythonz install 2.6.6      
Use the previously fetched /root/.pythonz/dists/Python-2.6.6.tgz
Extracting Python-2.6.6.tgz into /root/.pythonz/build/CPython-2.6.6

This could take a while. You can run the following command on another shell to track the status:
  tail -f /root/.pythonz/log/build.log

Installing CPython-2.6.6 into /root/.pythonz/pythons/CPython-2.6.6
ERROR: Failed to patch `/root/.pythonz/build/CPython-2.6.6`.
2: failed to `(patch -p0 < /root/.pythonz/patches/all/common/patch-setup.py.diff) >> '/root/.pythonz/log/build.log' 2>&1`
root /tmp # ls -al /root/.pythonz 
total 28
drwxr-xr-x  7 root root 4096 Nov 14 11:15 .
drwx------ 22 root root 4096 Nov 14 11:18 ..
drwxr-xr-x  3 root root 4096 Nov 14 11:18 build
drwxr-xr-x  2 root root 4096 Nov 14 11:15 dists
drwxr-xr-x  2 root root 4096 Nov 14 11:13 etc
drwxr-xr-x  2 root root 4096 Nov 14 11:15 log
drwxr-xr-x  2 root root 4096 Nov 14 11:14 pythons

SyntaxError: invalid syntax Failed to install pythonz.

curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2596 100 2596 0 0 8850 0 --:--:-- --:--:-- --:--:-- 12187
Downloading https://github.com/saghul/pythonz/tarball/master

################################################################## 100.0%

Extracting /home/xenoterracide/.pythonz/dists/pythonz-latest.tar.gz
Installing pythonz into /home/xenoterracide/.pythonz
Traceback (most recent call last):
File "/home/xenoterracide/.pythonz/dists/saghul-pythonz-5b355ac/pythonz_install.py", line 3, in
from pythonz.installer import install_pythonz, upgrade_pythonz, systemwide_pythonz
File "/home/xenoterracide/.pythonz/dists/saghul-pythonz-5b355ac/pythonz/init.py", line 9, in
from pythonz.util import makedirs
File "/home/xenoterracide/.pythonz/dists/saghul-pythonz-5b355ac/pythonz/util.py", line 100
except OSError, e:
^
SyntaxError: invalid syntax
Failed to install pythonz.

Interrupted downloads leave behind unfinished files

Interrupted downloads leave behind unfinished files, and these unfinished files will cause an error during the next attempt to install the same version:


~$ pythonz install --type cpython 2.6.7
Downloading Python-2.6.7.tgz as /Users/erik.allik/.pythonz/dists/Python-2.6.7.tgz
^CTraceback (most recent call last):                                         7%
...
KeyboardInterrupt

~$ pythonz install --type cpython 2.6.7
Use the previously fetched /Users/erik.allik/.pythonz/dists/Python-2.6.7.tgz
Extracting Python-2.6.7.tgz into /Users/erik.allik/.pythonz/build/CPython-2.6.7
Traceback (most recent call last):
...
IOError: CRC check failed 0x9aa41247L != 0x96b934e8L

Push for canonicalization of interpreter names

It could be useful to have a simple standardized schema for the interpreter names shared among different tools.

For example, tox uses basepython and envlist to choose which version of Python to use.

basepython is used to resolve the envlist names to the actual python interpreters (with some default names available), but ultimately it wants either an interpreter name (resolved with PATH to an executable) or an actual executable path.

This means that, unless you pick generic names like "python3.4", it's not portable among machines. And things like pypy3 won't allow to pick among the different versions of pypy3 (I haven't looked deeply to see all the default basepython names, so I might be wrong)

I think that the best place to do this would be in a tool that actually downloads/manages the python interpreters, like Pythonz.

Another advantage, could be to reuse the same .python-version files created by pyenv, allowing Pythonz (or another tool) to automatically propose the installation of the version specified in that file, is not available already.

The same thing could be done with the tox.ini, if Tox was on board: by parsing it, a tool could detect with Python versions are required for the full test suite, and propose the installation of them.

Pythonz currently outputs a camelcase representation with pythonz list, but otherwise, as an input, only uses the version and the --type command line flag.

a more canonical name would be shorter and could be used as a single argument to be supplied to pythonz. Pyenv names could be a good starting point, but there'd be 2 issues to take care:

  • Pyenv doesn't use python-3.5.0, or cpython-3.5.0 but only 3.50 when talking about Cpython versions... it'd be better to be more explicit
  • Pyenv has a bunch of -dev versions... I guess that those could be simply ignored?

This is just a proposal/idea... I wanted to discuss this, rather than starting to implement something similar in Pythonz with the risk of not having consensus on it

Pypy 4.0.0 released

Hi, just an heads up since, if you've been busy, you might have missed it.

pythonz list -a no PyPy

You noted that you had support for PyPy "CPython, Stackless, PyPy and Jython are supported." when I am doing pythonz list -a PyPy is not available.

Don't clean the build directory by default

When doing pythonz cleanup the build directory is removed, so all debug symbols are gone and debugging C extensions properly is no longer possible. Maybe a --all modifier would make sense, mentioning the debug symbols thing in the helper text.

Installing python without zlib

$ pythonz install 2.7.9
Use the previously fetched /Users/robinho/.pythonz/dists/Python-2.7.9.tgz
Extracting Python-2.7.9.tgz into /Users/robinho/.pythonz/build/CPython-2.7.9

This could take a while. You can run the following command on another shell to track the status:
  tail -f /Users/robinho/.pythonz/log/build.log

Installing CPython-2.7.9 into /Users/robinho/.pythonz/pythons/CPython-2.7.9

Installed CPython-2.7.9 successfully.
$ ~/.pythonz/pythons/CPython-2.7.9/bin/python get-pip.py
Traceback (most recent call last):
  File "get-pip.py", line 20204, in <module>
    main()
  File "get-pip.py", line 152, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

Another example:

$ ~/.pythonz/pythons/CPython-2.7.9/bin/python
Python 2.7.9 (default, Mar  6 2015, 18:39:28)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named zlib
>>>

But there are zlib installed:

$ pkg-config --list-all | grep -i zlib
zlib            zlib - zlib compression library
$ pkg-config --modversion zlib
1.2.5

Tar: write error

Latest pythonz version on Ubuntu 13.04.

After running:

curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash

Installation seems to be successful but I noticed this in the output:

tar: write error

Uninstall fails because of rmtree

Uninstalling fails with:

  File "/home/edliaw/.pythonz/pythons/CPython-2.7.5/lib/python2.7/shutil.py", line 254, in rmtree
    os.rmdir(path)
OSError: [Errno 39] Directory not empty: '/home/edliaw/.pythonz/pythons/CPython-2.7.5/lib/python2.7/lib-dynload'

lib-dynload is in fact empty when I check it, though. Perhaps a solution is to call shutil.rmtree (called in rm_r in util.py) with ignore_errors=True or to specify a function for onerror that only prints a warning message.

Proper project versioning

Hey guys, excellent work.
Is there any plans to version this project properly? maybe start creating tags?

Thanks!

Error message from .bashrc

Hi,

I get the following error message (I think from adding in .bashrc)
I followed this: http://stackoverflow.com/questions/12626370/virtualenv-shell-errors
but no result.
No effect setting $VIRTUALENVWRAPPER_HOOK_DIR as .virtualenvs in .bashrc. It is simply ignored.
Any idea?

stevedore.extension error calling 'user_scripts': [Errno 2] No such file or directory: '/home/toniher/$VIRTUALENVWRAPPER_HOOK_DIR/initialize'
stevedore.extension [Errno 2] No such file or directory: '/home/toniher/$VIRTUALENVWRAPPER_HOOK_DIR/initialize'
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/stevedore-0.8-py2.6.egg/stevedore/extension.py", line 126, in _invoke_one_plugin
response_callback(func(e, _args, *_kwds))
File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper-3.7-py2.6.egg/virtualenvwrapper/hook_loader.py", line 182, in invoke
ext.plugin(args)
File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper-3.7-py2.6.egg/virtualenvwrapper/user_scripts.py", line 143, in initialize
make_hook(get_path('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment)
File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper-3.7-py2.6.egg/virtualenvwrapper/user_scripts.py", line 124, in make_hook
f = open(filename, 'w')
IOError: [Errno 2] No such file or directory: '/home/toniher/$VIRTUALENVWRAPPER_HOOK_DIR/initialize'
stevedore.extension error calling 'project': [Errno 2] No such file or directory: '/home/toniher/$VIRTUALENVWRAPPER_HOOK_DIR/premkproject'
stevedore.extension [Errno 2] No such file or directory: '/home/toniher/$VIRTUALENVWRAPPER_HOOK_DIR/premkproject'
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/stevedore-0.8-py2.6.egg/stevedore/extension.py", line 126, in _invoke_one_plugin
response_callback(func(e, _args, *_kwds))
File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper-3.7-py2.6.egg/virtualenvwrapper/hook_loader.py", line 182, in invoke
ext.plugin(args)
File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper-3.7-py2.6.egg/virtualenvwrapper/project.py", line 36, in initialize
comment)
File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper-3.7-py2.6.egg/virtualenvwrapper/user_scripts.py", line 124, in make_hook
f = open(filename, 'w')
IOError: [Errno 2] No such file or directory: '/home/toniher/$VIRTUALENVWRAPPER_HOOK_DIR/premkproject'

Build stackless failed while using py3k to run pythonz

creating Modules/Setup
creating Modules/Setup.local
creating Makefile
make[1]: 进入目录“/home/tonyseek/.pythonz/build/Stackless-2.7.2”
./Parser/asdl_c.py -h ./Include ./Parser/Python.asdl
gcc -pthread -c -fno-strict-aliasing -DSTACKLESS_FRHACK=0 -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include -I./Stackless   -DPy_BUILD_CORE -o Parser/tokenizer_pgen.o Parser/tokenizer_pgen.c
gcc -pthread -c -fno-strict-aliasing -DSTACKLESS_FRHACK=0 -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include -I./Stackless   -DPy_BUILD_CORE -o Parser/printgrammar.o Parser/printgrammar.c
gcc -pthread -c -fno-strict-aliasing -DSTACKLESS_FRHACK=0 -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include -I./Stackless   -DPy_BUILD_CORE -o Parser/pgenmain.o Parser/pgenmain.c
  File "./Parser/asdl_c.py", line 1210
    print "Must specify exactly one output file"
                                               ^
SyntaxError: invalid syntax
make[1]: *** [Include/Python-ast.h] Error 1

CPython 2.4.x fails with syntax error

I am not able to install CPython 2.4 (I tried 2.4.1 and 2.4.6 with identical results) in Arch Linux. It seems it is using a wrong setup.py, because it contains a with block (which was introduced in 2.5).

  File "./setup.py", line 253
    with open(tmpfile) as fp:
            ^
SyntaxError: invalid syntax
make: *** [sharedmods] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.