distutils ignores leading / of prefix in some circumstances

Bug #920446 reported by Tim Bond
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fluidity
Fix Released
Medium
Tim Greaves

Bug Description

During the Fluidity install process, distutils appears to be behaving inconsistently in terms of how it treats the leading / in a prefix. This is specifically with regard to the python installer, called in the 'install' rule of the root Fluidity Makefile.

An example of where it fails to work is seen from the buildbot output at:

 http://buildbot-ocean.ese.ic.ac.uk:8080/builders/cx1-compile-111-binmod/builds/288/steps/shell/logs/stdio

where the command is:

 cd python ; python setup.py install --root="" --prefix="/home/fluidity/current" $FLUIDITY_PYTHON_INSTALL_ARGS

but the install proceeds as:

 creating home
 creating home/fluidity
 creating home/fluidity/current
 creating home/fluidity/current/lib
 creating home/fluidity/current/lib/python2.6
 creating home/fluidity/current/lib/python2.6/site-packages
 copying build/lib/fluidity_tools.py -> home/fluidity/current/lib/python2.6/site-packages
 copying build/lib/vtktools.py -> home/fluidity/current/lib/python2.6/site-packages
 .....

If a double leading slash is provided to the prefix (ie, //home/fluidity/current) the behaviour is as desired; otherwise, the install proceeds into python/home/fluidity/current/ which is not as intended.

At present, no idea why this is happening.

Jon Hill (jon-hill)
Changed in fluidity:
status: New → Triaged
Changed in fluidity:
importance: Undecided → Medium
assignee: nobody → Tim Greaves (tim-greaves)
status: Triaged → In Progress
milestone: none → 4.1.4
Revision history for this message
Tim Greaves (tim-greaves) wrote :

Status update on this:

I've tried changing this to use setuptools rather than distutils, and get exactly the same problem. I'm unsure whether this is an inherited bug by setuptools from distutils, or whether it indicates a higher-level problem; I suspect the latter as setuptools says:

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    data/tmb1/install/lib/python2.6/site-packages/

Investigation ongoing.

Changed in fluidity:
milestone: 4.1.4 → 4.1.5
Revision history for this message
Patrick Farrell (pefarrell) wrote :

Err ...

shouldn't --root="/", not --root=""? If I do this manually, then it works as expected.

Revision history for this message
Tim Greaves (tim-greaves) wrote :

The back-end to this is:

Makefile.in: cd python ; python setup.py install --root="${DESTDIR}" --prefix="$(prefix)" $$FLUIDITY_PYTHON_INSTALL_ARGS

Possibly we need to only supply the --root if DESTDIR is set; something like:

cd python ; [ -n ${DESTDIR} ] python setup.py install --root="${DESTDIR}" --prefix="$(prefix)" $$FLUIDITY_PYTHON_INSTALL_ARGS || python setup.py install --prefix="$(prefix)" $$FLUIDITY_PYTHON_INSTALL_ARGS

Does that look right? My test-fu is not feeling particularly confident that that's the best way to do it.

Revision history for this message
Patrick Farrell (pefarrell) wrote :

You could do something simpler like

--root=$(shell echo ${DESTDIR} | sed 's@^$@/@') ?

Does that work?

Revision history for this message
Lawrence Mitchell (wence) wrote :

AKA:

--root="${DESTDIR:-/}"

Revision history for this message
Lawrence Mitchell (wence) wrote :

sorry, that's wrong, we're in Make-land, not shell-land.

Revision history for this message
Tim Greaves (tim-greaves) wrote :

With minor tweaking of the sed, that works a treat. Thanks Patrick, and thanks also to Florian and Stephan for input into escaping.

I'll push that directly as a one-line build-system fix to trunk.

Changed in fluidity:
status: In Progress → Fix Committed
Revision history for this message
Tim Greaves (tim-greaves) wrote :

And confirmed resolved the previously breaking case on buildbot:

cd python ; python setup.py install --root=/ --prefix="/home/fluidity/current" $FLUIDITY_PYTHON_INSTALL_ARGS
....
running install_lib
copying build/lib/fluidity_tools.py -> /home/fluidity/current/lib/python2.6/site-packages
copying build/lib/vtktools.py -> /home/fluidity/current/lib/python2.6/site-packages
copying build/lib/fluidity/parse_functional.py -> /home/fluidity/current/lib/python2.6/site-packages/fluidity
copying build/lib/fluidity/lagrangian_biology.py -> /home/fluidity/current/lib/python2.6/site-packages/fluidity
copying build/lib/fluidity/spheretools.py -> /home/fluidity/current/lib/python2.6/site-packages/fluidity

Changed in fluidity:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.