Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get directory of Python C library

1 view
Skip to first unread message

arve.k...@gmail.com

unread,
Nov 15, 2009, 12:56:56 PM11/15/09
to
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)?

Thanks,
Arve

Diez B. Roggisch

unread,
Nov 15, 2009, 2:05:48 PM11/15/09
to
arve.k...@gmail.com schrieb:

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.

Diez

arve.k...@gmail.com

unread,
Nov 15, 2009, 3:14:59 PM11/15/09
to
On 15 Nov, 20:05, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
> arve.knud...@gmail.com schrieb:

That doesn't solve anything, the hard part is figuring out the part
after <prefix> ..

Arve

Diez B. Roggisch

unread,
Nov 15, 2009, 3:24:01 PM11/15/09
to
arve.k...@gmail.com schrieb:

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.


Diez

arve.k...@gmail.com

unread,
Nov 15, 2009, 4:08:22 PM11/15/09
to

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 ..

Arve

Diez B. Roggisch

unread,
Nov 15, 2009, 4:11:38 PM11/15/09
to
arve.k...@gmail.com schrieb:


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

arve.k...@gmail.com

unread,
Nov 15, 2009, 5:50:54 PM11/15/09
to

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

Diez B. Roggisch

unread,
Nov 15, 2009, 5:59:04 PM11/15/09
to
arve.k...@gmail.com schrieb:

I at least misunderstood it - which might be my fault. However, as there
is no such function. I suggest you discuss this on the devel-list -
however, anything before python2.7 is unlikely to grow such a function,
so you are stuck with the ways I described.

Diez

arve.k...@gmail.com

unread,
Nov 15, 2009, 6:23:10 PM11/15/09
to

OK, thanks. Perhaps I'll try distutils-sig, given that it looks
natural to extend distutils.sysconfig.

Arve

0 new messages