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

Check more than just <prefix>/lib/pkgconfig #16

Open
leorich opened this issue Aug 1, 2024 · 0 comments
Open

Check more than just <prefix>/lib/pkgconfig #16

leorich opened this issue Aug 1, 2024 · 0 comments

Comments

@leorich
Copy link

leorich commented Aug 1, 2024

/share/pkgconfig is widely used pkgconfig dir as well.

Not sure how to submit PR, but here is some code that searches other directories.

class PkgConfigEnvironment(EnvironmentExtensionPoint):
    """
    Extend the environment variable PKG_CONFIG_PATH.

    A package needs to provide the file 'lib/pkgconfig/<pkgname>.pc' to extend
    the environment variable.
    """

    def __init__(self):  # noqa: D107
        super().__init__()
        satisfies_version(
            EnvironmentExtensionPoint.EXTENSION_POINT_VERSION, '^1.0')

    def create_environment_hooks(self, prefix_path, pkg_name):  # noqa: D102
        subdirectory = self._get_pc_subdir(prefix_path, pkg_name)
        if subdirectory is not None:
            return create_environment_hook(
                'pkg_config', prefix_path, pkg_name, 'PKG_CONFIG_PATH',
                str(subdirectory), mode='prepend')
        return []
    
    def _get_pc_subdir(self, prefix_path, pkg_name):
        subdirectories = [Path('lib') / 'pkgconfig', 
                          Path('share') / 'pkgconfig']
        for subdirectory in subdirectories:
            pkg_config_file = prefix_path / subdirectory / (pkg_name + '.pc')
            logger.log(1, "checking '%s'" % pkg_config_file)
            if pkg_config_file.is_file():
                return subdirectory
        return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant