Skip to content

[question] tool requirements not available on package_info(), how do we handle pkg_config.fill_cpp_info if pkgconf is not installed on the OS? #14422

@ericriff

Description

@ericriff

What is your question?

This is on Conan 1.x.

I'm trying to build libudev/system which on the package_info() method calls pkg_config.fill_cpp_info() which relies on the pkg-conf executable.

Since I don't have it on my OS, I decided to include it as a tool_requirement(). But that doesn't work for 2 reasons:

  1. The pkgconf recipe provides an app named pkgconf but fill_cpp_info() expects it to be called pkg-conf. No big deal, that can be overridden with tools.gnu:pkg_config = 'pkgconf', but I thought it was an interesting inconsistency.
  2. The PATH from the tool_requirements doesn't get set on package_info(), so even if I add pkgconf as a build requirement and set the name of the executable on the profile as mentioned above, the recipe still fails to build.

Diff:

diff --git a/recipes/libudev/all/conanfile.py b/recipes/libudev/all/conanfile.py
index 46c164d11..b73f8ace7 100644
--- a/recipes/libudev/all/conanfile.py
+++ b/recipes/libudev/all/conanfile.py
@@ -27,6 +27,9 @@ class LibUDEVConan(ConanFile):
     def package_id(self):
         self.info.clear()
 
+    def build_requirements(self):
+        self.build_requires("pkgconf/1.9.5")
+
     def system_requirements(self):
         dnf = package_manager.Dnf(self)
         dnf.install(["systemd-devel"], update=True, check=True)
@@ -43,8 +46,10 @@ class LibUDEVConan(ConanFile):
         zypper = package_manager.Zypper(self)
         zypper.install_substitutes(["libudev-devel"], ["systemd-devel"], update=True, check=True)
 
+
     def package_info(self):
         self.cpp_info.includedirs = []
         self.cpp_info.libdirs = []
+        breakpoint()
         pkg_config = PkgConfig(self, "libudev")
         pkg_config.fill_cpp_info(self.cpp_info)

Error message:

ERROR: libudev/system@test/test: Error in package_info() method, line 54
	pkg_config = PkgConfig(self, "libudev")
	ConanException: pkg-config command ['"pkgconf"', '--print-provides', 'libudev', '--print-errors'] failed with error: Command '\"pkgconf\" --print-provides libudev --print-errors' returned non-zero exit status 127.
/bin/sh: 1: "pkgconf": not found

And

ls /home/eriff/.conan/data/pkgconf/1.9.5/_/_/package/24647d9fe8ec489125dfbae4b3ebefaf7581674c/bin
aclocal  pkgconf

How do we work around this? Will we have to install pkgconf on the OS alongside conan to make all the recipes that rely on fill_cpp_info build?

Thanks, Eric.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions