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

pkg-config and pythonX.X-config not correctly installed by actions/setup-python? #297

Closed
jdpipe opened this issue Dec 14, 2021 · 5 comments
Assignees
Labels
bug Something isn't working investigation The issue is under investigation

Comments

@jdpipe
Copy link

jdpipe commented Dec 14, 2021

Description:
I have a workflow that required building of shared libraries for OpenModelica that embed the Python interpreter. When using actions/setup-python to test this workflow, I don't seem to have a reliable way of detecting the configuration options for linking to libpython -- neither pkg-config nor python3.8-config (or whatever it is for the version of Python in question) seem to work reliably. What is the suggested approach?

Action version:
I'm using the current actions/setup-python@v2
See https://github.com/SolarTherm/SolarTherm/runs/4515306450?check_suite_focus=true for details.

Platform:

  • Ubuntu 20.04 and 18.04

Runner type:

  • Hosted

Tools version:
3.8 on 18.04
3.9 on 20.04
(see output at above link)

Repro steps:
See above link.

Expected behavior:
I would expect both pkg-config and python-config scripts to be provided. They don't seem to be.

Actual behavior:
Missing scripts/.pc files results in build errors.

@jdpipe jdpipe added bug Something isn't working needs triage labels Dec 14, 2021
@nikita-bykov nikita-bykov self-assigned this Dec 16, 2021
@nikita-bykov
Copy link
Contributor

Hello @jdpipe, thank you for report!
I went through your logs and found the following error: Package 'python-3.8-embed' not found
The error content suggests adding to the PKG_CONFIG_PATH environment variable a directory containing python-3.8-embed.pc.
The python-3.8-embed.pc file on Ubuntu can be found at /opt/hostedtoolcache/Python/3.8.12/x64/lib/pkgconfig, so you should add it to PKG_CONFIG_PATH environment variable:

export PKG_CONFIG_PATH=/opt/hostedtoolcache/Python/3.8.12/x64/lib/pkgconfig

To adapt this path to any OS and any Python version you can use $pythonLocation environment variable and write it like this:

export PKG_CONFIG_PATH=$pythonLocation/lib/pkgconfig

Could you please check and confirm that adding this environment variable works for you?

@jdpipe
Copy link
Author

jdpipe commented Feb 5, 2022

Thanks @nikita-bykov, that sounds like it should work.

However can I suggest that pkg-config, as a developer tool, becomes most useful when library installers put their .pc in a place somewhere that the system already knows to look for them. This is analogous to installing scripts/binaries somewhere that's on the user's PATH. Installing things where the system can't automatically find them just makes things less convenient, and more platform-specific code is needed by the final user.

So I think that setup-python should either be installing the .pc files in a standard place, placing a symlink, or by taking on the job of making system-level changes to the PKG_CONFIG_PATH (via /etc/profile.d or whatever GHA uses). I wonder, how do you handle the PATH for your setup-python action currently, such that calling python just works? Whatever you are doing for the executable, I suspect you can do the same for the .pc files.

Note that you can see what pkg-config is doing by running either pkg-config --debug 2>&1 | grep directory or pkg-config --variable pc_path pkg-config. On my local system, it reports

john@ovo:~/openmodelica$ pkg-config --debug 2>&1 | grep directory
Cannot open directory #1 '/usr/local/lib/x86_64-linux-gnu/pkgconfig' in package search path: No such file or directory
Cannot open directory #2 '/usr/local/lib/pkgconfig' in package search path: No such file or directory
Cannot open directory #3 '/usr/local/share/pkgconfig' in package search path: No such file or directory
Scanning directory #4 '/usr/lib/x86_64-linux-gnu/pkgconfig'
Scanning directory #5 '/usr/lib/pkgconfig'
Scanning directory #6 '/usr/share/pkgconfig'

Another option here is to place Python's python-config (python3.8-config, etc) script on the PATH. Ideally you would do both, since some software links to Python using pkg-config, others use python-config.

jdpipe added a commit to SolarTherm/SolarTherm that referenced this issue Feb 5, 2022
@vsafonkin vsafonkin self-assigned this Apr 19, 2022
@vsafonkin vsafonkin added the investigation The issue is under investigation label Apr 19, 2022
@dsame
Copy link
Contributor

dsame commented May 3, 2022

@jdpipe
I created the PR to set the PKG_CONFIG_PATH as you've advised, thanks.

@dsame
Copy link
Contributor

dsame commented May 5, 2022

@jdpipe setup-python action has been updated to set PKG_CONFIG_PATH, so i believe @marko-zivic-93 can close this issue as resolved, but please feel free to re-open the issue or create another one in case of any problems. Much thanks for your assistance.

@marko-zivic-93
Copy link
Contributor

Hello @jdpipe
As @dsame stated, I will close this issue, but feel free to leave a comment or create new issue if you still experience this problem.

@vsafonkin vsafonkin assigned dsame and unassigned vsafonkin May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigation The issue is under investigation
Projects
None yet
Development

No branches or pull requests

5 participants