microsoft / vcpkg

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

pybind11: can't find Python.h #27854

Open dcnieho opened 1 year ago

dcnieho commented 1 year ago

My builds using pybind11 fail because Python.h cannot be found. How do i fix this?

I am building from Visual Studio 17.4.1, and my project has vcpkg integration switched on. Also manifest is on, install vcpkg dependencies is on, and autolink is on and an installed directory is specified. my manifest file contains the following:

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
  "name": "titta-wrapper",
  "version": "1.0.0",
  "dependencies": [
    {
      "name": "pybind11",
      "platform": "windows & x64"
    }
  ],
  "builtin-baseline": "183a12585a95b36bfdda342eb6d302d3ab3ad466"
}

Environment

To Reproduce Make a project with the above vcpkg settings and manifest file, then try to compile:

#define _CRT_SECURE_NO_WARNINGS
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
using namespace pybind11::literals;

// start module scope
PYBIND11_MODULE(TobiiWrapper, m)
{
        m.attr("__version__") = "dev";
}

Expected behavior Should work ;)

Failure logs Building from MSVC (when previous runs have already vcpkg-installed the dependencies without trouble) produces this error:

Build started...
1>------ Build started: Project: TobiiWrapper_cpp, Configuration: Release x64 ------
1>C:\utils\Titta-matlab\TittaMex\deps\vcpkg_installed_python_wrapper\x64-windows\include\pybind11\detail\common.h(124,10): fatal  error C1083: Cannot open include file: 'Python.h': No such file or directory
1>Done building project "TobiiWrapper_cpp.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
========== Elapsed 00:00.216 ==========

Additional context I am not sure how to list the contents of a vcpkg install directory through manifest, but can list this:

  1. the manifest pulled in python3 3.9.5
  2. vcpkg_installed_python_wrapper\x64-windows\include contains a folder python3.9 which contains Python.h, but its not found when including pybind11 (which is at vcpkg_installed_python_wrapper\x64-windows\include\pybind11)
github-actions[bot] commented 1 year 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.

github-actions[bot] commented 1 year 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.

github-actions[bot] commented 1 year 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.

QGB commented 10 months ago

https://github.com/caiorss/example-pybind11-vcpkg/issues/1

m-kuhn commented 9 months ago

related to https://github.com/microsoft/vcpkg/issues/34876 ?