Skip to contentSkip to conversation

docs: add new python packaging classes

PATCH In review Tim Orling 2 participants 4 messages Feb 28, 2022 – Mar 2, 2022

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

PATCH 1/3 docs: add new python packaging classes

Add the new classes used for Python packaging:
* flit_core
* pip_install_wheel
* setuptools_build_meta

---
 documentation/ref-manual/classes.rst | 53 ++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
documentation/ref-manual/classes.rst +53 -0
index 949217bf4..2338ef6b3 100644
@@ -650,6 +650,22 @@ variables are not met, the recipe will be skipped, and if the
 build system attempts to build the recipe then an error will be
 triggered.
 
+.. _ref-classes-flit_core:
+
+``flit_core.bbclass``
+=====================
+
+The ``flit_core`` class enables building Python modules which declare
+the  `PEP-517 <https://www.python.org/dev/peps/pep-0517/>`__ compliant
+``flit_core.buildapi`` ``build-backend`` in the ``[build-system]``
+section of ``pyproject.toml`` (See `PEP-518 <https://www.python.org/dev/peps/pep-0518/>`__).
+
+Python modules built with ``flit_core.buildapi`` are pure Python (no
+``C`` or ``Rust`` extensions).
+
+The resulting ``wheel`` (See `PEP-427 <https://www.python.org/dev/peps/pep-0427/>`__)
+is installed with the :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` class.
+
 .. _ref-classes-fontcache:
 
 ``fontcache.bbclass``
@@ -2025,6 +2041,26 @@ When inherited by a recipe, the ``perlnative`` class supports using the
 native version of Perl built by the build system rather than using the
 version provided by the build host.
 
+.. _ref-classes-pip_install_wheel:
+
+``pip_install_wheel.bbclass``
+=============================
+
+The ``pip_install_wheel`` class uses ``pip`` to install a Python ``wheel``
+binary archive format (See `PEP-427 <https://www.python.org/dev/peps/pep-0427/>`__)
+
+The Python ``wheel`` can be built with several classes, including :ref:`flit_core <ref-classes-flit_core>`,
+:ref:`setuptools_build_meta <ref-classes-setuptools_build_meta>`, and :ref:`setuptools3 <ref-classes-setuptools3>`.
+
+The absolute path to the built ``wheel`` to be installed is defined by :term:`PYPA_WHEEL` which can be
+overriden for recipes where the filename or version number of the wheel are not easily
+determined by the defaults. Other variables which can be used to customize the behavior
+of the ``pip_install_wheel`` class include:
+
+- :term:`PIP_INSTALL_ARGS`
+- :term:`PIP_INSTALL_PACKAGE`
+- :term:`PIP_INSTALL_DIST_PATH`
+
 .. _ref-classes-pixbufcache:
 
 ``pixbufcache.bbclass``
@@ -2380,6 +2416,23 @@ additional configuration options you want to pass SCons command line.
 The ``sdl`` class supports recipes that need to build software that uses
 the Simple DirectMedia Layer (SDL) library.
 
+.. _ref-classes-setuptools_build_meta:
+
+``setuptools_build_meta.bbclass``
+=================================
+
+The ``setuptools_build_meta`` class enables building Python modules which
+declare the 
+`PEP-517 <https://www.python.org/dev/peps/pep-0517/>`__ compliant
+``setuptools.build_meta`` ``build-backend`` in the ``[build-system]``
+section of ``pyproject.toml`` (See `PEP-518 <https://www.python.org/dev/peps/pep-0518/>`__).
+
+Python modules built with ``setuptools.build_meta`` can be pure Python or
+include ``C`` or ``Rust`` extensions).
+
+The resulting ``wheel`` (See `PEP-427 <https://www.python.org/dev/peps/pep-0427/>`__)
+is installed with the :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` class.
+
 .. _ref-classes-setuptools3:
 
 ``setuptools3.bbclass``
Signature · 1 line
2.30.2
author
#1 lore raw

PATCH 2/3 docs: add pip install variables

Add the new variables used to install Python wheel binary archives:
* PIP_INSTALL_ARGS
* PIP_INSTALL_DIST_PATH
* PIP_INSTALL_PACKAGE
* PYPA_WHEEL

---
 documentation/ref-manual/variables.rst | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
documentation/ref-manual/variables.rst +26 -0
index ecb2b60c7..1f6433084 100644
@@ -5594,6 +5594,25 @@ system and gives an overview of their function and contents.
       ``bash-4.2-r1/``). This variable is comprised of the following:
       ${:term:`PN`}-${:term:`EXTENDPE`}${:term:`PV`}-${:term:`PR`}
 
+   :term:`PIP_INSTALL_ARGS`
+      When used by recipes that inherit the
+      :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` class,
+      denotes the arguments passed to ``pip install`` to adjust the
+      behavior of how the ``wheel`` is installed.
+
+   :term:`PIP_INSTALL_DIST_PATH`
+      When used by recipes that inherit the
+      :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` class,
+      denotes the path to ``dist/`` (short for distribution) where the
+      binary archive ``wheel`` is built. This is used in part to create
+      the :term:`PYPA_WHEEL` variable.
+
+   :term:`PIP_INSTALL_PACKAGE`
+      When used by recipes that inherit the
+      :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` class,
+      denotes the name of the package portion of the ``wheel`` filename.
+      This is used in part to create the :term:`PYPA_WHEEL` variable.
+
    :term:`PIXBUF_PACKAGES`
       When inheriting the :ref:`pixbufcache <ref-classes-pixbufcache>`
       class, this variable identifies packages that contain the pixbuf
@@ -6021,6 +6040,13 @@ system and gives an overview of their function and contents.
 
       :term:`PV` is the default value of the :term:`PKGV` variable.
 
+   :term:`PYPA_WHEEL`
+      When used by recipes that inherit the
+      :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` class, denotes
+      the absolute path to the built ``wheel`` to be installed. Normally the
+      defaults which use :term:`PIP_INSTALL_PACKAGE` and :term:`PIP_INSTALL_DIST_PATH`
+      to build the path to the ``wheel`` should be sufficient.
+
    :term:`PYTHON_ABI`
       When used by recipes that inherit the
       :ref:`distutils3 <ref-classes-distutils3>`,
Signature · 1 line
2.30.2
Reviewed-by on v1 2/3
#2 lore raw

Re: [docs] [PATCH 2/3] docs: add pip install variables

Quoted 7 lines · Tim Orling

Add the new variables used to install Python wheel binary archives:
* PIP_INSTALL_ARGS
* PIP_INSTALL_DIST_PATH
* PIP_INSTALL_PACKAGE
* PYPA_WHEEL

For both patches:

I add to remove a trailing whitespace, but no harm, everything else was fine.
I merged your two changes into "master-next".

Thanks again
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#3 lore raw

PATCH 3/3 docs: update setuptools3 class

In reply to Tim Orling

Add notes to inform about the new wheel behavior of the setuptools3.bbclass.

---
 documentation/ref-manual/classes.rst | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
documentation/ref-manual/classes.rst +17 -2
index 2338ef6b3..d216f8843 100644
@@ -2439,8 +2439,23 @@ is installed with the :ref:`pip_install_wheel <ref-classes-pip_install_wheel>` c
 =======================
 
 The ``setuptools3`` class supports Python version 3.x extensions that
-use build systems based on ``setuptools``. If your recipe uses these
-build systems, the recipe needs to inherit the ``setuptools3`` class.
+use build systems based on ``setuptools`` (e.g. only have a ``setup.py`` and
+have not migrated to the official ``pyproject.toml`` format). If your recipe
+uses these build systems, the recipe needs to inherit the ``setuptools3`` class.
+
+   .. note::
+
+      ``setuptools3`` ``do_compile`` now calls `setup.py bdist_wheel` to
+      build the ``wheel`` binary package format
+      (See `PEP-427 <https://www.python.org/dev/peps/pep-0427/>`__).
+      A consequence of this is that legacy software still using deprecated
+      `distutils` from the Python standard library cannot be packaged as
+      ``wheels`. A common solution is the replace
+      ``from distutils.core import setup`` with ``from setuptools import setup``.
+
+     ``setuptools3`` ``do_install`` now calls ``pip install`` to install
+     the ``wheel`` binary package. In current versions of ``setuptools`` the
+     legacy ``setup.py install`` method is deprecated.
 
 .. _ref-classes-setuptools3-base:
 
Signature · 1 line
2.30.2