-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix runtime conflict between embedded and system Python #37
Conversation
`embedded_python-core` already provides the include dirs and non-core inherits it. There's no reason for non-core to add them again.
We didn't catch this on CI since we only test lowest and highest supported versions. I don't think I'd change this CI setup just for this, but maybe reconsider in the future if such a case happens again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a list of packages (or is there a way to determine) which fail to build in isolated mode?
It's impossible to tell. It's any package from pypi.org that has a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛩️
The issue was that our embedded Python could pick up extra Python packages installed in the user's home directory. Python adds user paths by default unless instructed otherwise. The `._pth` file puts it into isolated mode. See the docstrings of `_isolate()` for all the details.
d50ffd2
to
bb0c9bb
Compare
This PR primarily fixes an issue where the embedded
python(3)
executable could still pick up some paths from the system Python which resulted in obscure, hard-to-debug issues. It's important to keep in mind that there are two ways to run the embedded Python:python(3)
executable in the embedded package.Case 1 is how we mainly use it and it wasn't really an issue because we already enabled isolated mode at initialization time using the Python C API.
Case 2 is something we do at build time to run some utilities (e.g. convert Jupytext to
. ipynb
files) or at runtime (launch Jupyter notebooks in a standalone process). When calling thepython(3)
exe directly, isolated mode can be set either via the-I
command line parameter or by adding a._pth
file next to the executable. It's easy to forget or not know to always add-I
so it's best for the embedded package itself to have a._pth
file to avoid issues. See the docstrings for more details.This PR also fixes #36 and a few other smaller bugs. See the individual commit messages. Thanks to @hrishikeshkelkar for finding both the bug and what causes it.