[py] Initialize site, and use PYTHONHOME#390
Merged
Conversation
* Allow python to automatically initialize `site` when we initialize the interpreter (see https://docs.python.org/2/library/site.html). This makes python build its own default `PYTHONPATH` from the `PYTHONHOME`, so that it can load modules (built-ins, `site-packages` modules, etc). * Instead of setting `PYTHONPATH` (since we let python build that on its own), set `PYTHONHOME`. That'll pick up the embedded python, the rest will be handled by python.
Contributor
|
cc @derekwbrown this should address your issue |
masci
approved these changes
Jul 19, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
sitewhen we initializethe interpreter (see https://docs.python.org/2/library/site.html).
This makes python build its own default
PYTHONPATHfrom thePYTHONHOME(so that it can load all the modules: built-ins,site-packagesmodules, etc).PYTHONPATH(since we let python build that onits own), sets
PYTHONHOME. That'll set up the embedded python's home, andthe rest will be handled by python.
See https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHOME:
Motivation
Disabling site initialization is error-prone. In my case, the installed
supervisormodule couldn't be imported because without site initialization, python doesn't
take into account the
.pthfiles in itssite-packagesdirectory (and thesupervisormodule relies on such a file).
Instead, let's enable the default behavior and let the interpreter do everything.
Additional Notes
This changes the site initialization behavior that was introduced in #15.
Also, sneaked in the addition of a log line that helped me for troubleshooting
(not directly related to the PYTHONPATH change though)