Skip to content

Conversation

@mherkazandjian
Copy link
Contributor

Hi,

I think it is handy to allow passing a custom environment to pkgconfig.clags or the other calls that
invoke Popen at runtime. This would allow to access .pc files found under different PKG_CONFIG_PATH, filter some, add other paths to .pc files...etc..

This would require adding **kwargs to all the function calls that eventually invoke the _query function.

print(pkgconfig.cflags('python3'))
# >>>  '-I/usr/include/python3.6.m'

import os
custom_env = os.environ.copy()
custom_env['PKG_CONFIG_PATH'] = '/path/to/some/other/libs/prefixes'
print(pkgconfig.cflags('python3', env=custom_env))
# >>>  '-I/path/to/some/other/libs/prefixes/include/python3.6.m'

@matze
Copy link
Owner

matze commented May 17, 2017

I don't get it. Shouldn't the pkgconfig binary pick that up itself and that whole thing be transparent to the user of the API?

@mherkazandjian
Copy link
Contributor Author

with the current implementation once an import pkgconfig is done, you will always get the
same values for e.g pkgconfig.cflags('python'). But say I want to get the flags for an installation
of python that is not in PKG_CONFIG_PATH, with the changes I am suggesting it would be possible.
i hope i was able to explain things better :)

@matze
Copy link
Owner

matze commented May 18, 2017

with the current implementation once an import pkgconfig is done, you will always get the
same values

Yes of course. What I meant is: if I want to change the environment then I would do it where it's the most natural place, i.e. the surrounding shell. So if I do export PKG_CONFIG_PATH=/some/where/else right before calling the Python program all should be good.

@mherkazandjian
Copy link
Contributor Author

I agree. The problem I am trying to solve is that I have installed several versions of python (2.7.9, 2.7.11, 3.5, 3.6, 3.6.1...) in different prefix paths. Based on these versions I want to be able to ask pkg-config to get the cflags and link flags for a specific version without having to specify the pkg-config say at the shell. So this is more of a multiple configuration management exercise.

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

Successfully merging this pull request may close these issues.

2 participants