FreeBSD ports and Python versions
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.
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
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?
"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.
[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>