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!

mercoledì 14 novembre 2012

python 3.3 and virtualenv


As in pep-0405 Python 3 new virtualenv specs are now implemented in Python 3.3.

Install python3.3 and venv it 


Python 3.3 has those bleeding edge venvs, lets try them and bleed!

# please add the source if needed
# it could need a package from experimental

set -e # exit in case of errors 

if grep -vqs "experimental main" ; then
    echo "deb experimental main" | \
    sudo tee -a /etc/apt/sources.list > /dev/null

sudo apt-get install python3.3
pyvenv-3.3 .pyvenv-3.3
. .pyvenv-3.3/bin/activate 

Install pyglet 

# pip install pyglet # if lucky and in the future
# maybe check for something >= 1.2 on
cd pyglet-1.2alpha11
python install

  Install pip

curl -O
I dreamed now for

easy_install pip
but I had to do that uglyness below, I'm missing a prefix probably (I hope!)

mv .pyvenv-3.3/local/lib/python3.3/dist-packages/ .pyvenv-3.3/lib/
easy_install-3.3 pip

Is there something wrong here?