Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15814

Re: How to insert my own module in front of site eggs?

From Marc Christiansen <usenet@solar-empire.de>
Newsgroups comp.lang.python
Subject Re: How to insert my own module in front of site eggs?
Date 2011-11-17 10:48 +0100
Message-ID <1s1fp8-6la.ln1@pluto.solar-empire.de> (permalink)
References <roy-EB07D8.20574216112011@news.panix.com>

Show all headers | View raw


Roy Smith <roy@panix.com> wrote:
> I'm trying to use a custom version of mongoengine.  I cloned the git 
> repo and put the directory on my PYTHONPATH, but python is still 
> importing the system's installed version.  Looking at sys.path, it's 
> obvious why:
> 
> $ echo $PYTHONPATH 
> /home/roy/songza:/home/roy/lib/mongoengine
> 
>>>> pprint.pprint(sys.path)
> ['',
> '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg',
> '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg',
> 
> '/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg
> g',
> '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg',
> '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg',
> '/home/roy/songza',
> '/home/roy/lib/mongoengine',
[...]

> The system eggs come before my path.  I found 
> http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in 
> the archives; it explains that eggs come before PYTHONPATH, but doesn't 
> explain how to get around this problem.  I emphatically agree with 
> Michael Bayer who said:
> 
>> I cant think of a  possible scenario where a path would explicitly
>> exist in PYTHONPATH,  non-egg or egg, where the user would still like the
>> system-wide installation to take precedence
> 
> So, is there any way to get my local copy of mongoengine loaded instead 
> of the system egg?  I could probably import sys, and do an egg-ectomy on 
> sys.path before importing mongoengine, but that's too gross to 
> contemplate.

The only way I found is to edit the easy_install.pth file and comment
the two lines starting with "import sys". You'll have to do that every
time you install/upgrade an egg via easy_install (and maybe setuptools).
In your case the right file should be
/usr/local/lib/python2.6/dist-packages/easy_install.pth

BTW: You could try pip (http://www.pip-installer.org/) instead of
easy_install, it doesn't mess with sys.path.

Ciao
Marc

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to insert my own module in front of site eggs? Roy Smith <roy@panix.com> - 2011-11-16 20:57 -0500
  Re: How to insert my own module in front of site eggs? Marc Christiansen <usenet@solar-empire.de> - 2011-11-17 10:48 +0100
    Re: How to insert my own module in front of site eggs? Roy Smith <roy@panix.com> - 2011-11-17 09:09 -0500
      Re: How to insert my own module in front of site eggs? Duncan Booth <duncan.booth@invalid.invalid> - 2011-11-17 15:04 +0000
        Re: How to insert my own module in front of site eggs? Roy Smith <roy@panix.com> - 2011-11-17 20:38 -0500
      Re: How to insert my own module in front of site eggs? Paul Rudin <paul.nospam@rudin.co.uk> - 2011-11-17 17:05 +0000
        Re: How to insert my own module in front of site eggs? Roy Smith <roy@panix.com> - 2011-11-17 20:36 -0500
          Re: How to insert my own module in front of site eggs? alex23 <wuwei23@gmail.com> - 2011-11-17 18:58 -0800
            Re: How to insert my own module in front of site eggs? Hans Mulder <hansmu@xs4all.nl> - 2011-11-18 11:52 +0100
          Re: How to insert my own module in front of site eggs? Paul Rudin <paul.nospam@rudin.co.uk> - 2011-11-18 05:54 +0000
          Re: How to insert my own module in front of site eggs? "spartan.the" <spartan.the@gmail.com> - 2011-11-20 12:44 -0800

csiph-web