Opened 6 years ago

Last modified 7 months ago

#56120 new defect

pkg-config fails to find python3

Reported by: aleb (Alex Băluț) Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.4.2
Keywords: Cc: raimue (Rainer Müller), yan12125 (Chih-Hsuan Yen)
Port: python27 python34 python35 python36 python_select

Description

I have port:python36 but pkg-config fails to find it:

$ find /opt/custom | grep \\.pc$ | grep -i python
/opt/custom/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig/python-2.7.pc
/opt/custom/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig/python.pc
/opt/custom/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig/python2.pc
/opt/custom/Library/Frameworks/Python.framework/Versions/3.6/lib/pkgconfig/python-3.6.pc
/opt/custom/Library/Frameworks/Python.framework/Versions/3.6/lib/pkgconfig/python-3.6m.pc
/opt/custom/Library/Frameworks/Python.framework/Versions/3.6/lib/pkgconfig/python3.pc

$ which python3
/opt/custom/bin/python3

$ /opt/custom/bin/pkg-config --list-all | grep python
.. crickets ..

Change History (9)

comment:1 Changed 6 years ago by aleb (Alex Băluț)

This happens even though I ran

sudo port select --set python3 python36

comment:2 Changed 6 years ago by kencu (Ken)

/opt/custom/Library/Frameworks/Python.framework/Versions/3.6/lib/pkgconfig

is not a default search directory for pkg-config files.

comment:3 Changed 6 years ago by jmroot (Joshua Root)

Putting python3.pc in the default pkgconfig search path is bad for ReproducibleBuilds. Fine to link python-2.7.pc, python-3.6.pc and so on.

comment:4 Changed 6 years ago by raimue (Rainer Müller)

Cc: raimue added
Port: python27 python34 python35 python36 python_select added
Summary: pkgconfig fails to find python3pkg-config fails to find python3

For those that stumble over this ticket while doing builds outside of MacPorts, the workaround is to set PKG_CONFIG_PATH manually:

$ pkg-config --print-provides python3
Package python3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `python3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'python3' found
$ export PKG_CONFIG_PATH=/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/pkgconfig
$ pkg-config --print-provides python3
python3 = 3.6

I agree that we do not want to use python3.pc when building a port. However, python3.pc could be managed by python_select. We also already have symlinks for the python3 and python3-config binaries. If a build system uses pkg-config ... python3, it would be the same as using python3-config. We will always have to handle these cases, most probably with patches.

comment:5 Changed 6 years ago by kencu (Ken)

So do we "fix" this by symlinking the properly-versioned *.pc files into the default search path, or just close it as "wontfix"?

comment:6 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

If port select is already symlinking *-config scripts, then it should also symlink *.pc files.

comment:7 Changed 6 years ago by aleb (Alex Băluț)

I noticed this problem while creating a Portfile. Maybe this info should be added in the howto for creating a new Portfile. Or in a "Python for Portfile authors" page if there is one? (see https://docs.brew.sh/Python-for-Formula-Authors)

comment:8 Changed 6 years ago by yan12125 (Chih-Hsuan Yen)

Cc: yan12125 added

comment:9 Changed 7 months ago by jmroot (Joshua Root)

Component: baseports
Note: See TracTickets for help on using tickets.