Skip to content

Commit

Permalink
feat: use ==major.minor.* as the default requires-python for applic…
Browse files Browse the repository at this point in the history
…ations (#2382)
  • Loading branch information
frostming committed Nov 16, 2023
1 parent 7b10371 commit 1d3ac51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/2382.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use `==major.minor.*` as default requires python for application projects.
7 changes: 4 additions & 3 deletions src/pdm/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def get_metadata_from_input(self, project: Project, options: argparse.Namespace)
"the project name and build backend"
)
build_backend: type[BuildBackend] | None = None
python = project.python
if is_library:
name = self.ask_project(project)
version = self.ask("Project version", "0.1.0")
Expand All @@ -140,16 +141,16 @@ def get_metadata_from_input(self, project: Project, options: argparse.Namespace)
build_backend = get_backend(all_backends[int(selected_backend)])
else:
build_backend = DEFAULT_BACKEND
default_python_requires = f">={python.major}.{python.minor}"
else:
name, version, description = "", "", ""
default_python_requires = f"=={python.major}.{python.minor}.*"
license = self.ask("License(SPDX name)", "MIT")

git_user, git_email = get_user_email_from_git()
author = self.ask("Author name", git_user)
email = self.ask("Author email", git_email)
python = project.python
python_version = f"{python.major}.{python.minor}"
python_requires = self.ask("Python requires('*' to allow any)", f">={python_version}")
python_requires = self.ask("Python requires('*' to allow any)", default_python_requires)

data = {
"project": {
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_init_command(project_no_init, pdm, mocker):
"description": "",
"license": {"text": "MIT"},
"name": "",
"requires-python": f">={python_version}",
"requires-python": f"=={python_version}.*",
"readme": "README.md",
"version": "",
},
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_init_non_interactive(project_no_init, pdm, mocker):
"description": "",
"license": {"text": "MIT"},
"name": "",
"requires-python": f">={python_version}",
"requires-python": f"=={python_version}.*",
"readme": "README.md",
"version": "",
},
Expand Down

0 comments on commit 1d3ac51

Please sign in to comment.