How to get directory of Python C library

A

arve.knudsen

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
 
D

Diez B. Roggisch

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.

Diez
 
A

arve.knudsen

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

Arve
 
D

Diez B. Roggisch

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.


Diez
 
A

arve.knudsen

(e-mail address removed) 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.

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
 
D

Diez B. Roggisch

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
 
A

arve.knudsen

(e-mail address removed) 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

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
 
D

Diez B. Roggisch

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.

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
 
A

arve.knudsen

(e-mail address removed) 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

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

Arve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top