Reimplement the pants_bin_name functionality in Rust. #21872
Merged
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 feature allows users to set a custom binary name
for use in help messages and documentation. So that
if their org has a custom wrapper script or binary,
we can direct users to use that.
Reimplementing this in Rust allows us to further
simplify OptionsBootstrapper.
Note that the old implementation relied on setting
an env var on the current process by manipulating
os.environ
. This served two purposes:since the latter inherits the environment of the former.
( 2) is important because pantsd uses bin_name() at
import time, and options (including the pants_bin_name
option) may not be available yet. )
But - setting an environment variable on the current
process is not thread-safe on POSIX, and there is no
way to make it so. Therefore we change the implementation
to use a static Mutex for 1), and an explicit pass-through
of that value when spawning pantsd for 2).