PYTHONPATH and eggs

G

geoffbache

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/010755.html)

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

Regards,
Geoff Bache
 
J

Jonathan Gardner

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/010755.html)

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.
 
D

David Cournapeau

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
 
G

geoffbache

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top