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

Honor PEX_IGNORE_RCFILES in to_python_interpreter() #673

Merged
merged 2 commits into from Feb 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions pex/bin/pex.py
Expand Up @@ -519,8 +519,11 @@ def to_python_interpreter(full_path_or_basename):
# affect usages of the interpreter(s) specified by the "--python" command line flag.
constraints = options.interpreter_constraint
validate_constraints(constraints)
rc_variables = Variables.from_rc(rc=options.rc_file)
pex_python_path = rc_variables.get('PEX_PYTHON_PATH', '')
if options.rc_file or not ENV.PEX_IGNORE_RCFILES:
rc_variables = Variables.from_rc(rc=options.rc_file)
Copy link
Member

Choose a reason for hiding this comment

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

The options.rc_file value is None by default. To be non-None pex had to be invoked from the cli with --rcfile=[path]. As such you're setting the precedent rule here of env beats flags. That does not seem kosher. Is that what you're intending here or have I read things wrong?

Copy link
Member

@jsirois jsirois Feb 15, 2019

Choose a reason for hiding this comment

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

Honestly, the flag really makes no sense. It shouldn't exist at all fwict. I'd be fine with considering this not your problem. I've filed #674

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if the option is None, Variable.from_rc will try to load stuff from well-known files (i.e. /etc/pexrc, ~/.pexrc...), which leaves us with no way of specifying here "I actually want you to ignore all pexrc files".

Copy link
Member

Choose a reason for hiding this comment

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

Well, the condition could be if options.rc_file or not ENV.PEX_IGNORE_RCFILES.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I'd still like a way of expressing "Please do not try to load pexrc files", so would you be okay with something like "If the flag is None, and the env variable PEX_IGNORE_RCFILES is set, please do not load any pexrc file? That would create slightly inconsistent semantics for the env variable, until the flag is removed.

Copy link
Member

Choose a reason for hiding this comment

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

Yes. I think we're saying the same thing. SGTM.

pex_python_path = rc_variables.get('PEX_PYTHON_PATH', '')
else:
pex_python_path = ""
interpreters = find_compatible_interpreters(pex_python_path, constraints)

if not interpreters:
Expand Down