Can I locate the source tree from from within the interpreter?

Thomas Heller theller at python.net
Thu Feb 13 14:23:35 EST 2003


Skip Montanaro <skip at pobox.com> writes:

> Is there a way to locate the source tree used to build an installed Python
> interpreter?  This doesn't need to be platform-independent (Unix-ish
> platform is sufficient).  I've poked around sys and the output of
> distutils.sysconfig.get_config_vars().  Neither seems to harbor the build
> tree as an absolute path.  (There is a "srcdir" entry in the
> get_config_vars() output, but it's a relative path.)  I even tried opening
> sys.executable and performing the moral equivalent of the strings(1)
> command, but no dice (this is on MacOSX - I'm sure MMWV on other platforms).

Don't know if this helps you, but I've changed the distutils
msvccompiler (for windows) some tim eago so that for debug builds
absolute pathnames are passed to the compiler.  So when a breakpoint
in encountered in Python, or in an extension, the MSVC debugger does
not need to bother the user looking for the source file.

I don't know where the source filenames are stored, probably in the
debug info somewhere, but I would guess it is possible to find them.
Maybe the same is possible on *nix?

Thomas




More information about the Python-list mailing list