Is it possible to find python34.lib from within Python?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to find python34.lib from within Python?

Paul Moore
I want to set up a script to build some C code. I need to link it with python34.lib, but I'm not sure how to locate that file without hard-coding it.

There doesn't seem to be a sysconfig path I can use - best ways I can think of for finding it in a way that works even if I'm in a virtualenv is:

os.path.join(getattr(sys, 'real_prefix', sys.prefix), 'libs', 'python%s%s.lib' % sys.version_info[:2])

Is that the best way, or is there something better I could use?

In particular, this only works on Windows, which is OK for my needs, but it'd be nice if I could make it cross-platform, just in case.

Paul


Reply | Threaded
Open this post in threaded view
|

Is it possible to find python34.lib from within Python?

Ned Deily
In article <68710660-0f24-403a-8c3d-996c06a26a35 at googlegroups.com>,
 Paul  Moore <p.f.moore at gmail.com> wrote:
> I want to set up a script to build some C code. I need to link it with
> python34.lib, but I'm not sure how to locate that file without hard-coding
> it.
[...]

If you are embedding Python, refer to the "Extending and Embedding"
document in the Python documentation set and the description of
python-config:

https://docs.python.org/3/extending/embedding.html#compiling-and-linking-
under-unix-like-systems

(Of course, if you are extending Python, Distutils should provide all
the necessary flags.)

--
 Ned Deily,
 nad at acm.org