未验证 提交 7b0c9995 编写于 作者: F Frost Ming

fix: respect requires-python when creating default venv

Close #1237
上级 8be6993c
Respect `requires-python` when creating the default venv.
......@@ -29,11 +29,16 @@ class Backend(abc.ABC):
saved_python = self.project.project_config.get("python.path")
if saved_python:
return PythonInfo.from_path(saved_python)
try: # pragma: no cover
return next(iter(self.project.find_interpreters(self.python)))
except StopIteration: # pragma: no cover
python = f" {self.python}" if self.python else ""
raise VirtualenvCreateError(f"Can't resolve python interpreter{python}")
for py_version in self.project.find_interpreters(self.python):
if (
self.python
or py_version.valid
and self.project.python_requires.contains(py_version.version, True)
):
return py_version
python = f" {self.python}" if self.python else ""
raise VirtualenvCreateError(f"Can't resolve python interpreter{python}")
@property
def ident(self) -> str:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册