Skip to content

Commit

Permalink
fix: Use minimal template if the project is an application.
Browse files Browse the repository at this point in the history
Related to #3295

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Dec 6, 2024
1 parent 5d59fd3 commit 8a651c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/3295.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use minimal template if the project is an application.
6 changes: 5 additions & 1 deletion src/pdm/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def _init_cookiecutter(self, project: Project, options: argparse.Namespace) -> N

def _init_builtin(self, project: Project, options: argparse.Namespace) -> None:
metadata = self.get_metadata_from_input(project, options)
with ProjectTemplate(options.template) as template:
template = options.template
if not template:
template = "default" if options.dist else "minimal"
with ProjectTemplate(template) as template:
template.generate(project.root, metadata, options.overwrite)
project.pyproject.reload()

Expand Down Expand Up @@ -119,6 +122,7 @@ def get_metadata_from_input(self, project: Project, options: argparse.Namespace)
"Do you want to build this project for distribution(such as wheel)?\n"
"If yes, it will be installed by default when running `pdm install`."
)
options.dist = is_dist
build_backend: type[BuildBackend] | None = None
python = project.python
if is_dist:
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_init_non_interactive(project_no_init, pdm, mocker):
def test_init_auto_create_venv(project_no_init, pdm, mocker):
mocker.patch("pdm.models.python.PythonInfo.get_venv", return_value=None)
project_no_init.project_config["python.use_venv"] = True
result = pdm(["init"], input="\n\n\n\n\n\n\n\n", obj=project_no_init)
result = pdm(["init"], input="\ntest-project\n\ny\nTest Project\n1\n\n\n\n\n", obj=project_no_init)
assert result.exit_code == 0
assert project_no_init.python.executable.parent.parent == project_no_init.root / ".venv"
assert ".pdm-python" in (project_no_init.root / ".gitignore").read_text()
Expand Down

0 comments on commit 8a651c3

Please sign in to comment.