Skip to content

feat: Remove dependency from /bin/python3 - #351

Closed
furtib wants to merge 2 commits into
Ericsson:mainfrom
furtib:python-toolchain-for-execution
Closed

furtib wants to merge 2 commits into
Ericsson:mainfrom
furtib:python-toolchain-for-execution

Conversation

@furtib

@furtib furtib commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Why:
We want a hermetic rule.
In PR #308 I noticed that removing /bin causes the tool to fail, saying that /usr/bin/env python3 cannot be found. For this reason, we need to add not only dirname but also the hermetic python interpreter to the PATH.

What:

  • Added python toolchain as a dependency to every rule.
  • Added python toolchain to the PATH of every rule.

Addresses:
#362

Depends on: #363

@furtib
furtib requested a review from Szelethus October 12, 2026 15:41
@furtib furtib self-assigned this Oct 12, 2026
@furtib furtib added the enhancement New feature or request label Oct 12, 2026
Comment thread src/per_file.bzl Outdated
py_interpreter_dir = py_toolchain.py3_runtime.interpreter.dirname

# TODO: remove /bin when dirname is available hermetically
env["PATH"] = (env.get("PATH", "") + ":" + py_interpreter_dir + ":/bin").lstrip(":")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does not look good :(

@furtib furtib Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will make it match the monolithic version.
It just occurred to me that if users specify PATH, the Python interpreter will be booted from the path of the monolithic one.

@furtib
furtib force-pushed the python-toolchain-for-execution branch 3 times, most recently from 1fa2205 to ea835b9 Compare October 20, 2026 16:30
@furtib
furtib force-pushed the python-toolchain-for-execution branch 3 times, most recently from ddd3db1 to 12645dd Compare October 20, 2026 17:01
@furtib

furtib commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

I tried to make this PR as neat as possible.
To make things easily reviewable, I split it into two (#363).
Only the last commit is this PR.

@furtib
furtib requested a review from nettle October 20, 2026 17:16
@furtib
furtib force-pushed the python-toolchain-for-execution branch from 12645dd to 4de5dbf Compare October 20, 2026 17:16

@nettle nettle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should agree on wanted position for this problem.
As I can see this changes just trying to use python3 from the toolchain for CodeChecker which in turn might be incompatible. CodeChecker has in fact more dependencies.

@furtib

furtib commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Oh, right, what if the python version of the codechecker installation and the one provided by rules_python differ........
So, as long as we accept Python to be supplied from outside (so not a solution like #293) we must also get the Python interpreter from outside (from PATH).
I should have thought of that...
Well great :/

@furtib furtib closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants