Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the source code for a Python egg?

I'm attempting to add a video extension to the Python Markdown-2.0.3-py2.7.egg

Things aren't working, so I want to use pdb debugger to see what's going on.

I can't seem to find the source code to insert pdb.

The egg is located here:

/usr/local/lib/python2.7/site-packages/Markdown-2.0.3-py2.7.egg

Using iPython, I can view the Python source code of the Markdown module and it's path:

/usr/local/lib/python2.7/site-packages/Markdown-2.0.3-py2.7.egg/markdown/__init__.py

But I can't navigate to that file, nor can open it in a Text Editor.

I'm guessing the source code I'm viewing may be generated from the compiled egg. However, it seems there must be some way of accessing the code.

like image 932
BryanWheelock Avatar asked Dec 08 '22 01:12

BryanWheelock


2 Answers

An .egg file is a simple ZIP archive, you can extract the files using any ZIP-enabled application if you want. That being said, you can install an .egg into a folder for development by passing the develop option to setup.py. This will make setuptools use the sources in the specified folder and just link to them by a file in your package path.

like image 109
Jim Brissom Avatar answered Dec 09 '22 16:12

Jim Brissom


A .egg file is a zipfile -- so, typing at a command prompt or shell prompt unzip -l /usr/local/lib/python2.7/site-packages/Markdown-2.0.3-py2.7.egg should tell you about its contents, for example (if you have unzip on your shell or command's $PATH, of course).

like image 21
Alex Martelli Avatar answered Dec 09 '22 16:12

Alex Martelli