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

Unexpected prefix value in .../lib/pkgconfig/python-3.<minor>.pc #10185

Closed
Matiiss opened this issue Dec 26, 2024 · 3 comments · Fixed by #10189
Closed

Unexpected prefix value in .../lib/pkgconfig/python-3.<minor>.pc #10185

Matiiss opened this issue Dec 26, 2024 · 3 comments · Fixed by #10189
Assignees
Labels
bug Something isn't working compatibility Compatibility with a specification or another tool

Comments

@Matiiss
Copy link

Matiiss commented Dec 26, 2024

I am aware that this is a documented quirk:

On Linux, our distributions are built in containers. The container has a custom build of Clang in a custom filesystem location. And Python is installed to the prefix /install. So you may see references to /install in Linux distributions.

- https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html#references-to-build-time-paths

Nonetheless, I was asked to open this issue as it seems it might get resolved for once 🥳

I was trying to compile a C extension using meson and it kept throwing an error that it couldn't find Python.h for the specified Python version and upon closer inspection it looked like it was not including the correct directory because the directory it was attempting to include started with /install which is not a path on my machine, so I went to the file mentioned in the title and found that it contains this (the <minor> was actually the version I had, in this case 3.12):

# See: man pkg-config
prefix=/install
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Python
Description: Build a C extension for Python
Requires:
Version: 3.<minor>
Libs.private: -lpthread -ldl  -lutil
Libs: -L${libdir} 
Cflags: -I${includedir}/python3.<minor>

So the prefix=/install was unexpected, what I would have expected would have been (in my particular case)

prefix=/home/matiiss/.local/share/uv/python/cpython-3.12.8-linux-x86_64-gnu

After editing the file manually and trying to run meson again, it worked.

@Matiiss Matiiss changed the title Unexpected prefix in .../lib/pkgconfig/python-3.<minor>.pc Unexpected prefix value in .../lib/pkgconfig/python-3.<minor>.pc Dec 26, 2024
@charliermarsh
Copy link
Member

I think we need to solve this in uv by patching pkgconfig, like we do with sysconfig, so I'm gonna transfer to the uv repo.

@charliermarsh charliermarsh self-assigned this Dec 26, 2024
@charliermarsh charliermarsh transferred this issue from astral-sh/python-build-standalone Dec 26, 2024
@charliermarsh charliermarsh added bug Something isn't working compatibility Compatibility with a specification or another tool labels Dec 26, 2024
charliermarsh added a commit that referenced this issue Dec 27, 2024
## Summary

Closes #10185.

## Test Plan

Ran `cargo run python install 3.10.15 --reinstall`; verified that
`python3.pc` contained:

```
# See: man pkg-config
prefix=/Users/crmarsh/.local/share/uv/python/cpython-3.10.15-macos-aarch64-none
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Python
Description: Build a C extension for Python
Requires:
Version: 3.10
Libs.private: -ldl   -framework CoreFoundation
Libs:
Cflags: -I${includedir}/python3.10
```
@neutrinoceros
Copy link

I'm encountering a very similar, possibly same, issue with uv 0.5.14

setup:

$ git clone https://github.com/numpy/numpy
$ cd numpy
$ git submodule update --init

then

$ uv build
Building source distribution...
+ /Users/clm/.cache/uv/builds-v0/.tmpcUq9Nd/bin/python /private/tmp/numpy/vendored-meson/meson/meson.py setup /private/tmp/numpy /private/tmp/numpy/.mesonpy-xqqxtm9n -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/private/tmp/numpy/.mesonpy-xqqxtm9n/meson-python-native-file.ini
The Meson build system
Version: 1.5.2
Source dir: /private/tmp/numpy
Build dir: /private/tmp/numpy/.mesonpy-xqqxtm9n
Build type: native build
Project name: NumPy
Project version: 2.3.0.dev0+git20241226.a07c6c5
C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
C linker for the host machine: cc ld64 1115.7.3
C++ compiler for the host machine: c++ (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.6)")
C++ linker for the host machine: c++ ld64 1115.7.3
Cython compiler for the host machine: cython (cython 3.0.11)
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program python found: YES (/Users/clm/.cache/uv/builds-v0/.tmpcUq9Nd/bin/python)
Found pkg-config: YES (/opt/homebrew/bin/pkg-config) 2.3.0
Run-time dependency python found: YES 3.13
Has header "Python.h" with dependency python-3.13: NO

../meson.build:44:2: ERROR: Problem encountered: Cannot compile `Python.h`. Perhaps you need to install python-dev|python-devel

A full log can be found at /private/tmp/numpy/.mesonpy-xqqxtm9n/meson-logs/meson-log.txt
  × Failed to build `/private/tmp/numpy`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `mesonpy.build_sdist` failed (exit status: 1)
      hint: This usually indicates a problem with the package or the build environment.

I made sure to reinstall Python 3.13 after I upgraded uv to 0.5.14.

I already had this issue with earlier versions of uv but didn't have time to report it at the time. I found this issue from uv 0.5.14's release notes.

@neutrinoceros
Copy link

I opened a separate issue at #10558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Compatibility with a specification or another tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants