Skip to content

Commit

Permalink
feat: take virtualenvs.prefer-active-python into account on `poetry…
Browse files Browse the repository at this point in the history
… new`
  • Loading branch information
finswimmer committed Nov 26, 2022
1 parent 9e5c59e commit bb940fc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/poetry/console/commands/new.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import sys

from contextlib import suppress

from cleo.helpers import argument
Expand Down Expand Up @@ -31,8 +29,9 @@ def handle(self) -> int:

from poetry.core.vcs.git import GitConfig

from poetry.config.config import Config
from poetry.layouts import layout
from poetry.utils.env import SystemEnv
from poetry.utils.env import EnvManager

if self.io.input.option("directory"):
self.line_error(
Expand Down Expand Up @@ -71,8 +70,16 @@ def handle(self) -> int:
if author_email:
author += f" <{author_email}>"

current_env = SystemEnv(Path(sys.executable))
default_python = "^" + ".".join(str(v) for v in current_env.version_info[:2])
poetry_config = Config.create()
default_python = "^" + ".".join(
str(v)
for v in EnvManager.get_python_version(
prefer_active_python=poetry_config.get(
"virtualenvs.prefer-active-python"
),
io=self.io,
)[:2]
)

layout_ = layout_cls(
name,
Expand Down

0 comments on commit bb940fc

Please sign in to comment.