Skip to content

[python3] cmake FindPython3 Development component #9026

@heydojo

Description

@heydojo

vcpkg does not present it's python3 port well to other ports and or there may be missing development files. cmake has built in support for detecting python3 and it is struggling to find the development component when python3 is installed via vcpkg.

For context, if you install python3 for Windows via the Visual Studio installer and a port you are building uses cmake and in the cmake files there is:

find_package(Python3 COMPONENTS Development)

https://cmake.org/cmake/help/v3.12/module/FindPython3.html

When the port is then built by vcpkg, cmake will pickup the python3 development component and the build will succeed.

If instead, you do not install python3 for Windows via the Visual Studio installer and simply add the dependency python3 to the CONTROL file of the port and attempt to build, if you ensure that:

vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${PYTHON3_DIR}")

is inside the portfile, then the python exe is picked up but the development component is not found at all by cmake and the build will fail.

If you then go on to look at the python3 port's installed files and compare them to the python for Windows installed files, it appears that there may be a large number of files useful for developing python applications missing from vcpkg's python3 port's installation.

Proposed solution
vcpkg_find_acquire_program(PYTHON3) might benefit from special logic to determine if the python3 port has been built and installed so that it can present what cmake expects to find.

The expected development files are revealed to cmake via vcpkg's python3 port's installation or a python3-dev port is created to ensure that those who only want the lib get only what they need but the development files can be had separately.

Describe alternatives you've considered
I tried the MS Visual Studio Installer Python for Windows and it's system integration was much better than vcpkg's. cmake had absolutely no problems. Obviously, that kind of support would be nice in vcpkg.

Additional context
Python's pretty big now. It's become the common language at large and it's popularity continues to grow. Python 2 has been officially announced as being depreciated at the start of next year, so there will be lots of work going on now where developers are porting to Python 3.

Although vcpkg is primarily a C++ package manager, the growing number of C++ Python 3 bindings and the way in which vcpkg is especially useful for reproducible builds makes Python 3 integration on par with the integration found in the Visual Studio Installer an especially interesting goal.

Whilst it could be argued to just use Visual Studio's Python 3 installation, it appears more suitable to me, to use the Python 3 port instead.

Metadata

Metadata

Assignees

Labels

category:port-featureThe issue is with a library, which is requesting new capabilities that didn’t exist

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions