-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new setting
package-type
to distinguish application and…
… library (#2394)
- Loading branch information
Showing
11 changed files
with
40 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
We now use the `package-type` field in the `tool.pdm` table to differentiate between library and application projects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
|
||
def test_init_validate_python_requires(project_no_init, pdm): | ||
result = pdm(["init"], input="\n\n\n\n\n3.7\n", obj=project_no_init) | ||
result = pdm(["init"], input="\n\n\n\n\n\n\n3.7\n", obj=project_no_init) | ||
assert result.exit_code != 0 | ||
assert "InvalidSpecifier" in result.stderr | ||
|
||
|
@@ -18,19 +18,20 @@ def test_init_command(project_no_init, pdm, mocker): | |
"pdm.cli.commands.init.get_user_email_from_git", | ||
return_value=("Testing", "[email protected]"), | ||
) | ||
pdm(["init"], input="\n\n\n\n\n\n", strict=True, obj=project_no_init) | ||
pdm(["init"], input="\ntest-project\n\n\n\n\n\n\n", strict=True, obj=project_no_init) | ||
python_version = f"{project_no_init.python.major}.{project_no_init.python.minor}" | ||
data = { | ||
"project": { | ||
"authors": [{"email": "[email protected]", "name": "Testing"}], | ||
"dependencies": [], | ||
"description": "", | ||
"description": "Default template for PDM package", | ||
"license": {"text": "MIT"}, | ||
"name": "", | ||
"name": "test-project", | ||
"requires-python": f"=={python_version}.*", | ||
"readme": "README.md", | ||
"version": "", | ||
"version": "0.1.0", | ||
}, | ||
"tool": {"pdm": {"package-type": "application"}}, | ||
} | ||
|
||
with open(project_no_init.root.joinpath("pyproject.toml"), "rb") as fp: | ||
|
@@ -44,7 +45,7 @@ def test_init_command_library(project_no_init, pdm, mocker): | |
) | ||
result = pdm( | ||
["init"], | ||
input="\ny\ntest-project\n\nTest Project\n1\n\n\n\n\n", | ||
input="\ntest-project\n\ny\nTest Project\n1\n\n\n\n\n", | ||
obj=project_no_init, | ||
) | ||
assert result.exit_code == 0 | ||
|
@@ -61,6 +62,7 @@ def test_init_command_library(project_no_init, pdm, mocker): | |
"version": "0.1.0", | ||
}, | ||
"build-system": {"build-backend": "setuptools.build_meta", "requires": ["setuptools>=61", "wheel"]}, | ||
"tool": {"pdm": {"package-type": "library"}}, | ||
} | ||
|
||
with open(project_no_init.root.joinpath("pyproject.toml"), "rb") as fp: | ||
|
@@ -89,13 +91,14 @@ def test_init_non_interactive(project_no_init, pdm, mocker): | |
"project": { | ||
"authors": [{"email": "[email protected]", "name": "Testing"}], | ||
"dependencies": [], | ||
"description": "", | ||
"description": "Default template for PDM package", | ||
"license": {"text": "MIT"}, | ||
"name": "", | ||
"name": project_no_init.root.name, | ||
"requires-python": f"=={python_version}.*", | ||
"readme": "README.md", | ||
"version": "", | ||
"version": "0.1.0", | ||
}, | ||
"tool": {"pdm": {"package-type": "application"}}, | ||
} | ||
|
||
with open(project_no_init.root.joinpath("pyproject.toml"), "rb") as fp: | ||
|
@@ -105,7 +108,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", obj=project_no_init) | ||
result = pdm(["init"], input="\n\n\n\n\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() | ||
|
@@ -116,7 +119,7 @@ def test_init_auto_create_venv_specify_python(project_no_init, pdm, mocker): | |
project_no_init.project_config["python.use_venv"] = True | ||
result = pdm( | ||
["init", f"--python={PYTHON_VERSION}"], | ||
input="\n\n\n\n\n\n", | ||
input="\n\n\n\n\n\n\n\n", | ||
obj=project_no_init, | ||
) | ||
assert result.exit_code == 0 | ||
|
@@ -127,7 +130,7 @@ def test_init_auto_create_venv_answer_no(project_no_init, pdm, mocker): | |
mocker.patch("pdm.models.python.PythonInfo.get_venv", return_value=None) | ||
creator = mocker.patch("pdm.cli.commands.venv.backends.Backend.create") | ||
project_no_init.project_config["python.use_venv"] = True | ||
result = pdm(["init"], input="\nn\n\n\n\n\n\n\n", obj=project_no_init) | ||
result = pdm(["init"], input="\nn\n\n\n\n\n\n\n\n\n", obj=project_no_init) | ||
assert result.exit_code == 0 | ||
creator.assert_not_called() | ||
assert project_no_init.python.executable.parent.parent != project_no_init.root / ".venv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters