-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add root path to sys.path in build env for embedded Python #11724
base: main
Are you sure you want to change the base?
Conversation
This looks like an issue in the embedded distribution? pip simply uses the sysconfig layout to reference the modules, and if a distribution fails to report the site locations, it’s on the distribution to fix that. |
import pyexpat | ||
if os.path.dirname(pyexpat.__file__) == os.path.dirname(sys.executable): |
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.
Is there any other way to detect embedded Python?
Yes, it only affects embedded distribution. |
In addition to the point @uranusjr made that this is an issue for the embedded distribution, I will note that the embedded distribution is explicitly documented as not being for general use - see the comment here
So this is not intended or supported use anyway, and IMO pip should not try to special case it. |
Fix #11670, related issue: python/cpython#100399, Azure/azure-cli#24781
In embedded python, the pyd files are put in root folder.
In standard python, they are put into DLLs folder.
In
build_env.py
, the root folder is excluded by this logic, as root folder is insystem_paths
/system_sites
.pip/src/pip/_internal/build_env.py
Lines 122 to 126 in 07a360d
If these pyd files need to be imported when install new package,
ModuleNotFoundError
is raised.Currently, I find
pwinput
andpendulum
can't be installed in embedded Python.I'm not sure whether this change brings some side effect. Let me know if you have any concern.
Repro step
ModuleNotFoundError: No module named 'pyexpat'
raisesIt can be installed successfully with this PR.