2

One of the nice features of working in Eclipse with PyDev is that clicking F3 you can browse into almost anything. However, if the package you're using is contained in a Python egg, that doesn't work.

Is it possible to make it work?
If not, would it work to extract the egg's contents into site-packages and delete the egg? Wouldn't some metadata be lost?

Community
  • 1
  • 1
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
  • An egg is a zip file. Why not just open it? – S.Lott Aug 30 '11 at 09:49
  • @S.Lott - If you mean just to view it - I do, but it's less comfortable than `F3`ing. It becomes tedious if you have a lot of eggs to go through – Jonathan Livni Aug 30 '11 at 09:53
  • @S.Lott - If you mean that I can extract it into `site-packages` and then delete the egg and everything will work fine - that's what I'm asking about... – Jonathan Livni Aug 30 '11 at 09:53
  • Neither comment makes much sense to me. Please **update** your question to specify what you can't do. I'm unclear on what problem you actually have. Please **update** the question. Please avoid stringing a lot of comments into a question which you own and can change to make it clear and complete. – S.Lott Aug 30 '11 at 09:57

2 Answers2

4

Actually, what you're saying should work (i.e.: doing F3 on a reference to a file within a zip should open the file properly).

So, this was actually a rather critical bug when dealing with zip files in PyDev (which I've just fixed and is already available in the current nightly build -- it'll be released for PyDev 2.2.3).

For getting the nightly build see instructions at: http://pydev.org/download.html

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
3

You can unzip the egg's contents into site-packages and it will work.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
  • And delete the egg? So... the egg's "metadata" (specifically package dependencies) isn't important for the use of the package? – Jonathan Livni Aug 30 '11 at 10:12
  • @Jonathan: it's not important for the *use* of the package, true. This metadata is something setuptools knows about, not CPython's import machinery. OTOH if you want to install other packages that depend on this one, the metadata may be required. Either way you can setup the .pth files so that the unzipped egg is found before the real egg, and keep the real egg alive to allow setuptools to its dependency work – Eli Bendersky Aug 30 '11 at 10:16
  • 1
    last Q: if I do leave both of them - won't I encounter [this problem](http://stackoverflow.com/questions/7239518/module-pytz-was-already-imported)? – Jonathan Livni Aug 30 '11 at 10:40
  • @Jonathan: I think you can rig the .pth files appropriately to make it work. AFAIK setuptools only needs the egg to be in the location it expects, not necessarily discoverable with `import`. Test it with some simple example – Eli Bendersky Aug 30 '11 at 10:50