{"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.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pdm-pep517"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}