mbox series

[RFC,0/3] Auto-generated Python dependencies

Message ID 20261130133833.2868171-1-ross.burton@arm.com
Headers show
Series Auto-generated Python dependencies | expand

Message

Ross Burton Nov. 30, 2026, 1:38 p.m. UTC
Hi,

Attached is a rough RFC to add automatic Python dependencies to recipes,
following the same model as the Go and Rust classes.  It's slightly hacky still,
but does mostly work:

First, every recipe that uses the pypi class gets a PROVIDES for the normalised
package name.

The pydeps class then adds an update task that uses the pypa-build API to
examine the build and runtime dependencies, and write an include file that sets
DEPENDS and RDEPENDS.

Finally there's a worked example with the python3-license-expression recipe.

Plenty of caveats and things to think about:
- The package variable name should probably be changed as it's not specific to
  PyPI.

- Support for optional dependencies is needed, at least specifying the set
  of optional deps to enable.

- Recipes that don't use pypi.bbclass don't get the provides, and not all
  recipes use that.  Possibly it should done in a separate class that can be
  inherited in various places instead?  Anything using pep517 or setuptools
  can be asked for it's package name at build time, so we could add this
  to the include file too maybe.

- Alternatively, as this is writing a few lines instead of the hundreds that
  the rust/go tasks do, this could use the devtool APIs and update the recipe
  itself inline, instead of writing an include file?

- It would be nice to have the include done by the class, but I can't see a
  variable for "THISDIR, but the directory of the recipe not the class".

Anyway, it sort of works for for third party dependencies. My plan for the
stdlib dependencies is still to remove the problem by continuing to shrink
the number of packages.

Cheers,
Ross

Ross Burton (3):
  pypi: add provides for the pypi package name
  classes: add pydeps class
  license-expression: use class

 meta/classes-recipe/pydeps.bbclass            |  8 ++
 meta/classes-recipe/pypi.bbclass              |  5 ++
 meta/files/py-update-requires.py              | 81 +++++++++++++++++++
 ...python3-license-expression-python-deps.inc |  8 ++
 .../python3-license-expression_30.4.4.bb      |  7 +-
 5 files changed, 105 insertions(+), 4 deletions(-)
 create mode 100644 meta/classes-recipe/pydeps.bbclass
 create mode 100755 meta/files/py-update-requires.py
 create mode 100644 meta/recipes-devtools/python/python3-license-expression-python-deps.inc