Skip to content

sbang.py: use os.uname and branch on kernel version#52373

Open
haampie wants to merge 2 commits intodevelopfrom
hs/fix/sbang-length
Open

sbang.py: use os.uname and branch on kernel version#52373
haampie wants to merge 2 commits intodevelopfrom
hs/fix/sbang-length

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented May 5, 2026

Remove Linux headers as a dependency of Spack.

The value has changed exactly only once in git history, and seems non-configurable.

haampie added 2 commits May 5, 2026 21:57
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Comment on lines +25 to +26
major, minor = (int(x) for x in release.split(".")[:2])
system_shebang_limit = 255 if (major, minor) >= (5, 1) else 127
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why risk IndexError when you don't have to?

Suggested change
major, minor = (int(x) for x in release.split(".")[:2])
system_shebang_limit = 255 if (major, minor) >= (5, 1) else 127
version_tuple = tuple(int(x) for x in release.split("."))
system_shebang_limit = 255 if version_tuple >= (5, 1) else 127

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slicing doesn't have that issue:

>>> [][:2]
[]

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented May 5, 2026

@finkandreas @tvoskui @AndresYague @jonasjucker does this still work for you? This is a simpler approach than #43290 and will work regardless of whether kernel headers are installed.

@tvoskui
Copy link
Copy Markdown

tvoskui commented May 5, 2026

@finkandreas @tvoskui @AndresYague @jonasjucker does this still work for you? This is a simpler approach than #43290 and will work regardless of whether kernel headers are installed.

I just tried this out and I get inconsistent results. 4.18 would put it at the lower limit, but the header is at 256

>>> import os
>>> os.uname().release
'4.18.0-553.115.1.el8_10.x86_64'

$ cat /usr/include/linux/binfmts.h | grep BINPRM_BUF_SIZE 
#define BINPRM_BUF_SIZE 256

Also, the proposed code fails on that release string too

>>> release = os.uname().release
>>> version_tuple = tuple(int(x) for x in release.split("."))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
ValueError: invalid literal for int() with base 10: '0-553'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants