microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.26k stars 6.41k forks source link

[pybind11] is there an option to link the system python3 lib and not link python3_d.dll when in debug mode #35169

Open miyanyan opened 12 months ago

miyanyan commented 12 months ago

Environment

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg install pybind11
  2. find_package(Python3 EXACT 3.8 COMPONENTS Interpreter Development REQUIRED)

Expected behavior hi, I wanna use pybind11 in this way:

Additional context I found in this pr https://github.com/microsoft/vcpkg/pull/31318 Py_DEBUGwill be set in debug mode, but not all the system python lib has debug version

Osyotr commented 12 months ago

The patch should be reverted BUT a proper instructions about how to use pybind11 should be provided instead.

MonicaLiu0311 commented 12 months ago

The patch should be reverted

If this patch is reverted, issues like https://github.com/microsoft/vcpkg/issues/30642 and https://github.com/microsoft/vcpkg/issues/31311 will appear.

BUT a proper instructions about how to use pybind11 should be provided instead.

Could you elaborate on your thoughts about this?

@Neumann-A Asking for your help.

Neumann-A commented 12 months ago

I think you can ask @BillyONeal since he will nuke system linkage of python in the future any way.

Osyotr commented 12 months ago

Could you elaborate on your thoughts about this?

Some users want pybind11 and system python (1), some users want pybind11 and python from vcpkg (2). Both are valid, but after #31318 (1) is broken and (2) works without additional interventions. The patch should be reverted and documentation about how to make (2) work should be added.

Neumann-A commented 12 months ago

Pybind11 and linking system python is not an option in vcpkg without an overlay. So breaking it is ok and even intended.

BillyONeal commented 11 months ago

If you want the default vcpkg experience, everything building things that load into python need to use the python port.

If you want the system python to be used instead, you need to install python development headers and libraries to the system, and overlay the python3 port with an empty one.

There is no desire to create frankenstein installed trees where some binaries therein expect system python and some expect vcpkg's built copy of python.

The only reason the system python should be being used is for running build systems or other scripts that are just "running .py files"

miyanyan commented 11 months ago

after this pr https://github.com/microsoft/vcpkg/pull/32194, vcpkg install pybind11will not install python first, so when I write find_package(Python3), if no python installed by vcpkg, it will find system python, otherwise it will use vcpkg's python. This's an option for me, it's great.

when using pybind11:

BillyONeal commented 11 months ago

after this pr #32194, vcpkg install pybind11will not install python first, so when I write find_package(Python3), if no python installed by vcpkg, it will find system python, otherwise it will use vcpkg's python. This's an option for me, it's great.

I must have not understood this when I merged it. Installs must not be path dependent. That is,

vcpkg install pybind11
vcpkg install python3

must produce the same results as

vcpkg install python3
vcpkg install pybind11

or features like binary caching that depend on ports providing this behavior will break.

If pybind11 needs to find a python to load things into, it needs to use the vcpkg one, not the system one, always. If you want to force the system one, overlay python3 with an empty port.

if use pybind11 to write python module, like create xxx.pyd, it's ok to use vcpkg or system python, because I dont't need to pip install xxx, the pure python env is enough.

It is unlikely that the system python and vcpkg's python are ABI compatible.

if use pybind11 to call python in c++, I have to install some python packages using pip most of the time, so since the packages are already installed in system python, using vcpkg's python will need more work.

Then that more work is necessary. Again, if you want to use the system python, you can overlay python3 with an empty port, and the universe becomes consistent again.

github-actions[bot] commented 10 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.