Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve PEX_ env variables after calling pex #180

Closed
digwanderlust opened this issue Nov 14, 2015 · 2 comments · Fixed by #932
Closed

Preserve PEX_ env variables after calling pex #180

digwanderlust opened this issue Nov 14, 2015 · 2 comments · Fixed by #932
Assignees
Labels

Comments

@digwanderlust
Copy link
Contributor

https://github.com/pantsbuild/pex/blob/master/pex/pex.py#L48

Currently we delete all env variables from os.environ that start with PEX_. If pex is called from another process as a library this will override the parent scripts env variables. If the env variables are reset back to their original state at the end of execution the behavior would be less confusing when using pex as a library.

For example in pants if we try to override the PEX_ROOT every time we call pex to build a target PEX_ROOT is reset.

@jsirois
Copy link
Member

jsirois commented Nov 14, 2015

If you haven't kibbutzed with @baroquebobcat you might want to.

@jsirois
Copy link
Member

jsirois commented Mar 24, 2020

This is actually a bug. The Pex.clean_environment helper directly mutates os.environ. This is OK for Pex._execute which is expected to be the last invocation in the current interpreter but it is not OK for Pex.run.

This was referenced Mar 24, 2020
jsirois added a commit to jsirois/pex that referenced this issue Mar 24, 2020
Previously, `PEX_*` environment variable stripping incorrectly stripped
`PEX_*` environment variables in host process when the `PEX.run` API was
used. This is fixed and an option to not strip pex environment variables
at all is added to `PexInfo` / the Pex CLI. This new option is used to
publish a Pex PEX that supports control via environment variables.

Fixes pex-tool#180
Fixes pex-tool#925
Work towards pex-tool#926
jsirois added a commit that referenced this issue Mar 24, 2020
* Fix `PEX_*` env stripping and allow turning off.

Previously, `PEX_*` environment variable stripping incorrectly stripped
`PEX_*` environment variables in host process when the `PEX.run` API was
used. This is fixed and an option to not strip pex environment variables
at all is added to `PexInfo` / the Pex CLI. This new option is used to
publish a Pex PEX that supports control via environment variables.

Fixes #180
Fixes #925
Work towards #926

* Fix Python versionisms.

* Explain --no-strip-pex-env more.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants