Skip to content

Commit

Permalink
fix(#2436): pdm init -n does not respect global python with asdf/rt…
Browse files Browse the repository at this point in the history
…x/pyenv

Fix #2436

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Nov 28, 2023
1 parent c3dbe89 commit 4f06613
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
1 change: 1 addition & 0 deletions news/2436.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the same order of Python interpreters as interactive mode in `pdm init -n`.
30 changes: 9 additions & 21 deletions src/pdm/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,15 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
def set_python(self, project: Project, python: str | None, hooks: HookManager) -> None:
from pdm.cli.commands.use import Command as UseCommand

do_use = UseCommand().do_use
if self.interactive:
python_info = do_use(
project,
python or "",
first=bool(python),
ignore_remembered=True,
ignore_requires_python=True,
save=False,
hooks=hooks,
)
else:
python_info = do_use(
project,
python or "3",
first=True,
ignore_remembered=True,
ignore_requires_python=True,
save=False,
hooks=hooks,
)
python_info = UseCommand().do_use(
project,
python or "",
first=bool(python) or not self.interactive,
ignore_remembered=True,
ignore_requires_python=True,
save=False,
hooks=hooks,
)

if project.config["python.use_venv"] and (
python_info.get_venv() is None or is_conda_base_python(python_info.path)
Expand Down

0 comments on commit 4f06613

Please sign in to comment.