Skip to content
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

Building with MinGW on Windows fails #900

Open
ThoreWietzke opened this issue Sep 14, 2024 · 6 comments
Open

Building with MinGW on Windows fails #900

ThoreWietzke opened this issue Sep 14, 2024 · 6 comments

Comments

@ThoreWietzke
Copy link

Installing e.g. the pybind11 example https://github.com/pybind/scikit_build_example with only MinGW (GCC) installed on Windows fails with a cryptic error message:

  × Building wheel for scikit_build_example (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      2024-09-14 09:09:38,528 - scikit_build_core - INFO - RUN: C:\Program Files\CMake\bin\cmake.EXE -E capabilities
      2024-09-14 09:09:38,544 - scikit_build_core - INFO - CMake version: 3.29.2
      *** scikit-build-core 0.10.6 using CMake 3.29.2 (wheel)
      2024-09-14 09:09:38,557 - scikit_build_core - INFO - Build directory: C:\Users\Thore\AppData\Local\Temp\tmpcpenilot\build
      *** Configuring CMake...
      2024-09-14 09:09:38,634 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None
      2024-09-14 09:09:38,643 - scikit_build_core - INFO - RUN: C:\Program Files\CMake\bin\cmake.EXE -S. -BC:\Users\Thore\AppData\Local\Temp\tmpcpenilot\build -CC:\Users\Thore\AppData\Local\Temp\tmpcpenilot\build\CMakeInit.txt -DCMAKE_INSTALL_PREFIX=C:\Users\Thore\AppData\Local\Temp\tmpcpenilot\wheel\platlib
      loading initial cache file C:\Users\Thore\AppData\Local\Temp\tmpcpenilot\build\CMakeInit.txt
      -- Building for: NMake Makefiles
      CMake Error at CMakeLists.txt:7 (project):
        Running
      
         'nmake' '-?'
     
        failed with:
     
         no such file or directory
     
     
      CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
      -- Configuring incomplete, errors occurred!
     
      *** CMake configuration failed
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for scikit_build_example
Failed to build scikit_build_example
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (scikit_build_example)

Building with MSVC works fine.
I know that GCC is not recommended for building extensions on Windows. Thus, a descriptive error message should hint the user at this problem.

@henryiii
Copy link
Collaborator

Scikit-build-core should try to build with the compiler used to compile Python. So if you used an MSVC-compiled Python, you'll likely see the above. If you used a Python built with MinGW, it should work out of the box.

Though I think the actual problem here is CMake can't find MSVC, so it's falling back on NMake as a default generator. Can you set CMAKE_GENERATOR to Ninja (for example) and try again?

@henryiii
Copy link
Collaborator

If you used a Python built with MinGW, it should work out of the box.

We test this, actually:

python:p python-pip:p gcc:p cmake:p

Though MSVC might still be detectable, so maybe we should make sure it's not used.

@ThoreWietzke
Copy link
Author

Scikit-build-core should try to build with the compiler used to compile Python. So if you used an MSVC-compiled Python, you'll likely see the above. If you used a Python built with MinGW, it should work out of the box.

Though I think the actual problem here is CMake can't find MSVC, so it's falling back on NMake as a default generator. Can you set CMAKE_GENERATOR to Ninja (for example) and try again?

That's good to know. It can't find MSVC, because it was not installed on that machine.
I've encountered this problem when using a pre-compiled Python for Windows (Which are compiled with MSVC, I presume) with a machine with only GCC available.

Can scikit-build-core detect this? For me it's no problem to install MSVC, but it took 2 hours with a colleague to find the culprit (Missing MSVC on his machine).

@ThoreWietzke
Copy link
Author

Actually, sk-build is able to identify such a situation:

2024-09-14 09:09:38,634 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None

Maybe make it more verbose and hint on this error?

@LecrisUT
Copy link
Collaborator

Actually, sk-build is able to identify such a situation:

2024-09-14 09:09:38,634 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None

Maybe make it more verbose and hint on this error?

Unfortunately that may not be desired. There are projects made in skbuild-core without python bindings like cmake or ninja. Maybe there could be a find_python like option that would control finding python-devel files and error if it couldn't.

I've encountered this problem when using a pre-compiled Python for Windows (Which are compiled with MSVC, I presume) with a machine with only GCC available.

Can scikit-build-core detect this?

Interesting idea, I think there could be a design for that if skbuild-core has a find_package(scikit-build-core) I'll open an issue for that.

@ThoreWietzke
Copy link
Author

The problem I see here is, that the build process hints at the CMakeLists.txt file as the source of error, whereas the different compilers for Python and the bindings are the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants