setup.py should rewrite bin script when installed to a non-standard location so it can be run without specifying PYTHONPATH

Bug #250826 reported by Christopher Armstrong
4
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Medium
Unassigned

Bug Description

When running the 'setup.py install --prefix ~/opt/whatever', the resulting installed bzr script is unusable because the bzrlib will be installed to a location that isn't importable from a standard environment.

The bzr script should be modified at install-time to include some code which makes the associated bzrlib importable.

In addition to making the initial use easier, it allows people to deal with multiple installs of different versions of bzr much more easily.

The code could be something like:

import sys;
sys.path.insert(0, "/path/to/nonstandard/location/etc/site-packages")

Revision history for this message
Daniel Silverstone (dsilvers) wrote :

Attached is a not particularly pretty possible solution to the problem. There is no NEWS entry or what-have-you but it should work.

James Westby (james-w)
Changed in bzr:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
John A Meinel (jameinel) wrote :

Why not just use "bzrlibroot = None" and then a simple

if line == 'bzrlibroot = None\n':

to replace it int the output script.

I also think this will set 'bzrlibroot' no matter where it is installed (system wide or elsewhere). Which seems a bit over-the-top. Especially for people using packaged versions.

Revision history for this message
Daniel Silverstone (dsilvers) wrote :

Yes, the = None makes sense.

Hence the deliberate 'not in sys.path' which should mean that it won't add the lib root to the path if it's already there. Therefore being somewhat nicer for packaged versions, no?

I should note that this is the first time I've ever done anything in distutils so there's bound to be something better. I just knocked this up to see if it were possible in a sane amount of code.

Revision history for this message
Dan Watkins (oddbloke) wrote :

I'd prefer something akin to the attached. Putting magic values within our code which are then replaced during install seems wrong.

Of course, we may not want to do this during post-install, this is just something I knocked together.

Revision history for this message
Wouter van Heyst (larstiq) wrote :

It is not that different from the rewriting of the hashbang line that distutils does, imo. Perhaps distutils even has more formal support for something like this?

Revision history for this message
Robert Collins (lifeless) wrote :

I'd personally rather folk just run bzr from source for this sort of use case; however the works been done and it should get a review.

Jelmer Vernooij (jelmer)
tags: added: setup.py
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
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.