build: Add python shebang to elf scripts #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request attempts to fix the following build failure on Gentoo Linux:
I followed the build instructions except that I installed
pyelftoolswith the Gentoo Linux package manager instead ofpip.I tracked it down to how Gentoo Linux handles Python. Multiple versions of Python can be installed, with one being set as active (currently 3.12). Most Python packages can also be built for multiple Python versions simultaneously.
The build fails because
pyelftoolsis only built for Python 3.12, but my system also has Python 3.13 installed. CMake assumes Python 3.13 is the active version and sets${Python_EXECUTABLE}to/usr/bin/python3.13.There is a way to tell the Gentoo Linux package manager to build
pyelftoolsfor every available Python version, but that requires the entirepyelftoolsdependency tree to be built for every available Python version. This becomes very messy and makes Python upgrades prone to failing.My solution is to add a Python shebang to the elf scripts, which should always find the active Python version. This requires that the elf scripts are made executable (
scripts/calculate_usage.pyalready is) and the removal${Python_EXECUTABLE}fromCMakeLists.txt.Please note that I'm a novice with Python and CMake so there could be some unforeseen issues. This change was only tested on Gentoo Linux.