未验证 提交 6eec5499 编写于 作者: F Frost Ming

Cleanup the code

上级 57f4ca5d
......@@ -35,8 +35,7 @@ from pdm.utils import (
find_project_root,
find_python_in_path,
get_in_project_venv_python,
is_conda_python,
is_venv_python,
get_venv_like_prefix,
)
if TYPE_CHECKING:
......@@ -206,10 +205,7 @@ class Project:
# compatible with the exact version
env.python_requires = PySpecSet(f"=={self.python.version}")
return env
if self.config["use_venv"] and (
is_venv_python(self.python.executable)
or is_conda_python(self.python.executable)
):
if self.config["use_venv"] and get_venv_like_prefix(self.python.executable):
# Only recognize venv created by python -m venv and virtualenv>20
return GlobalEnvironment(self)
return Environment(self)
......
......@@ -445,12 +445,6 @@ def is_venv_python(interpreter: str | Path) -> bool:
return bool(virtual_env and is_path_relative_to(interpreter, virtual_env))
def is_conda_python(interpreter: str | Path) -> bool:
"""Check if the given interpreter path is from a Conda environment"""
virtual_env = os.getenv("CONDA_PREFIX")
return bool(virtual_env and is_path_relative_to(Path(interpreter), virtual_env))
def get_venv_like_prefix(interpreter: str | Path) -> Path | None:
"""Check if the given interpreter path is from a virtualenv,
and return the prefix if found.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册