-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] -requiresAny
is not recognized by Visual Studio 2017 < v15.6
#3946
Comments
Hi @AndrewTsao, thank you very much for writing this report. Is there any chance you can expand a little bit more in the reproducer. Right now it is a bit difficult to understand what is going on. A good methodology for how to write reproducers is the following: https://stackoverflow.com/help/minimal-reproducible-example. Also could you please include the commands of how you are building your package? Does it behave the same way if you use Please note that the naming MSVC14 used in setuptools is not exactly related to the year of release of the toolkit. You can see in the file below that this number seems to be related to the runtime library version instead: Lines 2 to 11 in b545fc7
This is probably how setuptools is finding the latest installation of the toolkit: Lines 71 to 104 in b545fc7
Do you know what the |
My virtualenv: My setup.py file: from setuptools import setup, Extension
import numpy as np
__version__ = '0.0.1'
requires = ['numpy']
setup_requires = ['pybind11','wheel']
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
def __init__(self, user=False):
self.user = user
def __str__(self):
import pybind11
return pybind11.get_include(self.user)
ext_modules = [
Extension(
'example',
['src/main.cpp'],
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
get_pybind_include(user=True),
np.get_include()
],
language='c++',
# 如果是调试模式,添加以下选项。
extra_compile_args=['/Od', '/Zi'],
extra_link_args=['/DEBUG:FULL']
),
]
setup(
name='example',
ext_modules=ext_modules,
install_requires=requires,
setup_requires=setup_requires,
platforms='win_amd64',
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*'
) `src/main.cc' #include <Python.h>
#define PY_ARRAY_UNIQUE_SYMBOL MYLIBRARY_ARRAY_API
#define PY_UFUNC_UNIQUE_SYMBOL MYLIBRARY_UFUNC_API
#include <numpy/arrayobject.h>
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
namespace py = pybind11;
using namespace py::literals;
struct Point
{
int x;
int y;
double z;
};
struct Points
{
Points()
{
points.resize(10);
for (int i = 0; i < 10; i++) {
points[i].x = i;
points[i].y = i;
points[i].z = i * 6.6;
}
}
~Points()
{
std::cout << (void*)this << ": Points bye, p:" << (void*)points.data() << std::endl;
}
std::vector<Point> points;
py::buffer_info Buffer();
};
py::buffer_info Points::Buffer()
{
auto buf = py::buffer_info(
points.data(), /* Pointer to buffer */
sizeof(Point), /* Size of one scalar */
py::format_descriptor<Point>::format(), /* Python struct-style format descriptor */
1, /* Number of dimensions */
{ 10 }, /* Buffer dimensions */
{ /* Strides (in bytes) for each index */
sizeof(Point) }
);
return buf;
}
PYBIND11_MODULE(example, m) {
PYBIND11_NUMPY_DTYPE(Point, x, y, z);
py::class_<Points>(m, "Points", py::buffer_protocol())
.def_buffer([](Points &m) -> py::buffer_info {return m.Buffer();});
m.doc() = "test pybind11 module";
import_array1();
} build command: |
Hi @AndrewTsao, can you try running The thing about renaming The patch for Lines 154 to 187 in b545fc7
Here you can see that setuptools will use a If you compare Footnotes
|
It seems that the So probably what is happening is that Now we have to trace down why the author of the patch in I don't know what is the relationship between the versions of the VC toolkit and |
It seems the |
If we see the release pages for By correlating the date with the Visual Studio 2017 releases, we can say that the earliest possible Visual Studio to include this (or a later) version of This means that I asked the original author of the PR about suggestions for how to tackle this problem. |
-requiresAny
is not recognized by Visual Studio 2017 < v15.6
Hi @AndrewTsao, could you please confirm if the PR #3950 would solve your problem? pip install https://github.com/abravalheri/setuptools/archive/refs/heads/issue-3946.zip |
In my environment, the problem was solved after pip install setuptools-issue-3956.zip. Thank you for your efforts. |
Thank you very much for trying it out Andrew. Let's see if we can have feedback from the other maintainers about the PR, so it can land on the next release. |
setuptools version
setuptools==67.8.0
Python version
Python 3.09, 3.10, 3.11
OS
Windows Server 2012r2
Additional environment information
No response
Description
Hi,
I encountered an error when using setup.py to compile a module related to pybind11. The error message was
pybind11\detail/common.h(86): fatal error C1189: #error: pybind11 2.10+ requires MSVC 2017 or newer
. But I actually had VS2017 installed. Later, I found that the _msvccompiler.py module in setuptools seemed to be highly optimized, causing the _get_vc_env function to always return the environment variables of MSVC14. And I tried to add some print statements in that function, but nothing was printed, proving that the function was never called. Finally, I renamed _get_vc_env to _get_vc_env1, and setup.py worked fine.I tried to print the name of the _get_env_vc function, and the actual output was “<function msvc14_get_vc_env at 0xxxxxxxx>.”, which looked like a function that was optimized for a specific compiler.
Expected behavior
setuptools can dected vs2017 environment.
How to Reproduce
Output
\.py3.11\lib\site-packages\pybind11\include\pybind11\detail/common.h(86): fatal error C1189: #error: pybind11 2.10+ requires MSVC 2017 or newer
The text was updated successfully, but these errors were encountered: