pykg-config icon indicating copy to clipboard operation
pykg-config copied to clipboard

Search-paths default differs from pkg-config

Open dmacks opened this issue 10 years ago • 6 comments

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.

dmacks avatar Jun 03 '14 10:06 dmacks

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.

dmacks avatar Jun 10 '14 03:06 dmacks

Sorry for the misunderstanding. I've fixed the ordering and checked that it matches what pkg-config does.

gbiggs avatar Jun 11 '14 03:06 gbiggs

Looks fine now. README.txt needs to be updated to match (the "Package paths" section still describes the transiently-implemented way).

dmacks avatar Dec 25 '14 06:12 dmacks

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).

dmacks avatar Dec 25 '14 07:12 dmacks

(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).

dmacks avatar Dec 25 '14 07:12 dmacks

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

gbiggs avatar Jan 26 '15 06:01 gbiggs