-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
pdm run python
then import package
return system packages if not installed with pdm
#708
Comments
The correct way to do this is |
Oh, I get this error: $ pdm list --freeze -v
Traceback (most recent call last):
File "/home/user/.local/bin/pdm", line 8, in <module>
sys.exit(main())
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/core.py", line 200, in main
return Core().main(args)
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/core.py", line 153, in main
raise cast(Exception, err).with_traceback(traceback)
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/core.py", line 148, in main
f(options.project, options)
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/cli/commands/list.py", line 31, in handle
actions.do_list(
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/cli/actions.py", line 404, in do_list
reqs = [
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/cli/actions.py", line 405, in <listcomp>
frozen_requirement_from_dist(dist)
File "/home/user/.local/pipx/venvs/pdm/lib/python3.8/site-packages/pdm/cli/utils.py", line 608, in frozen_requirement_from_dist
return str(FrozenRequirement.from_dist(pkg_dist))
File "/home/user/.local/pipx/shared/lib/python3.6/site-packages/pip/_internal/operations/freeze.py", line 235, in from_dist
editable = dist.editable
File "/home/user/.local/pipx/shared/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2816, in __getattr__
return getattr(self._provider, attr)
AttributeError: 'PathMetadata' object has no attribute 'editable'
|
$> pdm run python
>>> import black
>>> This will import my system black and not raise a Maybe it's the desired behavior but I wanted to log it here |
pdm run pip freeze
return system (but __pypackage__ overwritten) packagespdm run python
then import package
return system packages if not installed with pdm
I believe that is the normal behavior. PDM adds the Note that you could run
Another note: I usually install tools like Black with pipx instead of pip, so as to not pollute my interpreter site-packages directory. |
let's make an enhancement item: allow disabling the system site-packages with an env var and turn it on for |
Thanks @pawamoy for explanations ! @frostming Maybe it's my "old way usage" of pip with venv that make me feel that weird, if there is no normal usage of that, we don't need to make a new feature of this. Maybe we can make this issue well referenced and wait for more community inputs before make you wasting your time ? |
No, I think we can disable system site-packages in Because by including system site-packages, global tools like ipython and other Python utilities won't suddenly break when the current directory has a |
I wouldn't mind actual isolation for the Yup. Totally agree with your last two sentences. |
Steps to reproduce
Actual behavior
$> pdm run pip freeze black==21.9b0 typer==0.4.0
Expected behavior
$> pdm run pip freeze typer==0.4.0
The
pdm run
command should launch the command in apdm
isolated environment but it's more like a "system overloaded" environment. Is this a voluntary behavior ?It makes more difficult to be sure than
pdm.lock
file is complete if system had some package than the project need.In this case, if a script did a
import black
and I run it withpdm run my_script.py
it will not raise aModuleNotFoundError
, so I can't know I'm missing theblack
package in my lock file and the install will fail in a clean environment without the systemblack
package already installed.Environment Information
The text was updated successfully, but these errors were encountered: