• 
      

    Add per-build dependencies and normalized exclusions.

    Review Request #15044 — Created May 12, 2026 and submitted

    Information

    buildthings
    master

    Reviewers

    During the development of buildthings, one of the goals was to allow
    editable builds to exclude certain dependencies. This was removed
    accidentally during the move to build isolation dependency control.

    This change brings that functionality back and improves it.

    All build types can now specify their own lists of dependencies, which
    default to the standard dependencies set. They can also specify their
    own exclusions.

    Exclusions, both on dependencies and isolations, are now normalized.
    The name in an exclusion can now match against a name with a version
    specifier in the dependencies list. Names are also canonicalized, so
    they don't have to be an exact match.

    Unit tests covering the dependency options for build isolation, package
    metadata, and builds have been added, along with the underlying methods
    used for normalizing and filtering dependencies. These tests have been
    moved into buildthings/tests/ so that we can reliably import test
    modules for utilities.

    Built packages in Review Board using both dependencies and exclusions.
    Checked the resulting lists.

    Installed in editable mode and verified it also used the right
    dependencies and exclusions.

    All unit tests pass.

    Summary ID
    Add per-build dependencies and normalized exclusions.
    During the development of buildthings, one of the goals was to allow editable builds to exclude certain dependencies. This was removed accidentally during the move to build isolation dependency control. This change brings that functionality back and improves it. All build types can now specify their own lists of dependencies, which default to the standard dependencies set. They can also specify their own exclusions. Exclusions, both on dependencies and isolations, are now normalized. The name in an exclusion can now match against a name with a version specifier in the dependencies list. Names are also canonicalized, so they don't have to be an exact match. Unit tests covering the dependency options for build isolation, package metadata, and builds have been added, along with the underlying methods used for normalizing and filtering dependencies. These tests have been moved into `buildthings/tests/` so that we can reliably import test modules for utilities.
    191e79ad4df7f1211d2a0adb42765f0c28283e63
    Description From Last Updated

    It seems like these shouldn't have isolation in them.

    david david

    You added a whole big section for .exclude-deps, but .dependencies only gets this. Can we make a section for this …

    david david

    Don't we need to be applying exclusions here? It seems like we're correctly excluding dependencies inside the isolated environment, but …

    david david

    Same here.

    david david

    Same here.

    david david

    It might be nice to validate that these are lists (in the way that _load_dependencies does).

    david david

    It might be surprising that package[extras] wouldn't match an exclusion of package. Can we at least note in here that …

    david david

    This can be *package_deps_config['dependencies']

    david david

    typo: arguments -> argument

    david david

    We're not validating the type in this branch. Can we make a small helper to do the validation bit that …

    david david

    Need to add "Returns:" to this docstring now.

    david david

    PEP685 says that extras names should be normalized using the same rules as project names, so this should probably be: …

    david david

    I think when we're in greenfield packages where we're truly using pytest-style tests, we should use real python docstrings with …

    david david

    Leftover debug code.

    david david
    david
    1. 
        
    2. README.rst (Diff revision 1)
       
       
       
       
       
       
      Show all issues

      It seems like these shouldn't have isolation in them.

    3. README.rst (Diff revision 1)
       
       
       
       
       
      Show all issues

      You added a whole big section for .exclude-deps, but .dependencies only gets this. Can we make a section for this too?

      1. It's in the dependencies section, which has a lot of content. This is the override example for the dependencies. What should I add?

      2. Just thinking it would be nice to have something like this, matching the exclude section:

        tool.buildthings.<build_type>.dependencies
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        .. versionadded:: 1.1
        
        A list of Python package dependencies for the given build type.
        
        This will override the general dependencies specified in
        ``tool.buildthings.dependencies``.
        
        **Example**
        
        .. code-block:: toml
        
           [tool.buildthings.editable]
           dependencies = ["kgb"]
        
      3. exclude-deps has its own section there because, unlike with dependencies, this isn't an override for one in tool.buildthings. It's only found in the build type sections. This is following the same pattern used for all the docs here, which is to document where the setting is defined at the highest level and then to list where it can be overridden. For example, we have:

        tool.buildthings.isolation.include-dev-deps
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        When ``true``, development dependencies (from
        ``tool.buildthings.dev-dependencies`` or ``dev-requirements.txt``) will be
        installed into the isolated build environment.
        
        This may be needed if you're using extra build steps.
        
        **Overridden by:**
        
        * ``tool.buildthings.isolation.editable.include-dev-deps``
        * ``tool.buildthings.isolation.sdist.include-dev-deps``
        * ``tool.buildthings.isolation.wheel.include-dev-deps``
        
    4. buildthings/backend.py (Diff revision 1)
       
       
      Show all issues

      Don't we need to be applying exclusions here? It seems like we're correctly excluding dependencies inside the isolated environment, but the resulting wheel file would have Requires-Dist with all dependencies in it.

    5. buildthings/backend.py (Diff revision 1)
       
       
      Show all issues

      Same here.

    6. buildthings/backend.py (Diff revision 1)
       
       
      Show all issues

      Same here.

    7. buildthings/config.py (Diff revision 1)
       
       
       
       
       
       
       
       
      Show all issues

      It might be nice to validate that these are lists (in the way that _load_dependencies does).

    8. buildthings/requirements.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      It might be surprising that package[extras] wouldn't match an exclusion of package. Can we at least note in here that extras will be included in the returned name?

    9. 
        
    chipx86
    david
    1. 
        
    2. buildthings/backend.py (Diff revision 2)
       
       
      Show all issues

      This can be *package_deps_config['dependencies']

    3. buildthings/config.py (Diff revision 2)
       
       
      Show all issues

      typo: arguments -> argument

    4. buildthings/config.py (Diff revision 2)
       
       
      Show all issues

      We're not validating the type in this branch.

      Can we make a small helper to do the validation bit that you added twice above so we can use it here too?

      1. Validation needs more work in general. I'd rather not get this change any more out of scope at this point in the release than it is. Let's punt for now on future cleanup.

    5. buildthings/config.py (Diff revision 2)
       
       
       
       
      Show all issues

      Need to add "Returns:" to this docstring now.

    6. buildthings/requirements.py (Diff revision 2)
       
       
       
       
      Show all issues

      PEP685 says that extras names should be normalized using the same rules as project names, so this should probably be:

      extras_str = ','.join(sorted(canonicalize_name(e) for e in extras))
      
    7. buildthings/tests/test_backend.py (Diff revision 2)
       
       
      Show all issues

      I think when we're in greenfield packages where we're truly using pytest-style tests, we should use real python docstrings with imperative mood and trailing periods.

      So "Test get_requires_for_build_editable."

      Same for the rest of the test cases.

      1. I don't love having two standards for how we write these, but fine. The conditions of a test usually need to wrap after the first line summary, so we're not going to get actual real docstring compliance for tests, just a version of it.

    8. buildthings/tests/test_config.py (Diff revision 2)
       
       
      Show all issues

      Leftover debug code.

    9. 
        
    chipx86
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (733889a)