{"library":"pyproject-api","code":"import sys\nfrom pathlib import Path\nimport tempfile\nimport shutil\n\n# Create a temporary project directory\ntemp_dir = Path(tempfile.mkdtemp())\nproject_root = temp_dir / \"my_project\"\nproject_root.mkdir()\n\n# Create a minimal pyproject.toml\npyproject_toml_content = '''\n[build-system]\nrequires = [\"my-dummy-backend\"]\nbuild-backend = \"my_dummy_backend:MyDummyBackend\"\n\n[project]\nname = \"my-example-package\"\nversion = \"0.0.1\"\n'''\n(project_root / \"pyproject.toml\").write_text(pyproject_toml_content)\n\n# Create a dummy build backend module (my_dummy_backend.py)\nbackend_module_content = '''\nfrom pathlib import Path\n\nclass MyDummyBackend:\n    def __init__(self, directory): # pyproject-api passes the project directory\n        self.directory = Path(directory)\n        self.name = \"my-example-package\"\n\n    def get_requires_for_build_wheel(self, config_settings=None):\n        return []\n\n    def build_wheel(self, wheel_directory, config_settings=None, metadata_directory=None):\n        # Simulate building a wheel file\n        wheel_name = f\"{self.name}-0.0.1-py3-none-any.whl\"\n        (Path(wheel_directory) / wheel_name).touch()\n        return wheel_name\n'''\n(project_root / \"my_dummy_backend.py\").write_text(backend_module_content)\n\nfrom pyproject_api import Frontend, BackendFailed\n\nprint(f\"Created temporary project at: {project_root}\")\n\ntry:\n    # Initialize the Frontend to interact with our dummy project\n    # backend_paths is crucial to make 'my_dummy_backend' importable\n    frontend = Frontend(\n        root=project_root,\n        backend_paths=[project_root],\n        backend_module=\"my_dummy_backend\",\n        backend_obj=\"MyDummyBackend\", # The class name to instantiate\n        requires=[], # Our dummy backend doesn't have build requirements itself\n        reuse_backend=False\n    )\n\n    # Get build requirements (should be empty for our dummy backend)\n    build_requirements = frontend.get_requires_for_build_wheel()\n    print(f\"Build requirements reported by backend: {build_requirements.requires}\")\n\n    # Build a wheel\n    build_dir = temp_dir / \"dist\"\n    build_dir.mkdir()\n    print(f\"Attempting to build wheel into: {build_dir}\")\n    wheel_result = frontend.build_wheel(build_dir)\n    print(f\"Successfully built wheel: {wheel_result.path.name}\")\n    print(f\"Wheel file location: {wheel_result.path}\")\n\nexcept BackendFailed as e:\n    print(f\"Backend operation failed: {e.exc_msg}\")\n    print(f\"Backend stdout: {e.out}\")\n    print(f\"Backend stderr: {e.err}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    # Clean up the temporary directory\n    if temp_dir.exists():\n        shutil.rmtree(temp_dir)\n        print(f\"Cleaned up temporary directory: {temp_dir}\")","lang":"python","description":"This quickstart demonstrates how to use `pyproject_api.Frontend` to programmatically interact with a project structured around `pyproject.toml`. It sets up a minimal project with a dummy build backend, then uses `Frontend` to query build requirements and simulate building a wheel. The `backend_paths` argument is essential for `pyproject-api` to locate and import your custom build backend module.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}