On 12 Jan 2020, at 16:20, musbur@posteo.org wrote:
Hi guys,
after I got the whole list into a lather about the merits of the python-config program, let me rephrase the question:
Is there a "canonical" way of automatically finding the correct include files and Python runtime library when embedding the Python interpreter, based on the current virtual environment (and not the "installed" version)? Upon reding the docs there isn't. And maybe there should't or cant be any. So if I want to try embedding Python under different versions I have to either install those into different directories and use python-config, or I write a trivial Python program that finds the correct values for the current environment using sysconfig and outpus those as compiler / linker flags. Easy enough, I was just surprised that no such solution was already built into the virtualenv setup mechanism
Here's a quote from the docs """ If this procedure [using python-config] doesn’t work for you (it is not guaranteed to work for all Unix-like platforms; however, we welcome bug reports) you will have to read your system’s documentation about dynamic linking and/or examine Python’s Makefile (use sysconfig.get_makefile_filename() to find its location) and compilation options. In this case, the sysconfig module is a useful tool to programmatically extract the configuration values that you will want to combine together. For example:
import sysconfig sysconfig.get_config_var('LIBS') '-lpthread -ldl -lutil' sysconfig.get_config_var('LINKFORSHARED') '-Xlinker -export-dynamic' """
I build a python C++ extension called pysvn. It's build system works by running a python program to generate a native makefile for Windows, macOS, Fedora, NetBSD etc. The code support python 2 and all the python 3's. I have all the python versions installed on my build systems side-by-side. I did not need to use venv as all the python's are installled into the systems. Maybe you can use some of the ideas from the code. See this module: https://svn.code.sf.net/p/pysvn/code/trunk/pysvn/Extension/Source/setup_conf... <https://svn.code.sf.net/p/pysvn/code/trunk/pysvn/Extension/Source/setup_conf...> Barry
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/364Q6EZH... Code of Conduct: http://python.org/psf/codeofconduct/