[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

PYTHONPATH and eggs

geoffbache

3/3/2010 10:14:00 AM

Hi all,

I have a very simple problem that seems to have no simple solution.

I have a module which is installed centrally and lives in a Python
egg. I have experimented with some minor changes to it and would like
to set my PYTHONPATH to pick up my local copy of it, but don't want to
have to figure out how to build my own version of the "egg" if
possible.

Unfortunately, the location from PYTHONPATH ends up after the eggs in
sys.path so I can't persuade Python to import my version. The only way
I've found to fix it is to copy the main script and manually hack
sys.path at the start of it which isn't really very nice. I wonder if
there is any better way as I can't be the first person to want to do
this, surely?

I've seen this issue has been discussed elsewhere and flagged as a
problem (e.g.
http://mail.python.org/pipermail/distutils-sig/2009-January/0...)

but I've been unable to find any suggestions for workarounds or
indications whether this will be/has been fixed.

Regards,
Geoff Bache
3 Answers

Jonathan Gardner

3/4/2010 12:10:00 AM

0

On Wed, Mar 3, 2010 at 2:14 AM, geoffbache <geoff.bache@jeppesen.com> wrote:
>
> I have a very simple problem that seems to have no simple solution.
>
> I have a module which is installed centrally and lives in a Python
> egg. I have experimented with some minor changes to it and would like
> to set my PYTHONPATH to pick up my local copy of it, but don't want to
> have to figure out how to build my own version of the "egg" if
> possible.
>
> Unfortunately, the location from PYTHONPATH ends up after the eggs in
> sys.path so I can't persuade Python to import my version. The only way
> I've found to fix it is to copy the main script and manually hack
> sys.path at the start of it which isn't really very nice. I wonder if
> there is any better way as I can't be the first person to want to do
> this, surely?
>
> I've seen this issue has been discussed elsewhere and flagged as a
> problem (e.g.
> http://mail.python.org/pipermail/distutils-sig/2009-January/0...)
>
> but I've been unable to find any suggestions for workarounds or
> indications whether this will be/has been fixed.
>

Sounds like you might need to use virtualenv to setup python
environments that you can control.

--
Jonathan Gardner
jgardner@jonathangardner.net

David Cournapeau

3/4/2010 2:24:00 AM

0

On Wed, Mar 3, 2010 at 7:14 PM, geoffbache <geoff.bache@jeppesen.com> wrote:

> Unfortunately, the location from PYTHONPATH ends up after the eggs in
> sys.path so I can't persuade Python to import my version. The only way
> I've found to fix it is to copy the main script and manually hack
> sys.path at the start of it which isn't really very nice. I wonder if
> there is any better way as I can't be the first person to want to do
> this, surely?

One way is to never install things as eggs: I have a script
hard_install which forces things to always install with
--single-externally-managed blablabla. This has worked very well for
me, but may not always be applicable (in particular if you are on a
platform where building things from sources is difficult).

cheers,

David

geoffbache

3/4/2010 8:21:00 AM

0


On Mar 4, 3:24 am, David Cournapeau <courn...@gmail.com> wrote:
> On Wed, Mar 3, 2010 at 7:14 PM, geoffbache <geoff.ba...@jeppesen.com> wrote:
> > Unfortunately, the location from PYTHONPATH ends up after the eggs in
> > sys.path so I can't persuade Python to import my version. The only way
> > I've found to fix it is to copy the main script and manually hack
> > sys.path at the start of it which isn't really very nice. I wonder if
> > there is any better way as I can't be the first person to want to do
> > this, surely?
>
> One way is to never install things as eggs: I have a script
> hard_install which forces things to always install with
> --single-externally-managed blablabla. This has worked very well for
> me, but may not always be applicable (in particular if you are on a
> platform where building things from sources is difficult).

Thanks for the tips. Is your script generic at all? I wonder if you'd
be prepared to share it?

Figuring out virtualenv would also be an option, as would figuring out
how to build my own egg, but both these solutions feel like overkill
to me just to enable a small bit of tweaking.

/Geoff