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

[question] Usage of self.run in the package_info method does not use environment #16978

Closed
1 task done
rohel01 opened this issue Sep 11, 2024 · 3 comments
Closed
1 task done

Comments

@rohel01
Copy link

rohel01 commented Sep 11, 2024

What is your question?

Hello,

I am cross-building my applications using a Yocto SDK. To better integrate this build process into conan, I created a small generator which automatically registers a script to setup the Yocto SDK environment before build.

This works surprisingly well for building and creating Conan packages since most build tools (cmake, meson, pkg-config...) are now provided by the Yocto SDK.

Lately, I tried to optimize the implementation of the package_info method for stub Conan packages already provided by Yocto. Since most Yocto packages are provided with pc files, I tried to reuse that information when building the cpp_info metadata

    def package_info(self):
        pkg_config = PkgConfig(self, self.name)
        pkg_config.fill_cpp_info(self.cpp_info, is_system=True)

The PkgConfig class internally uses conanfile.run but it seems environments are not activated as I expected: the Yocto SDK is not activated so cpp_info is filled with information from the wrong target.

Do you know how I can achieved the desired outcome? Looking at the PkgConfig class implementation again, I see I could override the "tools.gnu:pkg_config" property to point to the Yocto SDK binary. But I would be duplicating information, which I wanted to avoid in the first place.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Thanks for your question @rohel01

I think this is connected to #15099 and more discussed in #14422, and the approach to solve this is being documented in conan-io/docs#3811. Basically the package_info() cannot execute things from dependencies, it cannot inject "tool_requires", because the tool-requires are for "build-time", but the package_info() must work even if the tool_requires are not installed in the system (when installing for example a pre-compiled binary).

So please try the approach from conan-io/docs#3811, moving the tool-requires logic to build() or package() method, and let us know.

@rohel01
Copy link
Author

rohel01 commented Sep 13, 2024

Hello,

I confirmed the described approach solves my issue.

Thanks for the pointers!

@rohel01 rohel01 closed this as completed Sep 13, 2024
@memsharded
Copy link
Member

Great, happy to help!

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

2 participants