giovedì 15 novembre 2012

Python 3.3 and pyvenv, a (hackish) solution

EDIT: it seems to be a bug in debian experimental, if you install python3.3 from the upstream tarball, you will not find this issue, the resolution of this bug is tracked in both Debian BTS and python BTS .

EDIT2: I could confirm that in debian unstable as of July 2013 is fixed. In this case you will be done with:

$ pyvenv-3.3 ~/.pyvenv-3.3
$ . ~/.pyvenv-3.3/bin/activate
(.pyvenv-3.3)$ curl -O
(.pyvenv-3.3)$ python
(.pyvenv-3.3)$ easy_install pip

In the previous blog post I got stuck in properly creating a virtualenv in python 3.3, now I came with this hacky script, which naively wraps pyvenv-3.3 and create a couple of missing links which makes everything works fine. In fact I saw that virtualenvs created with virtualenv .27 tools makes links from directories in <virtualenv>/local/{bin,lib,include} to <virtualenv>, those links are missing in venv created by pyvenv-3.3.

So here it is the hackish wrapper script:


PROGRAM="$(basename $0)"

if [ -z "${VENV_PATH}" ]; then
    echo "Usage:" 1>&2
    echo "${PROGRAM} VENV_PATH" 1>&2
    exit 1

shift 1

echo pyvenv-3.3 "${VENV_PATH}" "${@}"
pyvenv-3.3 "${VENV_PATH}" "${@}"

mkdir -p "${VENV_PATH}/local"

for dir in lib bin include ; do
    ln -vs ../${dir} "${VENV_PATH}/local/${dir}"

Save this script somewhere in your PATH (e.g. /usr/local/bin/mk_pyvenv or maybe ~/bin/mk_pyvenv) and then issue:

$ mk_pyvenv ~/.pyvenv-3.3
$ . ~/.pyvenv-3.3/bin/activate
(.pyvenv-3.3)$ curl -O
(.pyvenv-3.3)$ python
(.pyvenv-3.3)$ easy_install pip

And now you finally have a working virtualenv with python-3.3 VENV!

Nessun commento:

Posta un commento