How to get directory of Python C library

arve.knudsen at gmail.com arve.knudsen at gmail.com
Sun Nov 15 23:50:54 CET 2009


On 15 Nov, 22:11, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> arve.knud... at gmail.com schrieb:
>
>
>
>
>
> > On 15 Nov, 21:24, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> >> arve.knud... at gmail.com schrieb:
>
> >>> On 15 Nov, 20:05, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> >>>> arve.knud... at gmail.com schrieb:
> >>>>> Hi
> >>>>> I need to link against Python, is there a way to get the path to the
> >>>>> directory containing Python's C library (e.g., <exec-prefix>/libs on
> >>>>> Windows)?
> >>>> Most probably from the registry somehow. In general, try & locate a
> >>>> python-executable, and make it execute
> >>>>   python -c "import sys; print sys.prefix"
> >>>> Capture that, and you're done. Depending on the OS, the libs then are
> >>>> placed in e.g. <prefix>/lib.
> >>> That doesn't solve anything, the hard part is figuring out the part
> >>> after <prefix> ..
> >> AFAIK is that only varying based on the OS. Under unix, it's
>
> >>   <prefix>/lib/python<version>/
>
> >> You can get the platform via sys.platform.
>
> > Well, my point is that I should like a way to query for this
> > directory, just as I can query distutils.sysconfig for the include
> > directory and Python library (i.e., the standard Python library)
> > directory. It's not trivial to figure out Python's installation scheme
> > so long as it's not written in stone ..
>
> Well, than how about you word your question like that? But there is no
> simple function to call. So the answer to the question you asked is: no.
>
> I showed you a way that works for current python, and consists of
> stitching together a number of informations.
>
> Diez

My original question was pretty clear I think. And I don't have the
required information to deduce what the library path may look like on
any given platform, there really should be a standard function for
this.

Arve



More information about the Python-list mailing list