mesonbuild / mesonbuild/meson-python

mesonpy embeds random path into .o files for debug build

Open
#671 31 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Python
Stars
180
Forks
93
Avg merge
2d 7h
Merged PRs (30d)
18

Description

While working on [reproducible builds](https://reproducible-builds.org/) for [openSUSE](https://en.opensuse.org/openSUSE:Reproducible_Builds) (sponsored by the NLnet NGI0 fund), I found that various python packages (python-pandas, python-scikit-learn, python-scipy, python-contourpy, python-gobject) have variations in every build.

I am pretty certain this comes from
https://github.com/mesonbuild/meson-python/blob/04e00668ae869ab42579cc5bfa8264d0475e83fc/mesonpy/__init__.py#L965
but don't know how to best make this deterministic.

Is there a variant of `tempfile.TemporaryDirectory` that does not add randomness? I tried with `pathlib.Path(os.path.join(source_dir, '.mesonpy'))` but that lacks the automatic cleanup.

Here is a typical diff:
```diff
--- old /usr/lib/debug/.dwz/python-pandas-2.2.2-1.1.x86_64 (objdump)
+++ new /usr/lib/debug/.dwz/python-pandas-2.2.2-1.1.x86_64 (objdump)
@@ -14923,7 +14923,7 @@
0010 01010101 081e3c64 777a3e00 2f757372 ......./usr
0020 2f737263 2f646562 75672f70 616e6461 /src/debug/panda
0030 732d322e 322e322f 2e6d6573 6f6e7079 s-2.2.2/.mesonpy
- 0040 2d6e7777 6b673134 74002f75 73722f6c -nwwkg14t./usr/l
+ 0040 2d73615f 6761376e 33002f75 73722f6c -sa_ga7n3./usr/l
0050 69623634 2f676363 2f783836 5f36342d ib64/gcc/x86_64-
0060 73757365 2d6c696e 75782f31 342f696e suse-linux/14/in
0070 636c7564 65002f75 73722f69 6e636c75 clude./usr/inclu
@@ -14965,7 +14965,7 @@
02b0 2f6e756d 70792f64 61746574 696d6500 /numpy/datetime.
02c0 2f757372 2f737263 2f646562 75672f70 /usr/src/debug/p
02d0 616e6461 732d322e 322e322f 2e6d6573 andas-2.2.2/.mes
- 02e0 6f6e7079 2d757868 63736133 66002f75 onpy-uxhcsa3f./u
+ 02e0 6f6e7079 2d713166 36397136 61002f75 onpy-q1f69q6a./u
02f0 73722f69 6e636c75 64652f70 7974686f sr/include/pytho
0300 6e332e31 31002f75 73722f69 6e636c75 n3.11./usr/inclu
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Read mesonpy/__init__.py around line 965 and inspect how TemporaryDirectory contributes its random name to compiler paths. Compare that behavior with the suggested pathlib.Path(os.path.join(source_dir, '.mesonpy')) approach and determine how deterministic paths can retain automatic cleanup. Done means repeated builds no longer embed varying .mesonpy paths in debug object files.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.