python / python/cpython

Building against libuuid without pkgconfig fails if OSSP uuid is installed

オープン
#147,977 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

build extension-modules type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

When building Python on a system where:

  • libuuid is installed without pkgconfig
  • OSSP uuid is installed (uuid-devel on RHEL/Rocky/Alma)
  • OSSP uuid's uuid.h is installed as /usr/include/uuid.h (the case on RHEL/Rocky/Alma)

the build fails with the following error:

./Modules/_uuidmodule.c: In function ‘py_uuid_generate_time_safe’:
./Modules/_uuidmodule.c:31:12: error: storage size of ‘uuid’ isn’t known
   31 |     uuid_t uuid;
      |            ^~~~
./Modules/_uuidmodule.c:35:11: error: implicit declaration of function ‘uuid_generate_time_safe’; did you mean ‘py_uuid_generate_time_safe’? [-Werror=implicit-function-declaration]
   35 |     res = uuid_generate_time_safe(uuid);
      |           ^~~~~~~~~~~~~~~~~~~~~~~
      |           py_uuid_generate_time_safe

This is because on such a system, both HAVE_UUID_H and HAVE_UUID_UUID_H become set:

$ grep 'HAVE_UUID.*_H' pyconfig.h
#define HAVE_UUID_H 1
#define HAVE_UUID_UUID_H 1

-I/usr/include/uuid does not get added to CFLAGS:

$ grep ^MODULE__UUID_CFLAGS Makefile
MODULE__UUID_CFLAGS=

and Modules/_uuidmodule.c currently checks HAVE_UUID_H before HAVE_UUID_UUID_H:

#if defined(HAVE_UUID_H)
  // AIX, FreeBSD, libuuid with pkgconf
  #include <uuid.h>
#elif defined(HAVE_UUID_UUID_H)
  // libuuid without pkgconf
  #include <uuid/uuid.h>
#endif

This causes the wrong uuid.h to be included.

The order in which HAVE_UUID_H and HAVE_UUID_UUID_H are checked was inverted in commit 8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f, but neither the commit itself or the related issue documents why the order was changed.

Building Python on a system with the properties described in this issue did work as expected in Python 3.10 (3.11 was the first release to include the reordering mentioned above).

Reproducer

docker run --rm -it almalinux:9

dnf install -y 'dnf-command(builddep)'
dnf --enablerepo=crb builddep -y python3
dnf --enablerepo=crb install -y uuid-devel

rm -f /usr/lib64/pkgconfig/uuid.pc

curl -O https://www.python.org/ftp/python/3.14.3/Python-3.14.3.tgz
tar -xf Python-3.14.3.tgz
cd Python-3.14.3

./configure
make -j$(nproc)
CPython versions tested on:

3.14

Operating systems tested on:

Linux

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Modules/_uuidmodule.c から始め、configure が pyconfig.h と Makefile で HAVE_UUID_H、HAVE_UUID_UUID_H、MODULE__UUID_CFLAGS をどのように生成するかを調べてください。Issue に記載されたコマンドを使用して AlmaLinux 9 で失敗を再現し、その後、pkgconfig なしで OSSP uuid をインストールした状態でビルドが成功し、意図した libuuid ヘッダーがインクルードされることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
build-system
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
70/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。