FreeBSD ports and Python versions
July 2010
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
About
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments

collective.solr 1.0rc1 (Release candidate)
2010-07-30 plone.org releases

Products.cron4plone 1.1.5rc1 (Release candidate)
2010-07-30 plone.org releases

vs.dashboardmanager 0.2.6.1
2010-07-30 plone.org releases

Heads up! OpenBSD now supports multi-byte characters!
2010-07-30 OpenBSD Journal (undeadly.org)

Setting the Focus Distance on the Epson V700 Scanner
2010-07-29 betabug

Gnome Census Released (and Red Hat 16% vs Canonical 1% Flame)
2010-07-29 Ramble on

Cómo conectarse a bases de datos SQLite desde NetBeans
2010-07-29 vaites (dmnet)

Diferencias cambiando de Perl a Python
2010-07-28 blackshell

Monos y cacahuetes
2010-07-28 userlinux.net

No Gazoline
2010-07-28 betabug

[c2k10] (Part 5)
2010-07-28 OpenBSD Journal (undeadly.org)

Cómo evitar fbc_channel=1 con Facebook Fan/Like Box
2010-07-28 vaites (dmnet)

Copyright Nonsense
2010-07-28 Ramble on

New Plone Usergroup in Charlottesville, VA kicks off July 29th
2010-07-28 plone.org news

Redimensionar la ventana de Firefox sin extensiones
2010-07-27 vaites (dmnet)

ἀφορισμός XII: Silencio
2010-07-27 emereci

New committer: Baptiste Daroussin (ports)
2010-07-27 FreeBSD latest news

[c2k10] The Hackathon BBQ (Part 4) - June 25 - July 3, 2010, Edmonton, Alberta, Canada
2010-07-26 OpenBSD Journal (undeadly.org)

Setting up Bacula
2010-07-26 Evilcoder

Plone 4 upgrade coming to plone.org
2010-07-25 plone.org news

So I bought a Scanner
2010-07-24 betabug

FreeBSD 8.1 RELEASED
2010-07-24 Evilcoder

FreeBSD 8.1-RELEASE Available
2010-07-23 FreeBSD latest news

Announcing Tornado 1.0
2010-07-23 Ramble on

Sauna Sprint just around the corner
2010-07-22 plone.org news

April-June, 2010 Status Report
2010-07-22 FreeBSD latest news

O culeiro
2010-07-21 emereci

Limitando usuarios ssh en Mercurial
2010-07-21 userlinux.net

The Wire
2010-07-20 emereci

Comienza la mudanza, nos vamos a Reading
2010-07-18 blackshell

Recent Trackbacks
Categories
OpenBSD (8 items)
BSD (0 items)
FreeBSD (12 items)
Linux (2 items)
Security (3 items)
Python (18 items)
Zope (13 items)
Daily (120 items)
e-shell (8 items)
Hacks (7 items)
PostgreSQL (3 items)
OSX (7 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (0 items)
Django (23 items)
Music (9 items)
Plone (7 items)
Varnish (0 items)
Lugo (1 items)
Sendmail (-1 items)
europython (7 items)
Archives

Syndicate this site (XML)

RSS/RDF 0.91

24 enero
2008

FreeBSD ports and Python versions

or how the env magic saved me again...

If you have some experience with FreeBSD ports, and more precisely with Python related ones (for example, extra modules like imaging or psycopg), you should already noticed that it is common to have two different python versions installed in the same system.

For example, in one of my FreeBSD servers, I've both Python 2.4 and 2.5 installed, because 2.5 is the current stable version, but I need 2.4 for certain things, like Zope.

And what happens when you need an additional module for a given version of Python ?

While working in that server today, trying to set up a Plone site. I noticed that I needed the python imaging module. I checked with pkg_info (because I thought it was already installed) and I found that there is already a version installed of such module:

[prunus] /var/log> pkg_info | grep imaging
py25-imaging-1.1.6_2 The Python Imaging Library
[prunus] /var/log>

The module was installed for Python 2.5. The problem was that Plone runs on top of Zope, which needs Python 2.4, and as I do not have the module for that version of Python installed, Plone didn't find it.

No problem, I just went to /usr/ports/graphics/py-imaging and perform another make install.

As you could imagine, it tried to re-install the py25-imaging package and, obviously, it crashes:

===>  Checking if graphics/py-imaging already installed
===>   py25-imaging-1.1.6_2 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of graphics/py-imaging
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Ugly.

After reading carefully the error message, I opened the Makefile inside the port directory, just searching for some knobs or options to set the default Python version... but no luck. What now?

Well, after some googling I found something interesting in the porters handbook:

"The Ports Collection supports parallel installation of multiple Python versions. Ports should make sure to use a correct python interpreter, according to the user-settable PYTHON_VERSION variable."

AHA! it was PYTHON_VERSION... So the only thing I need is to set up such variable in the user environment to get the correct version of the module installed:

prunus# setenv PYTHON_VERSION python2.4
prunus# make clean install
===>  Cleaning for py24-imaging-1.1.6_2
===>  Found saved configuration for py25-imaging-1.1.6_2
===>  Extracting for py24-imaging-1.1.6_2
=> MD5 Checksum OK for python/Imaging-1.1.6.tar.gz.
=> SHA256 Checksum OK for python/Imaging-1.1.6.tar.gz.
===>  Patching for py24-imaging-1.1.6_2
===>  Applying FreeBSD patches for py24-imaging-1.1.6_2

[ ... ]

===>   Registering installation for py24-imaging-1.1.6_2
prunus#

NOTE: probably you already noticed it, this time, I wasn't using sudo, because if I've had added the PYTHON_VERSION variable to my user env and then used sudo, the process executed through sudo couldn't be able to access that environment variable.

UPDATE: As betabug said in the comments, you can pass environment variables to sudo, for example, to install elementtree for both python 2.5 and 2.4:

[prunus] /usr/ports/devel/py-elementtree> sudo make install
=> elementtree-1.2.6-20050316.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://effbot.org/downloads/.

[ ... ]

===>   Registering installation for py25-elementtree-1.2.6
[prunus] /usr/ports/devel/py-elementtree> sudo make clean
===>  Cleaning for py25-elementtree-1.2.6
[prunus] /usr/ports/devel/py-elementtree> sudo env PYTHON_VERSION=python2.4 make install
===>  Extracting for py24-elementtree-1.2.6
=> MD5 Checksum OK for elementtree-1.2.6-20050316.tar.gz.

[ ... ]

===>   Registering installation for py24-elementtree-1.2.6
[prunus] /usr/ports/devel/py-elementtree>

Posted by wu at 15:15 | Comments (0) | Trackbacks (0)
<< Django People | Main | OSx dns cache >>
Comments
Re: FreeBSD ports and Python versions

sudo env PYTHON_VERSION=python2.4 make clean install

Posted by: betabug at enero 25,2008 09:14
Re: FreeBSD ports and Python versions

Yes, due to the new sudo behaviour, environment variables must be set when calling sudo...

thnx betabug!

Posted by: Wu at enero 25,2008 10:14
Re: FreeBSD ports and Python versions

I just upgraded to Python 2.6 and was facing a similar problem. However, I wanted to make the setting more permanent, so I added "PYTHON_VERSION=python2.6" to /etc/make.conf.

Worked like charm. Thanks for the tips.

Posted by: Viktor Petersson at noviembre 13,2008 20:29
Re: FreeBSD ports and Python versions

Hi Viktor.

Yes, that's the way to make the PYTHON_VERSION env var available without having to set it up every time. The thing about that is that the default "stable" version is already the default one with the ports (that is, currently, 2.5).

What about 2.6? too much changes? (I didn't notice it is even in the ports tree :( )

Posted by: Wu at noviembre 15,2008 18:50
Trackbacks
Please send trackback to:http://blog.e-shell.org/35/tbping
There are no trackbacks.
Post a comment