-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Added components to fix pybind11 #4445
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I detected other pull requests that are modifying pybind11/all recipe: This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prs so don't hesitate to report issues/improvements there. |
Hi, |
Waiting for the update of Conan version to add this support in the recipe |
recipes/pybind11/all/conanfile.py
Outdated
self.cpp_info.components["main"].names["cmake_find_package"] = "pybind11" | ||
self.cpp_info.components["main"].builddirs = [cmake_base_path] | ||
for generator in ["cmake_find_package", "cmake_find_package_multi"]: | ||
self.cpp_info.components["main"].build_modules[generator].append(os.path.join(cmake_base_path, "FindPythonLibsNew.cmake")) | ||
self.cpp_info.components["main"].build_modules[generator].append(os.path.join(cmake_base_path, "pybind11Tools.cmake")) | ||
self.cpp_info.components["headers"].includedirs = [os.path.join("include", "pybind11")] | ||
self.cpp_info.components["headers"].requires = ["main"] | ||
self.cpp_info.components["embed"].requires = ["main"] | ||
self.cpp_info.components["module"].requires = ["main"] | ||
self.cpp_info.components["python_link_helper"].requires = ["main"] | ||
self.cpp_info.components["windows_extras"].requires = ["main"] | ||
self.cpp_info.components["lto"].requires = ["main"] | ||
self.cpp_info.components["thin_lto"].requires = ["main"] | ||
self.cpp_info.components["opt_size"].requires = ["main"] | ||
self.cpp_info.components["python2_no_register"].requires = ["main"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those components names are too generic for pkg-config generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those are the names of the CMake targets in pybind11. Do you have any suggestions? I will resume work on this PR once Conan is updated and let's see if those components really make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, add a prefix for conan components names, and set cmake_find_package and cmake_find_package_multi names explicitly.
pkg_config names will inherit from conan components names (if it's too generic they might conflict with others pkg_config files in the dependency graph even if consumer doesn't care of pybind11 pkgconfig files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider my comment #4445 (comment), I'd prefer to move this forward and then improve the components' related stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Components are part of the interface (downstream recipes might rely on those conan components names in their package_info). It's better to not introduce generic component names, because we would have to remove them later, and it would be a breaking change in the recipe.
recipes/pybind11/all/conanfile.py
Outdated
self.cpp_info.components["main"].names["cmake_find_package"] = "pybind11" | ||
self.cpp_info.components["main"].builddirs = [cmake_base_path] | ||
for generator in ["cmake_find_package", "cmake_find_package_multi"]: | ||
self.cpp_info.components["main"].build_modules[generator].append(os.path.join(cmake_base_path, "FindPythonLibsNew.cmake")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including FindPythonLibsNew
will enforce use of the deprecated FindPythonInterp
etc. pybind supports the new FindPython
modules (CMake 3.12+) but if you remove pybind11NewTools
etc, it won't be able to use it.
Maybe make it an option? See also #4641
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Given there are now recipes on the index that require For this reason, I am interested in the status of this PR. There was some reference to wait for a Thanks. |
Are there any updates on this PR / issue? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
All green in build 11 (
|
I know it is far from complete regarding components and it will require some more time to understand each of the cmake targets and relations among them, but at least this works as expected without requiring packaging config files. I'd prefer to have this merge in order to fix #4407 and then continue the work in the recipe to improve it |
cmake_base_path = os.path.join("lib", "cmake", "pybind11") | ||
self.cpp_info.builddirs = [cmake_base_path] | ||
if tools.Version(self.version) >= "2.6.0": | ||
self.cpp_info.components["main"].names["cmake_find_package"] = "pybind11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I comment I see often (but I am no expert) we need to be caution about generic conan component names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, already mentioned here: #4445 (comment)
Hi, these changes have broken my builds and I can't seem to find a way to use the new revision of 2.6.1 version.
and then linking with
If dropping the pybind:: targets was intended what's the replacement here? |
You should be able to use the |
These changes seem to have broken our builds. Our setup is super simple. In our CMakeLists.txt we have pybind11_add_module(mytarget main.cpp)
target_link_libraries(mytarget PRIVATE CONAN_PKG::pybind11) Invoking with cmake -DPython3_EXECUTABLE=/my/python /my/code gives this output
How is
Results in
|
To get the missing file |
@m-drozd @jornb please check the test_package of the recipe https://github.com/conan-io/conan-center-index/tree/master/recipes/pybind11/all/test_package to see how this should be consumed correctly. Generators in consumers should be
|
Yeah I managed to get it working after messing with |
* Added components to fix pybind11 * required conan version * remove config files * remove cmake files not needed * fix unlink * add rest of macros * order * patch pybind11common file * set standard * remove other modules from build_modules
Posting here to get some attention from the community. |
I'm also having an issue with the pybind11 package which I think is related to these changes. I'm using cmake_find_package_multi together with CMake Generator for Visual Studio (multi-configuration build), and find_package(pybind11 REQUIRED) is throwing the following error:
I wonder if it is trying to execute this script for all configurations (Debug/Release/RelWithDebInfo) and there is no guard against multiple-includes? |
I'm getting another error at this location:
It looks like both pybind11NewTools.cmake AND pybind11Tools.cmake are being run, but they create the same targets, and presumably only one should be used? |
Same as above, I'm completely stuck... Any news on this? |
I modified the recipe (we fork them locally, so was fortunate to be able to do this) to patch the sources as follows:
I appreciate that this is a total hack, but the scripts are completely broken as they are so had no other solution... (note: CMake's include_guard requires cmake 3.10 or higher) The include guard was required because the file gets loaded multiple times, resulting in the same target being created multiple times. The add_library call was to fix the actual issue here of both scripts getting run (I'm going from memory here...). My usage in CMake is as follows... using conan's cmake_find_package_multi generator:
|
Hello, I don't understand why the the pybind11 recipe does removes the "pybind11Targets.cmake", "pybind11Config.cmake", "pybind11ConfigVersion.cmake". I cannot use I ended up using the following (as mentioned in #9343): It seems that the official pybind11 package from conan doesn't expose all cmake files from pybind11. For instance I ended up using a custom conan package that works nicely with CMakeDeps and CMakeToolchain generators (that are the recommended way for conan 2.0): import os
from conans import ConanFile, tools, CMake
class PyBind11Conan(ConanFile):
name = "pybind11"
version = "2.9.2"
settings = "os", "compiler", "arch", "build_type"
description = "Seamless operability between C++11 and Python"
homepage = "https://github.com/pybind/pybind11"
license = "BSD Style: https://github.com/pybind/pybind11/blob/master/LICENSE"
url = "https://github.com/conan-community/conan-pybind11"
no_copy_sources = True
def source(self):
tools.get("%s/archive/v%s.tar.gz" % (self.homepage, self.version))
def build(self):
cmake = CMake(self)
cmake.definitions["PYBIND11_TEST"] = False
cmake.configure(source_folder="pybind11-%s" % self.version)
cmake.build()
cmake.install()
def package(self):
self.copy("*LICENSE", keep_path=False)
def package_id(self):
# Make all options and dependencies (direct and transitive) contribute
# to the package id
self.info.requires.full_package_mode()
def package_info(self):
self.cpp_info.builddirs.append(os.path.join("share", "cmake", "pybind11")) It is an adaptation of this https://github.com/conan-community/conan-pybind11. My CMakeLists.txt looks like that:
@danimtb Do you think I should do a PR? I'm sure I'm missing a lot of stuff. I'm really new to conan. It would be great to have the support of pybind11 with the new recommended generators. |
Specify library name and version: pybind11/2.6.0, pybind11/2.6.1
closes #4407
First try to model the pybind11 components. I got the test_package example working but I am sure there are cases that are still not covered. However, this is a start and the recipe works without doing tricks to package the CMake config file.
conan-center hook activated.