You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker and believe that this is not a duplicate.
This issue is similar to #685
But in that bug report, users were not installing pdm in an isolated way.
However, even installing pdm in a recommended, isolated way, there still seems to be a conflict with enabling PEP 582 globally.
Steps to reproduce
You need to have an older version of resolvelib inside your project's local __pypackages__ directory. This example project that will install resolvelib 0.5.5.. older than pdm's minimum of 0.8.
You can install PDM using a recommended way like Homebrew.
Then you can follow the section right after to Enable PEP 582 globally.
Actual behavior
The first run of pdm install -v will work correctly.
Subsequent runs of pdm install -v will end up using the older resolvelib in the project's __pypackages__ now, instead of falling back to the one that Homebrew put in pdm's isolated venv directory.
There will be various API argument errors printed to console.
Expected behavior
pdm install should ideally work even if a project uses an older resolvelib and the user would also like PEP 582 enabled globally. It is not intuitive that the pdm CLI, depending directly on Python itself, would be affected by global PEP 582 even for its own dependencies. It makes the tool a bit fragile, given that enabling global PEP 582 is, I think, one of its main purposes.
Perhaps we could find an alternative way for pdm CLI to exist alongside global PEP 582, but without the current side effects?
Again, thanks for working on the tool!
(A workaround for pdm to work on this project is to not enable PEP 582 globally, by unsetting PYTHONPATH while running pdm, and setting it again afterward.)
I am afraid this has no graceful solution. Not only for PDM itself, enabling PEP 582 can make global tools work with local packages, and there might be conflicting dependencies. If we are to disable PEP 582, this feature is also disabled.
So it seems with PEP 582 enabled, running any external Python script, whether it uses venv or not, can be affected by the local __pypackages__ directory overriding the intended packages.
I read PEP 582 to see if it discusses this scenario. It actually does, but only in the case where the external script was also using PEP 582 as well:
"While executing a Python script, it will not consider the __pypackages__ in the current directory, instead if there is a __pypackages__ directory in the same path of the script, that will be used."
This seems to suggest that if the official installation / invocation approaches of PDM were changed to use PEP 582, instead of venv, that PDM would then be protected from other PEP 582 projects!
Although this does not globally solve the __pypackages__ "hijacking" issue, since many other common external Python scripts will likely not be using PEP 582.. it would at least protect PDM.
This issue is similar to #685
But in that bug report, users were not installing pdm in an isolated way.
However, even installing pdm in a recommended, isolated way, there still seems to be a conflict with enabling PEP 582 globally.
Steps to reproduce
You need to have an older version of resolvelib inside your project's local
__pypackages__
directory. This example project that will install resolvelib 0.5.5.. older than pdm's minimum of 0.8.You can install PDM using a recommended way like Homebrew.
Then you can follow the section right after to Enable PEP 582 globally.
Actual behavior
The first run of
pdm install -v
will work correctly.Subsequent runs of
pdm install -v
will end up using the older resolvelib in the project's__pypackages__
now, instead of falling back to the one that Homebrew put in pdm's isolated venv directory.There will be various API argument errors printed to console.
Expected behavior
pdm install
should ideally work even if a project uses an older resolvelib and the user would also like PEP 582 enabled globally. It is not intuitive that the pdm CLI, depending directly on Python itself, would be affected by global PEP 582 even for its own dependencies. It makes the tool a bit fragile, given that enabling global PEP 582 is, I think, one of its main purposes.Perhaps we could find an alternative way for pdm CLI to exist alongside global PEP 582, but without the current side effects?
Again, thanks for working on the tool!
(A workaround for pdm to work on this project is to not enable PEP 582 globally, by unsetting PYTHONPATH while running pdm, and setting it again afterward.)
Environment Information
The text was updated successfully, but these errors were encountered: