-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python3] Add vcpkg-cmake-wrapper. #15221
Conversation
This is still a WIP... For now, we only remove registry detection on Windows.
Co-authored-by: Jack·Boos·Yu <[email protected]>
FindPython is a builtin cmake module so this meets the usual "vcpkg-cmake-wrapper" nuclear option criteria. I do wonder though what our actual story is; we don't intend users to use the python port to get a That said, the existing FindPython bits don't distinguish these use cases so we might be in a situation where we provide that accidentially; what effect does this have on people who use vcpkg but are expecting to find a system python where there might be pip packages or similar? |
My focus in this PR is embedding Python into another application (in this case a 17 year old game). I agree that we don't want to replace the official Python distribution, but the separation of concerns as of Python 3 is very muddy. Python 3 is interesting in that the core actually imports Python code from its own standard library during initialization. If that code is unavailable, that is a fatal error. In order to properly make the Python standard library available, FindPython can report the location of the standard library on the build machine for bundling but only if the executable is available. In the project I help maintain, we have to use In #14891, I strove to make the vcpkg python3 "tool" look and behave similar to a system install of Python. When the port is built, we ensure that pip is installed, and that pip functionality is available. In the aforementioned project, we also have build scripts that need extensions installed by pip. This works by effectively ** The manual intervention required is to pass something like this to cmake: |
@BillyONeal I'll give you my bit on this. I work on KiCad. We embed python as part of our application and expose application functionality via api bindings. This means we have a fully functioning python interpreter DLL involved but not the python exes. The python upstream distributions cannot be used for this as compiler settings have to match entirely across the whole build. In many cases there are libraries used by these core modules that vcpkg builds as well. This would mean we would need to somehow handle two separate copies of openssl at different versions for example which I don't even want to think of the LoadLibrary hell. Hoikas has been pushing to include support for being able to fully have true embeddable python with these modules |
Ping @BillyONeal for response. |
I tagged with "requires: discussion" because I want it to be discussed; normally we discuss PRs with that tag on Thursdays but that didn't happen last week due to holidays :) |
OK, after some discussion it seems like the behavior should be:
Was that your intent? |
3593500
to
5db060a
Compare
5db060a
to
17aa0b2
Compare
17aa0b2
to
e9647f7
Compare
Ok, I've written up the suggestions by @BillyONeal, and, as a bonus, added a Per the documentation:
So:
Note that
|
6d370e1
to
6f9a24a
Compare
6f9a24a
to
cfd451b
Compare
Note that this PR does not solve the issue that some ports rely on python2 instead of python3: PS F:\vcpkg> .\vcpkg.exe install cppcms
Computing installation plan...
The following packages will be built and installed:
cppcms[core]:x86-windows -> 1.2.1-1
...
Finding PYTHON2 name python in F:/vcpkg/downloads/tools/python/python-2.7.16-x86;F:/vcpkg/downloads/tools/python/python-2.7.16-x86
... but log shows:
edit: I think we can only fix |
IIRC, cppcms does something strange with the |
@Hoikas Can you please fix it for the current version? |
This adds a vcpkg-cmake-wrapper.cmake to the python3 port. CMake offers three disparate find modules that are compatible with Python 3.x. They are FindPythonInterp, FindPythonLibs, and FindPython. The first two are deprecated since CMake 3.12 but still widely used, and the last one implements FindPython2 and FindPython3. Working with these find modules is particularly challenging due to their propensity to find the Python installed by the system package manager or an installed Windows Python. FindPython particularly has issues resolving the Python libraries due to the separate debug/lib and lib directories in the vcpkg installed tree. This ensures that any calls to find_package() for PythonLibs, PythonInterp, and Python3 correctly finds the vcpkg provided python3 port. To see the improvement, look at the simplification to the python feature of itk.
I'd appreciate review, especially around the macOS portion of the wrapper. I don't have access to a mac machine, and the workarounds for static linkage are very empirical from my custom tests on GHA.
What does your PR fix?
Fixes [python3] cmake FindPython3 Development component #9026
Closes [python3] Improve support for embedding and add tools #13556
Which triplets are supported/not supported? Have you updated the CI baseline?
No change
Does your PR follow the maintainer guide?
Yes