venv with system-site-packages enabled invokes console scripts in the parent version context
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
调研方向
Start by reproducing the reported commands with pyenv virtualenv and inspect the venv creation and console-script path handling in pyenv-virtualenv. Compare pyenv which pyright, direct console-script execution, and python -m pyright; done means a parent-installed console script runs under the current virtual environment and can import packages installed there.
由索引模型根据 Issue 内容生成。
描述
When a pyenv virtualenv is created with system-site-packages enabled, console scripts installed in the parent pyenv version are invoked using the parent's environment, not the current virtual environment, and cannot load packages installed in the virtualenv.
Reproduction:
Create a venv from a parent version that has packages with console scripts. Here, package pyright has a console script.
> pyenv virtualenv --system-site-packages 3.10.5 foo
> pyenv shell foo
foo > pyenv which pyright
/Users/tmiller/.pyenv/versions/3.10.5/bin/pyright
We pip install a package into the venv.
foo > pip install kopf
Looking in indexes: https://artifacts.mitre.org/artifactory/api/pypi/python/simple
Collecting kopf
Downloading https://artifacts.mitre.org/artifactory/api/pypi/python/packages/packages/80/eb/e82f3e249db2ecd06aeb42eb4209ea295a00a98b9277bff13901e99ddeda/kopf-1.35.6-py3-none-any.whl (205 kB)
[...]
When invoked, pyright parses code and imports, but can't find the package in the venv.
foo > pyright ~/projects/foo
No configuration file found.
No pyproject.toml file found.
stubPath /Users/tmiller/typings is not a valid directory.
Assuming Python platform Darwin
Searching for source files
Found 1 source file
pyright 1.1.269
/Users/tmiller/projects/foo/bar.py
/Users/tmiller/projects/foo/bar.py:3:8 - error: Import "kopf" could not be resolved (reportMissingImports)
1 error, 0 warnings, 0 informations
Completed in 0.596sec
When the console script is invoked as a module entry point, the import is resolved because python is executed in the venv.
foo > python -m pyright ~/projects/foo/
No configuration file found.
No pyproject.toml file found.
stubPath /Users/tmiller/typings is not a valid directory.
Assuming Python platform Darwin
Searching for source files
Found 1 source file
pyright 1.1.269
/Users/tmiller/projects/foo/bar.py
/Users/tmiller/projects/foo/bar.py:6:2 - error: Argument of type "(namespace: Unknown, name: Unknown, resource: Unknown, **_: Unknown) -> dict[tuple[Unknown, Unknown], Unknown]" cannot be assigned to parameter of type "IndexingFn"
Type "(namespace: Unknown, name: Unknown, resource: Unknown, **_: Unknown) -> dict[tuple[Unknown, Unknown], Unknown]" cannot be assigned to type "IndexingFn"
Function accepts too many positional parameters; expected 3 but received 15 (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
Completed in 0.82sec
Prerequisite
- Make sure your problem is not listed in the common build problems.
- Make sure no duplicated issue has already been reported in the pyenv-virtualenv issues. You should look in closed issues, too.
There are a couple of close issues, but nothing really seemed to match.
- Make sure you are not asking us to help solving your specific issue.
- Make sure your problem is not derived from packaging (e.g. Homebrew).
- Make sure your problem is not derived from other plugins.
Description
- Platform information (e.g. Ubuntu Linux 20.04):
- OS architecture (e.g. amd64):
Darwin yadda 20.6.0 Darwin Kernel Version 20.6.0: Tue Jun 21 20:50:28 PDT 2022; root:xnu-7195.141.32~1/RELEASE_X86_64 x86_64
- pyenv version:
pyenv 2.3.1-20-g572a8bcf
- pyenv-virtualenv version:
pyenv-virtualenv 1.1.5 (python -m venv)
- Python version:
All.
- virtualenv version (if installed):
N/A
- Please attach the debug log of a faulty Pyenv invocation as a gist
https://gist.github.com/Cerebus/bf0a32edd99d6d8c00a29401628771f8
- 主要语言
- Shell
- 星标
- 6.7k
- 派生
- 433
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 11
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pyenv/pyenv-virtualenv 的其他 Issue
-
Document the virtualenv, activate and deactivate hooks可能已有人在做 @officialasishkumar 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
pyenv/pyenv-virtualenv#552 ·
维护者通常 1 天内回复
-
Creating a virtualenv from system leaves a self-referencing symlink inside it可能已有人在做 @dhananjay6561 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
pyenv/pyenv-virtualenv#548 · 1 条评论 ·
维护者通常 1 天内回复
-
virtualenv-delete with a trailing slash can remove all of $PYENV_ROOT/versions可能已有人在做 @dhananjay6561 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
pyenv/pyenv-virtualenv#546 · 1 条评论 ·
维护者通常 1 天内回复
-
Fish: activating a conda env doesn't set CONDA_PREFIX or run its activate.d/deactivate.d scripts可能已有人在做 @officialasishkumar 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 76/100
pyenv/pyenv-virtualenv#550 ·
维护者通常 1 天内回复
-
`pyenv virtualenv (version) (name)` ignores specified version and uses homebrew's `python` version未关闭
难度 3/5 半天 新手友好度 55/100
pyenv/pyenv-virtualenv#531 ·
维护者通常 1 天内回复
查看 pyenv/pyenv-virtualenv 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
Abdk4Moura/tunlion#1014 ·
维护者通常 1 天内回复
-
icon request
难度 1/5 1 小时以内 新手友好度 85/100
PapirusDevelopmentTeam/papirus-icon-theme#4401 ·
维护者通常 3 天内回复
-
package-update
难度 1/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复