{"id":8405,"library":"pdm-pep517","title":"pdm-pep517","description":"pdm-pep517 is an official plugin for PDM, the Python package manager. It acts as a PEP 517 build backend, enabling PDM projects to be built into distribution packages (sdist, wheel) using PEP 621 metadata defined in `pyproject.toml`. It is currently at version 1.1.4 and is actively maintained, with updates tied to PDM's core development and bug fixes.","status":"active","version":"1.1.4","language":"en","source_language":"en","source_url":"https://github.com/pdm-project/pdm-pep517","tags":["pdm","pep517","build-backend","packaging","pyproject.toml","build","developer-tool"],"install":[{"cmd":"pip install pdm-pep517","lang":"bash","label":"Install pdm-pep517"}],"dependencies":[{"reason":"Required for pdm-pep517 to function as a build backend, specifically PDM >= 2.0.0.","package":"pdm","optional":false},{"reason":"Used internally for version parsing and metadata handling.","package":"packaging","optional":false}],"imports":[],"quickstart":{"code":"import os\nimport shutil\nimport subprocess\nfrom pathlib import Path\n\n# --- Setup a temporary project to demonstrate pdm-pep517 ---\nproject_name = \"my_pdm_project_quickstart\"\nproject_path = Path(project_name)\n\n# Clean up previous run if exists\nif project_path.exists():\n    shutil.rmtree(project_path)\n\nproject_path.mkdir()\n(project_path / project_name).mkdir()\n\n# Create a simple __init__.py\n(project_path / project_name / \"__init__.py\").write_text(\n    f'__version__ = \"0.1.0\"\\n'\n    f'def hello():\\n'\n    f'    return \"Hello from {project_name}\"\\n'\n)\n\n# Create pyproject.toml with pdm-pep517 as build backend\npyproject_toml_content = f\"\"\"\n[project]\nname = \"{project_name}\"\nversion = \"0.1.0\"\ndescription = \"A project built with pdm-pep517\"\nrequires-python = \">=3.8\"\nauthors = [\n    {{ name = \"AI Assistant\", email = \"ai@example.com\" }},\n]\n\n[build-system]\nrequires = [\"pdm-pep517\", \"pdm>=2.0.0\"]\nbuild-backend = \"pdm.pep517.api\"\n\"\"\"\n(project_path / \"pyproject.toml\").write_text(pyproject_toml_content)\n\nprint(f\"Created project structure in {project_path.resolve()}\\n\")\n\n# --- Build the project using PDM ---\nprint(\"Attempting to build the project with 'pdm build'...\")\n\ntry:\n    # Change to the project directory for pdm commands\n    os.chdir(project_path)\n\n    # Ensure pdm is installed and on PATH\n    pdm_cmd = os.environ.get('PDM_PATH', 'pdm')\n    result = subprocess.run(\n        [pdm_cmd, \"build\"],\n        capture_output=True,\n        text=True,\n        check=True # Raise CalledProcessError for non-zero exit codes\n    )\n    print(\"Build successful!\")\n    print(result.stdout)\n    print(result.stderr)\n\n    # Verify wheel file exists\n    dist_path = Path(\"dist\")\n    wheel_files = list(dist_path.glob(\"*.whl\"))\n    if wheel_files:\n        print(f\"Generated wheel file: {wheel_files[0].name}\")\n    else:\n        print(\"No wheel file found in 'dist' directory.\")\n\nexcept FileNotFoundError:\n    print(f\"\\nError: '{pdm_cmd}' command not found. Please ensure PDM is installed and on your PATH.\")\n    print(\"You can install it via: `pip install pdm`\")\nexcept subprocess.CalledProcessError as e:\n    print(f\"\\nBuild failed with error code {e.returncode}\")\n    print(\"STDOUT:\")\n    print(e.stdout)\n    print(\"STDERR:\")\n    print(e.stderr)\nfinally:\n    # Clean up the temporary project\n    os.chdir(\"..\")\n    shutil.rmtree(project_path)\n    print(f\"\\nCleaned up temporary project directory: {project_path}\")\n","lang":"python","description":"This quickstart demonstrates how to set up a project to use `pdm-pep517` as its build backend and then build it using PDM. It programmatically creates a dummy project, configures its `pyproject.toml` to use `pdm.pep517.api`, and then executes `pdm build`. Ensure PDM itself is installed in your environment before running this script."},"warnings":[{"fix":"Upgrade PDM to version 2.0.0 or newer. Recommended command: `pip install --upgrade pdm`.","message":"PDM 2.0+ Requirement: `pdm-pep517` explicitly requires PDM 2.0 or later to function correctly. Using an older PDM version will result in a `RuntimeError` during the build process.","severity":"breaking","affected_versions":"<1.0.0 of pdm-pep517 (implicit by PDM dependency), all versions of pdm-pep517 with PDM < 2.0.0"},{"fix":"Ensure your `pyproject.toml` includes `pdm-pep517` and `pdm>=2.0.0` in the `build-system.requires` list: `requires = [\"pdm-pep517\", \"pdm>=2.0.0\"]`.","message":"Build Environment Installation: When building with tools like `pip build` or in isolated CI/CD environments, `pdm-pep517` must be listed in `build-system.requires` in your `pyproject.toml` so the build backend is installed in the isolated environment. PDM's own `pdm build` command handles this automatically for you.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify that your `pyproject.toml` contains `build-backend = \"pdm.pep517.api\"` exactly as shown in the `[build-system]` section.","message":"Incorrect `build-backend` Specification: The `build-backend` entry in `pyproject.toml` must be precisely `pdm.pep517.api`. Any deviation will prevent the build tool from finding the correct backend.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install `pdm-pep517` into your environment (`pip install pdm-pep517`). If using isolated builds (e.g., `python -m build`), ensure `pyproject.toml` has `pdm-pep517` in `build-system.requires`.","cause":"The `pdm-pep517` library is not installed in the Python environment where the build process is attempting to run, or it was not listed in `build-system.requires` for an isolated build.","error":"ModuleNotFoundError: No module named 'pdm.pep517.api'"},{"fix":"Upgrade your PDM installation to version 2.0.0 or newer by running: `pip install --upgrade pdm`.","cause":"`pdm-pep517` was invoked, but the installed PDM version in the active environment is older than 2.0.0, or PDM is not installed at all.","error":"RuntimeError: PDM is not installed or PDM's version is too old. PDM >= 2.0.0 is required."},{"fix":"Add a `[project]` table to your `pyproject.toml` file, including at least `name`, `version`, and `requires-python` fields.","cause":"The `pyproject.toml` file is missing the mandatory `[project]` table, which is required by PEP 621 metadata specification that `pdm-pep517` relies on.","error":"pyproject.toml does not contain a [project] table"}]}