-
Notifications
You must be signed in to change notification settings - Fork 970
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] Error when detecting CPython version when included via CMake #16952
Comments
Hi @wawanbreton Thanks very much for your report. |
Related:
Adding |
Hi @wawanbreton The reason it is failing is because being a shared-library, it is not found in the runtime paths. Then it means that the runtime information is needed also at build time (the build-time information contains the runtime paths of the This can be modeled in different ways with Conan, for example: from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.env import VirtualRunEnv
class Pkt(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps"
requires = "cpython/3.12.2"
def configure(self):
self.options["cpython"].shared = True
def layout(self):
cmake_layout(self)
def generate(self):
VirtualRunEnv(self).generate(scope="build")
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build() It can be forced with Please try that and let us know if this makes sense. |
Hi, and thank you very much for you answers. Sorry for the delay in answering, I have been a bit sick. So, setting On the other hand, I am probably not the only one who will run into this issue, in this case I don't have a very exotic setup. But maybe other people can find this discussion, and then the solution for it ? I also see that the Thanks again for you help ! |
Thanks for the feedback! yes, lets leave it open, at least some improvements to the docs could be made. The thing is that "runtime" shared dependencies for "build time" are intrinsically complex, they don't have a great solution, and Conan can in fact do even more than some build systems can do by themselves. Still, it is very common for tools used at build-time to be statically linked to avoid these problems. But yes, at least some docs can be added to explain this, thanks again! |
Just chiming in - I'm glad that sanity check code I added actually caught something :) |
Describe the bug
Hi,
I'm trying to consume the
cpython/3.12.2
package for my project, which is Python binding.My
conanfile.py
contains the following:And also the classic CMake generator/build
Now my CMakeLists.txt contains:
Building CPython 2.12.2 works like a charm, and the
FindPython.cmake
file and associated are properly generated. But when I run myconan build .
, I get the following error:Apparently, when trying to detect the Python version, it finds Python 3.12.3 which is the one installed on my system. I indeed have the following:
I can then use the LD_LIBRARY_PATH trick to start the build, and this time the detection works properly. But this really sound like a dirty hack 😃
Do you think this is something about my environment, or is there indeed a bug somewhere ? In this case, I can try to provide a fix, but I don't know what part of the process is faulty.
How to reproduce it
The provided bug description should allow to reproduce it. Otherwise, I can make a minimal projet.
The text was updated successfully, but these errors were encountered: