Skip to content

Create method to #934

@Lanceypantsy

Description

@Lanceypantsy

Summary

We are commonly/regularly using the prepare_source() hook for package plugins to make simple modifications to the pyproject.toml in cases where the dynamic field is missing from the [project] header in the toml file.

Ideally, we'd be able to do this common operation as an override setting in a yaml file, instead of needing a plugin.

def prepare_source(
    ctx: context.WorkContext,
    req: Requirement,
    source_filename: pathlib.Path,
    version: Version,
) -> tuple[pathlib.Path, bool]:
    source_root_dir, is_new = sources.default_prepare_source(
        ctx=ctx, req=req, source_filename=source_filename, version=version
    )
    if is_new:
        # Fix pyproject.toml: add 'readme' to dynamic field in [project] table
        # to prevent AttributeError when setuptools processes the readme metadata
        pyproject = source_root_dir / "pyproject.toml"
        if pyproject.exists():
            logger.info(
                "%s: patching pyproject.toml to add readme to dynamic fields",
                req.name,
            )
            utils.replace_lines(
                pyproject,
                [
                    (
                        r"^(requires-python\s*=.*)$",
                        r'\1\ndynamic = ["readme"]',
                    ),
                ],
            )

    return source_root_dir, is_new

What needs to happen

Develop a method for an override setting to work as follows:

annotations:
  aipcc.component: Development Platform
project_override:
  add_dynamic_field:
    - readme
    - version
    - license
    - authors
changelog:
  "0.9.1":
    - "2026-02-20: initial build for pydeck"

Related

PEP 621

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions