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

CMake Error Could NOT find Python (missing: Development.Module) #20

Closed
maximvochten opened this issue Sep 12, 2024 · 4 comments
Closed

Comments

@maximvochten
Copy link
Collaborator

maximvochten commented Sep 12, 2024

Issue is explained here: #17 (comment)

Temporary solution is to change these lines in CMakeList.txt back to

if(WITH_PYTHON)
  add_subdirectory(external/pybind11)
  add_subdirectory(fatropy)
endif()
@nim65s
Copy link
Contributor

nim65s commented Sep 12, 2024

I can't reproduce your issue, with the following workflow:

FROM ubuntu:24.04

RUN apt-get update && apt-get install -qqy \
    build-essential \
    cmake \
    git \
    python3-dev

RUN git clone --recursive https://github.com/meco-group/fatrop

RUN cmake -B build -S fatrop -DWITH_PYTHON=ON

Can you provide more informations on your system, the commit you are on, and the command you use to configure the project ?

@maximvochten
Copy link
Collaborator Author

Thank you for your reply. It made me realize that the problem is because I am on Ubuntu 20.04 with CMake 3.16 (which is the latest release on Debian for Cmake).

I discovered that "Development.Module" while finding Python was only introduced in CMake 3.18. Changing that line in CMakeLists.txt to

find_package(Python REQUIRED COMPONENTS Interpreter Development)

solves my issue. I also had to install pybind11 system-wide using

sudo apt-get install pybind11-dev

@nim65s
Copy link
Contributor

nim65s commented Sep 13, 2024

You are right, thanks. We could, either:

  1. replace Development.Module by Development, as you propose, but this impose the additional requirement of having libpython.so available even if we don't really need it. This would prevent fatropy to be easily used with alternative python implementations like pypy, and also prevent fatropy to be easily distribuable on PyPI.
  2. update the cmake_minimum_required(VERSION 3.14) to 3.18, but this would force ubuntu 20.04 users to upgrade either their whole system, or install an updated version of CMake (pip install cmake would work, but that is still an additional packaging constraint)
  3. use a condition, like:
if(CMAKE_VERSION VERSION_LESS "3.18")
  find_package(Python REQUIRED COMPONENTS Interpreter Development)
else()
  find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
endif()

The system-wide pybind11 is a good solution, but not the only one: you could also have used the git submodule, if did not want (or could not) run that sudo apt …. This is what I did with the --recursive flag in the example above.

@lvanroye
Copy link
Collaborator

Hi Guilhem and Maxim,

Thanks a lot for figuring this out and the suggestions for fixing the issues. We think the third option is the best solution. I implemented it (see commit bcf259d).

Best,
Lander

@wdecre wdecre closed this as completed Sep 14, 2024
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

4 participants