pykg-config
pykg-config copied to clipboard
Search-paths default differs from pkg-config
The use of "all paths in ${prefix}/lib[64]/pkgconfig/ and ${prefix}/share/pkgconfig/, where ${prefix} is a system prefix (typically this will be /usr/)." as the default search paths is different from pkg-config. As the README notes, pkg-config hardcodes a search-path list at its compile-time, which means the vendor or sysadmin can define any arbitrary list and pkg-config will always use it by default. But pykg-config does not appear to have a way to permanently alter the default. I can use env vars to override it at runtime, but that means all my users have to be doing it (and risking breaking it by strict env-cleanup via sudo, or other site policies). It would be useful if setup.py took a --with-pc-path flag (like pkg-config's ./configure) to force hardcoding a specific default.
Maybe I didn't explain the algorithm clearly. --with-pc-flag sets the default, not the mandatory only. PKG_CONFIG_LIBDIR still replaces it at runtime and PKG_CONFIG_PATH still prepends to take precedence. That's because pkg-config itself doesnt' do "Else append prefix/lib/pkgconfig, prefix/share/pkgconfig". So This setting would just replace that narrow piece of the logic rather than mandating exclusively this search list.
Sorry for the misunderstanding. I've fixed the ordering and checked that it matches what pkg-config does.
Looks fine now. README.txt needs to be updated to match (the "Package paths" section still describes the transiently-implemented way).
Actually no, it doesn't work. 'setup.py build_py --with-pc-path=[path]' correctly stashes [path] in install_config.py, but 'setup.py install' nukes that setting (installs install_config.py containing "pc_path = None"). Looks like 'setup.py install' doesn't accept --with-pc-path ("error: option --with-pc-path not recognized") and even trying it combined ('setup.py build_py --with-pc-path=[path] install') still gives me "None" (consistent with the 'install' implementation neither allowing --with-pc-path being passed to it nor respecting the setting from the preceding build_py).
(sorry for the stream-of-consciousness/debugging session here!)
I can use --skip-build in the 'setup.py install' to avoid breaking the formerly-correct install_config.py, but then install itself fails because setup.py build_py only builds the pure-python modules, not the pykgconfig script itself (that only happens if I explicitly 'setup.py build_scripts'). 'setup.py build' handles all the build_* internally and is the standard way I've seen setup.py used, but that mode doesn't support --with-pc-paths (only build_py being called explicitly).
Overwriting the value of with_pc_path with None when executing 'setup.py install' is a consequence of the way distutils works. The 'install' command executes all its dependency commands again. This includes executing 'build_py' (indirectly via executing the 'build' command), which is why the with_pc_path option becomes None.
If I run the following command, then install_config.py correctly includes the value I specified for with_pc_path:
python setup.py build_py --with-pc-path='/opt/X11/lib/pkgconfig:usr/lib/pkgconfig' install