Multiple versions of Python packages (2.7 vs 3.4)

Shane Ambler FreeBSD at ShaneWare.Biz
Thu Mar 17 00:14:09 UTC 2016


On 16/03/2016 23:39, Miroslav Lachman wrote:
> I checked that most files are installed in versioned subdirectory, for
> example python2.7/site-packages, some tools have versioned binaries like
> /usr/local/bin/pip-2.7 but they have also symlink /usr/local/bin/pip.
> Are there any way to create / install those packages without creating
> this symlink?
> If I didn't miss something the symlinks are the only common files for
> both versions so it will be overwritten by the later installation or
> upgrade. Or not?

This is an automated step to allow the python ports to be installed for
more than one python version at the same time. The scripts in
/usr/local/bin being one of the places that a conflict can happen. Docs
and licenses are other paths that can conflict, these other dir names
are altered to match the python version. eg share/licenses/py-pip will
get changed to share/licenses/py27-pip

In the Makefile of the port USE_PYTHON=concurrent enables this feature,
if a port conflicts with multiple python versions then concurrent needs
to be added (or sometimes other adjustments). If you remove concurrent
then the symlinks in bin won't be made.

I don't think there is a way to control this with environment variables
so you would have to alter the ports Makefile and build yourself if you
want it to work differently.

The reason for the symlink is to allow the expected pip script to exist
in bin while preventing multiple python versions conflicting, the pkg
installed for the default version of python will own the bin/pip which
will symlink to it's install of bin/pip-${PYTHON_VER} - pkgs installed
for other versions of python will only install bin/pip-${PYTHON_VER}

So if python 2.7 is the default version, py27-pip will install bin/pip
and bin/pip-2.7 while py34-pip will only install bin/pip-3.4
If you run pip you will get the default py27 version but if you want to
run it for py34 then you need to specifically run pip-3.4

You can alter the default python version by adding to /etc/make.conf

DEFAULT_VERSIONS= python=2.7 python2=2.7 python3=3.4

And if your wondering how to build multiple versions -

cd /usr/ports/devel/py-pip
make PYTHON_VERSION=3.4 install clean

-- 
FreeBSD - the place to B...Software Developing

Shane Ambler



More information about the freebsd-ports mailing list