diff --git a/docs/docs/reference/build.md b/docs/docs/reference/build.md index 3fdcfe99c0..d10a98ddb8 100644 --- a/docs/docs/reference/build.md +++ b/docs/docs/reference/build.md @@ -54,20 +54,6 @@ If you run [`pdm init`](../reference/cli.md#init), PDM will let you choose the b [:book: Read the docs](https://hatch.pypa.io/) -=== "pdm-pep517(deprecated)" - - *This backend is deprecated, please migrate to `pdm-backend`.* - - `pyproject.toml` configuration: - - ```toml - [build-system] - requires = ["pdm-pep517"] - build-backend = "pdm.pep517.api" - ``` - - [:book: Read the docs](https://pypi.org/project/pdm-pep517/) - Apart from the above mentioned backends, you can also use any other backend that supports PEP 621, however, [poetry-core](https://python-poetry.org/) is not supported because it does not support reading PEP 621 metadata. diff --git a/docs/docs/reference/pep621.md b/docs/docs/reference/pep621.md index 49c07dd231..feeefb4b03 100644 --- a/docs/docs/reference/pep621.md +++ b/docs/docs/reference/pep621.md @@ -140,7 +140,7 @@ Depending on which build backend you are using, PDM will expand some variables i ### Environment variables -=== "pdm-pep517" +=== "pdm-backend" ```toml [project] @@ -160,11 +160,11 @@ Don't worry about credential leakage, the environment variables will be expanded ### Relative paths -When you add a package from a relative path, PDM will automatically save it as a relative path for `pdm-pep517` and `hatchling`. +When you add a package from a relative path, PDM will automatically save it as a relative path for `pdm-backend` and `hatchling`. For example, if you run `pdm add ./my-package`, it will result in the following line in `pyproject.toml`. -=== "pdm-pep517" +=== "pdm-backend" ```toml [project] diff --git a/docs/docs/usage/project.md b/docs/docs/usage/project.md index 5dcbf500dd..358a077942 100644 --- a/docs/docs/usage/project.md +++ b/docs/docs/usage/project.md @@ -64,11 +64,11 @@ The value of `requires-python` is a [version specifier as defined in PEP 440](ht ## Working with Python < 3.7 -Although PDM run on Python 3.7 and above, you can still have lower Python versions for your **working project**. But remember, if your project is a library, which needs to be built, published or installed, you make sure the PEP 517 build backend being used supports the lowest Python version you need. For instance, the default backend `pdm-pep517` only works on Python 3.7+, so if you run [`pdm build`](../reference/cli.md#build) on a project with Python 3.6, you will get an error. Most modern build backends have dropped the support for Python 3.6 and lower, so it is highly recommended to upgrade the Python version to 3.7+. Here are the supported Python range for some commonly used build backends, we only list those that support PEP 621 since otherwise PDM can't work with them. +Although PDM run on Python 3.7 and above, you can still have lower Python versions for your **working project**. But remember, if your project is a library, which needs to be built, published or installed, you make sure the PEP 517 build backend being used supports the lowest Python version you need. For instance, the default backend `pdm-backend` only works on Python 3.7+, so if you run [`pdm build`](../reference/cli.md#build) on a project with Python 3.6, you will get an error. Most modern build backends have dropped the support for Python 3.6 and lower, so it is highly recommended to upgrade the Python version to 3.7+. Here are the supported Python range for some commonly used build backends, we only list those that support PEP 621 since otherwise PDM can't work with them. | Backend | Supported Python | Support PEP 621 | | --------------------- | ---------------- | --------------- | -| `pdm-pep517` | `>=3.7` | Yes | +| `pdm-backend` | `>=3.7` | Yes | | `setuptools>=60` | `>=3.7` | Experimental | | `hatchling` | `>=3.7` | Yes | | `flit-core>=3.4` | `>=3.6` | Yes | diff --git a/news/2167.removal.md b/news/2167.removal.md new file mode 100644 index 0000000000..5e213adc98 --- /dev/null +++ b/news/2167.removal.md @@ -0,0 +1 @@ +Remove the legacy build backend `pdm-pep517`. diff --git a/src/pdm/cli/completions/pdm.ps1 b/src/pdm/cli/completions/pdm.ps1 index 13aa516401..13c0e76e23 100644 --- a/src/pdm/cli/completions/pdm.ps1 +++ b/src/pdm/cli/completions/pdm.ps1 @@ -285,7 +285,7 @@ function TabExpansion($line, $lastWord) { [Option]::new(@("-g", "--global", "--non-interactive", "-n", "--python", "--lib", "--copier", "--cookiecutter", "--overwrite")), $projectOption, $skipOption, - [Option]::new(@("--backend")).WithValues(@("pdm-backend", "setuptools", "flit", "hatching", "pdm-pep517")) + [Option]::new(@("--backend")).WithValues(@("pdm-backend", "setuptools", "flit", "hatching")) )) break } diff --git a/src/pdm/cli/completions/pdm.zsh b/src/pdm/cli/completions/pdm.zsh index b8766f5fb2..3ffdc6d90d 100644 --- a/src/pdm/cli/completions/pdm.zsh +++ b/src/pdm/cli/completions/pdm.zsh @@ -186,7 +186,7 @@ _pdm() { {-n,--non-interactive}"[Don't ask questions but use default values]" {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' {-r,--overwrite}'[Overwrite existing files]' - '--backend[Specify the build backend]:backend:(pdm-backend setuptools hatchling flit pdm-pep517)' + '--backend[Specify the build backend]:backend:(pdm-backend setuptools hatchling flit)' '--lib[Create a library project]' '--python[Specify the Python version/path to use]:python:' '--copier[Use Copier to generate project]' diff --git a/src/pdm/models/backends.py b/src/pdm/models/backends.py index 7544232bdc..3e6d6a459d 100644 --- a/src/pdm/models/backends.py +++ b/src/pdm/models/backends.py @@ -70,15 +70,6 @@ def build_system(cls) -> BuildSystem: } -class PDMLegacyBackend(PDMBackend): - @classmethod - def build_system(cls) -> BuildSystem: - return { - "requires": ["pdm-pep517>=1.0"], - "build-backend": "pdm.pep517.api", - } - - # Context formatting helpers for hatch class PathContext: def __init__(self, path: Path) -> None: @@ -135,7 +126,6 @@ def build_system(cls) -> BuildSystem: "setuptools": SetuptoolsBackend, "flit-core": FlitBackend, "hatchling": HatchBackend, - "pdm-pep517": PDMLegacyBackend, } # Fallback to the first backend DEFAULT_BACKEND = next(iter(_BACKENDS.values())) diff --git a/tests/cli/test_build.py b/tests/cli/test_build.py index f0a8523cea..ac7f2aa743 100644 --- a/tests/cli/test_build.py +++ b/tests/cli/test_build.py @@ -33,7 +33,7 @@ def test_build_single_module(fixture_project): project = fixture_project("demo-module") Command.do_build(project) - tar_names = get_tarball_names(project.root / "dist/demo-module-0.1.0.tar.gz") + tar_names = get_tarball_names(project.root / "dist/demo_module-0.1.0.tar.gz") for name in [ "foo_module.py", "bar_module.py", @@ -41,7 +41,7 @@ def test_build_single_module(fixture_project): "pyproject.toml", "PKG-INFO", ]: - assert f"demo-module-0.1.0/{name}" in tar_names + assert f"demo_module-0.1.0/{name}" in tar_names zip_names = get_wheel_names(project.root / "dist/demo_module-0.1.0-py3-none-any.whl") for name in ["foo_module.py", "bar_module.py"]: @@ -56,18 +56,18 @@ def test_build_single_module_with_readme(fixture_project): project.pyproject.metadata["readme"] = "README.md" project.pyproject.write() Command.do_build(project) - assert "demo-module-0.1.0/README.md" in get_tarball_names(project.root / "dist/demo-module-0.1.0.tar.gz") + assert "demo_module-0.1.0/README.md" in get_tarball_names(project.root / "dist/demo_module-0.1.0.tar.gz") def test_build_package(fixture_project): project = fixture_project("demo-package") Command.do_build(project) - tar_names = get_tarball_names(project.root / "dist/my-package-0.1.0.tar.gz") - assert "my-package-0.1.0/my_package/__init__.py" in tar_names - assert "my-package-0.1.0/my_package/data.json" in tar_names - assert "my-package-0.1.0/single_module.py" not in tar_names - assert "my-package-0.1.0/data_out.json" not in tar_names + tar_names = get_tarball_names(project.root / "dist/my_package-0.1.0.tar.gz") + assert "my_package-0.1.0/my_package/__init__.py" in tar_names + assert "my_package-0.1.0/my_package/data.json" in tar_names + assert "my_package-0.1.0/single_module.py" not in tar_names + assert "my_package-0.1.0/data_out.json" not in tar_names zip_names = get_wheel_names(project.root / "dist/my_package-0.1.0-py3-none-any.whl") assert "my_package/__init__.py" in zip_names @@ -80,9 +80,9 @@ def test_build_src_package(fixture_project): project = fixture_project("demo-src-package") Command.do_build(project) - tar_names = get_tarball_names(project.root / "dist/demo-package-0.1.0.tar.gz") - assert "demo-package-0.1.0/src/my_package/__init__.py" in tar_names - assert "demo-package-0.1.0/src/my_package/data.json" in tar_names + tar_names = get_tarball_names(project.root / "dist/demo_package-0.1.0.tar.gz") + assert "demo_package-0.1.0/src/my_package/__init__.py" in tar_names + assert "demo_package-0.1.0/src/my_package/data.json" in tar_names zip_names = get_wheel_names(project.root / "dist/demo_package-0.1.0-py3-none-any.whl") assert "my_package/__init__.py" in zip_names @@ -91,20 +91,21 @@ def test_build_src_package(fixture_project): def test_build_package_include(fixture_project): project = fixture_project("demo-package") - project.pyproject.settings["includes"] = [ + build_config = project.pyproject.settings.setdefault("build", {}) + build_config["includes"] = [ "my_package/", "single_module.py", "data_out.json", ] - project.pyproject.settings["excludes"] = ["my_package/*.json"] + build_config["excludes"] = ["my_package/*.json"] project.pyproject.write() Command.do_build(project) - tar_names = get_tarball_names(project.root / "dist/my-package-0.1.0.tar.gz") - assert "my-package-0.1.0/my_package/__init__.py" in tar_names - assert "my-package-0.1.0/my_package/data.json" not in tar_names - assert "my-package-0.1.0/single_module.py" in tar_names - assert "my-package-0.1.0/data_out.json" in tar_names + tar_names = get_tarball_names(project.root / "dist/my_package-0.1.0.tar.gz") + assert "my_package-0.1.0/my_package/__init__.py" in tar_names + assert "my_package-0.1.0/my_package/data.json" not in tar_names + assert "my_package-0.1.0/single_module.py" in tar_names + assert "my_package-0.1.0/data_out.json" in tar_names zip_names = get_wheel_names(project.root / "dist/my_package-0.1.0-py3-none-any.whl") assert "my_package/__init__.py" in zip_names @@ -115,13 +116,13 @@ def test_build_package_include(fixture_project): def test_build_src_package_by_include(fixture_project): project = fixture_project("demo-src-package") - project.pyproject.settings["includes"] = ["src/my_package"] + project.pyproject.settings.setdefault("build", {})["includes"] = ["src/my_package"] project.pyproject.write() Command.do_build(project) - tar_names = get_tarball_names(project.root / "dist/demo-package-0.1.0.tar.gz") - assert "demo-package-0.1.0/src/my_package/__init__.py" in tar_names - assert "demo-package-0.1.0/src/my_package/data.json" in tar_names + tar_names = get_tarball_names(project.root / "dist/demo_package-0.1.0.tar.gz") + assert "demo_package-0.1.0/src/my_package/__init__.py" in tar_names + assert "demo_package-0.1.0/src/my_package/data.json" in tar_names zip_names = get_wheel_names(project.root / "dist/demo_package-0.1.0-py3-none-any.whl") assert "my_package/__init__.py" in zip_names diff --git a/tests/cli/test_publish.py b/tests/cli/test_publish.py index 34672edde0..795bc70328 100644 --- a/tests/cli/test_publish.py +++ b/tests/cli/test_publish.py @@ -117,7 +117,7 @@ def test_publish_and_build_in_one_run(fixture_project, pdm, mock_pypi): mock_pypi.assert_called() assert "Uploading demo_module-0.1.0-py3-none-any.whl" in result - assert "Uploading demo-module-0.1.0.tar.gz" in result + assert "Uploading demo_module-0.1.0.tar.gz" in result, result assert "https://pypi.org/project/demo-module/0.1.0/" in result diff --git a/tests/cli/test_template.py b/tests/cli/test_template.py index f3744a284e..617010e157 100644 --- a/tests/cli/test_template.py +++ b/tests/cli/test_template.py @@ -58,4 +58,4 @@ def test_package_project_template(project_no_init): assert project_no_init.pyproject._data["build-system"] == metadata["build-system"] assert (project_no_init.root / "foo").is_dir() assert (project_no_init.root / "foo/__init__.py").exists() - assert project_no_init.pyproject.settings["version"] == {"from": "foo/__init__.py"} + assert project_no_init.pyproject.settings["version"] == {"path": "foo/__init__.py", "source": "file"} diff --git a/tests/fixtures/projects/demo-combined-extras/pyproject.toml b/tests/fixtures/projects/demo-combined-extras/pyproject.toml index 82cc43d090..f3326d1e92 100644 --- a/tests/fixtures/projects/demo-combined-extras/pyproject.toml +++ b/tests/fixtures/projects/demo-combined-extras/pyproject.toml @@ -17,5 +17,5 @@ te = ["chardet"] all = ["idna", "chardet"] [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" diff --git a/tests/fixtures/projects/demo-module/pyproject.toml b/tests/fixtures/projects/demo-module/pyproject.toml index 8f8d3ca95a..c0880d17e8 100644 --- a/tests/fixtures/projects/demo-module/pyproject.toml +++ b/tests/fixtures/projects/demo-module/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [project] # PEP 621 project metadata @@ -17,5 +17,6 @@ name = "demo-module" [project.optional-dependencies] -[tool.pdm] -version = { from = "foo_module.py" } +[tool.pdm.version] +source = "file" +path = "foo_module.py" diff --git a/tests/fixtures/projects/demo-package-has-dep-with-extras/pyproject.toml b/tests/fixtures/projects/demo-package-has-dep-with-extras/pyproject.toml index 5e6618c023..3440985c31 100644 --- a/tests/fixtures/projects/demo-package-has-dep-with-extras/pyproject.toml +++ b/tests/fixtures/projects/demo-package-has-dep-with-extras/pyproject.toml @@ -12,8 +12,8 @@ requires-python = ">=3.6" license = {text = "MIT"} [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [tool] [tool.pdm] diff --git a/tests/fixtures/projects/demo-package/pyproject.toml b/tests/fixtures/projects/demo-package/pyproject.toml index ac6c16ae1e..70dd8481e0 100644 --- a/tests/fixtures/projects/demo-package/pyproject.toml +++ b/tests/fixtures/projects/demo-package/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [project] # PEP 621 project metadata @@ -18,8 +18,9 @@ readme = "README.md" [project.optional-dependencies] -[tool.pdm] -version = { from = "my_package/__init__.py" } +[tool.pdm.version] +source = "file" +path = "my_package/__init__.py" [[tool.pdm.source]] url = "https://test.pypi.org/simple" diff --git a/tests/fixtures/projects/demo-parent-package/package-b/pyproject.toml b/tests/fixtures/projects/demo-parent-package/package-b/pyproject.toml index ebcd35cc34..fb5988f656 100644 --- a/tests/fixtures/projects/demo-parent-package/package-b/pyproject.toml +++ b/tests/fixtures/projects/demo-parent-package/package-b/pyproject.toml @@ -1,11 +1,12 @@ [build-system] -requires = ["pdm-pep517>=0.3.0"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [project] name = "package-b" dependencies = ["django"] dynamic = ["version"] -[tool.pdm] -version = {from="bar.py"} +[tool.pdm.version] +source = "file" +path = "bar.py" diff --git a/tests/fixtures/projects/demo-src-package/pyproject.toml b/tests/fixtures/projects/demo-src-package/pyproject.toml index d334411aa6..6781d0ad56 100644 --- a/tests/fixtures/projects/demo-src-package/pyproject.toml +++ b/tests/fixtures/projects/demo-src-package/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [project] # PEP 621 project metadata @@ -17,5 +17,6 @@ name = "demo-package" [project.optional-dependencies] -[tool.pdm] -version = { from = "src/my_package/__init__.py" } +[tool.pdm.version] +source = "file" +path = "src/my_package/__init__.py" diff --git a/tests/fixtures/projects/test-monorepo/core/pyproject.toml b/tests/fixtures/projects/test-monorepo/core/pyproject.toml index 7dbe43b53f..4a9a40178b 100644 --- a/tests/fixtures/projects/test-monorepo/core/pyproject.toml +++ b/tests/fixtures/projects/test-monorepo/core/pyproject.toml @@ -6,5 +6,5 @@ requires-python = ">= 3.7" dependencies = [] [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" diff --git a/tests/fixtures/projects/test-monorepo/package_a/pyproject.toml b/tests/fixtures/projects/test-monorepo/package_a/pyproject.toml index 95cd0d92b0..6069e65ab6 100644 --- a/tests/fixtures/projects/test-monorepo/package_a/pyproject.toml +++ b/tests/fixtures/projects/test-monorepo/package_a/pyproject.toml @@ -8,5 +8,5 @@ dependencies = [ ] [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" diff --git a/tests/fixtures/projects/test-monorepo/package_b/pyproject.toml b/tests/fixtures/projects/test-monorepo/package_b/pyproject.toml index 6f673c0c5e..e4446422f5 100644 --- a/tests/fixtures/projects/test-monorepo/package_b/pyproject.toml +++ b/tests/fixtures/projects/test-monorepo/package_b/pyproject.toml @@ -8,5 +8,5 @@ dependencies = [ ] [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" diff --git a/tests/fixtures/projects/test-monorepo/pyproject.toml b/tests/fixtures/projects/test-monorepo/pyproject.toml index 6ffaf01fbc..b113532efd 100644 --- a/tests/fixtures/projects/test-monorepo/pyproject.toml +++ b/tests/fixtures/projects/test-monorepo/pyproject.toml @@ -4,7 +4,3 @@ dependencies = [ "package_a @ file:///${PROJECT_ROOT}/package_a", "package_b @ file:///${PROJECT_ROOT}/package_b", ] - -[build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" diff --git a/tests/fixtures/projects/test-plugin-pdm/pyproject.toml b/tests/fixtures/projects/test-plugin-pdm/pyproject.toml index bab9526fdf..25d1aad1f5 100644 --- a/tests/fixtures/projects/test-plugin-pdm/pyproject.toml +++ b/tests/fixtures/projects/test-plugin-pdm/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["pdm-pep517"] -build-backend = "pdm.pep517.api" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [project] # PEP 621 project metadata diff --git a/tests/models/test_backends.py b/tests/models/test_backends.py index 421b7fe8d1..c81966eb76 100644 --- a/tests/models/test_backends.py +++ b/tests/models/test_backends.py @@ -38,7 +38,7 @@ def test_project_backend(project, working_set, backend, pdm): dep = project.pyproject.metadata["dependencies"][0] demo_path = project.root.joinpath("demo").as_posix() demo_url = path_to_url(demo_path) - if backend in ("pdm-pep517", "pdm-backend"): + if backend == "pdm-backend": assert dep == "demo @ file:///${PROJECT_ROOT}/demo" elif backend == "hatchling": assert dep == "demo @ {root:uri}/demo" @@ -63,10 +63,10 @@ def test_hatch_expand_variables(monkeypatch): assert backend.relative_path_to_url("../demo") == "{root:uri}/../demo" -def test_pdm_pep517_expand_variables(monkeypatch): +def test_pdm_backend_expand_variables(monkeypatch): root = Path().absolute() root_url = path_to_url(root.as_posix()) - backend = get_backend("pdm-pep517")(root) + backend = get_backend("pdm-backend")(root) monkeypatch.setenv("BAR", "bar") assert backend.expand_line("demo @ file:///${PROJECT_ROOT}/demo") == f"demo @ {root_url}/demo" assert backend.expand_line("demo==${BAR}") == "demo==bar" diff --git a/tests/models/test_candidates.py b/tests/models/test_candidates.py index 08b0d751bd..6f9fe95030 100644 --- a/tests/models/test_candidates.py +++ b/tests/models/test_candidates.py @@ -210,7 +210,8 @@ def test_vcs_candidate_in_subdirectory(project, is_editable): candidate = Candidate(req) expected_deps = ["django"] assert candidate.prepare(project.environment).get_dependencies_from_metadata() == expected_deps - assert candidate.version == "0.1.0" + tail = "+editable" if is_editable else "" + assert candidate.version == f"0.1.0{tail}" @pytest.mark.usefixtures("local_finder")