Installing textproc/py-libxml2 port for python 2.5 while keeping 2.4?

cpghost cpghost at cordula.ws
Thu Oct 11 19:20:11 PDT 2007


On Thu, 11 Oct 2007 17:55:00 -0400
Naoyuki Tai <ntai at smartfruit.com> wrote:

> Hello,
> 
> When I install textproc/py-libxml2 from the port tree, it installs 
> py24-libxml2.
> I want to install py25-libxml2 while keeping py24-libxml2.
> 
> lib/%%PYTHON_VERSION%%/site-packages/drv_libxml2.py
> lib/%%PYTHON_VERSION%%/site-packages/drv_libxml2.pyc
> lib/%%PYTHON_VERSION%%/site-packages/drv_libxml2.pyo
> lib/%%PYTHON_VERSION%%/site-packages/libxml2.py
> lib/%%PYTHON_VERSION%%/site-packages/libxml2.pyc
> lib/%%PYTHON_VERSION%%/site-packages/libxml2.pyo
> lib/%%PYTHON_VERSION%%/site-packages/libxml2mod.a
> lib/%%PYTHON_VERSION%%/site-packages/libxml2mod.la
> lib/%%PYTHON_VERSION%%/site-packages/libxml2mod.so
> 
> These files are per python version while docs are not.
> 
> Is there anyway to do this?
> Should I just do force install?
> Any other better way?
> Is it possible for one port to be installed to multiple versions of
> python?

I've had exactly the same problem trying to install www/py-turbogears
in a python2.5 world (it needs python2.4, and a lot of ports that
must of course be installed in the python2.4 instance as well) :-(

This is what I've discovered while doing so:

1.) If you want to install a py24-* in addition to py25-* of the
same port, you'll often need to switch between two versions of
easy_install:

So before you want to install a py24-* package, do something
like this:

# cd /usr/local/bin
# mv easy_install easy_install.orig
# cp easy_install-2.4 easy_install
<now force install the py24-* package>
# mv easy_install.org easy_install

You need this, because you'll get some errors about .pth files
not being supported etc...

2.) When compiling the py24-* version of an existing port,
you'll often need to define PYTHON_DEFAULT_VERSION to be
python2.4 in /etc/make.conf. For example:

.if ${.CURDIR:M*/devel/py-setuptools}
PYTHON_DEFAULT_VERSION=python2.4
.endif

Then go into the ports directory, recompile with 'make', and
then force install by defining FORCE_PKG_REGISTER. Then you
my comment out those lines in /etc/make.conf again.

3.) It is safe to have py24-* and py25-* of the same port
simultaneously on your system, as long as they only install
files in the respective python trees, a.k.a.:
  /usr/local/lib/python2.4/site-packages/
  /usr/local/lib/python2.5/site-packages/

But not all py- ports are so well behaved! Some ports also
install stuff in /usr/local/bin (e.g.  devel/py-twistedCore,
which adds stuff like /usr/local/bin/twistd. This 'twistd'
is tied to the python version you've last used to install
the port (look at its first line).

So what I'm doing is:
a.) first install all py24-* packages with easy_install set to
    easy_install-2.4, and PYTHON_DEFAULT_VERSION set to python2.4
    in /etc/make.conf
b.) reinstall all those py24-* packages as py25-* (of course
    with easy_install set to easy_install-2.5), with
    PYTHON_DEFAULT_VERSION set to python2.5 in /etc/make.conf
    and using FORCE_PKG_REGISTER, and overwriting stuff that's
    outside site-packages/...

It's not ideal (we really need a better way to simultaneously
install the same ports for different versions of python!), but
it's good enough for me: once the packages are installed, the
python installations are nicely self-contained and working
(except for the common binaries in /usr/local/bin etc..., which
would need a -2.4 or -2.5 suffix IMHO). Updating all those
py24-* packages is not as nice though..., cause you'll have to
redo it manually (at least for the py24-*... the py25-* will update
themselves automatically).

> Naoyuki "Tai" Tai, ntai a t smartfruit d o t com

Regards,
-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/


More information about the freebsd-questions mailing list