[Buildroot] [PATCH 1/2] package/pkg-python: add setup.cfg-only setuptools project support

Yegor Yefremov yegorslists at googlemail.com
Tue May 10 12:15:43 UTC 2022


Hi James,

On Mon, May 9, 2022 at 3:09 AM James Hilliard <james.hilliard1 at gmail.com> wrote:
>
> Some projects have been removing their setup.py shims under the
> assumption that they are not needed due to setuptools being usable
> via pep517, however this is not actually the case as it is not
> possible to bootstrap setuptools without setup.py style builds as
> setuptools has a dependency on wheel when being used via pep517
> which is itself not installable via pep517 as that would create a
> dependency cycle between wheel and setuptools(which means wheel
> itself must use a legacy setup.py build/installation for itself).
>
> In addition our pep517 toolchain itself requires setuptools for
> building/installing dependencies, although it would appear these
> dependencies will eventually move to flit. Until this is resolved
> we must use setup.py style builds for setuptools packages.
>
> Since it is not yet possible to convert setup.py based setuptools
> builds to pep517 based setuptools builds we simply need to execute
> the setuptools shim code directly if the setup.py file is missing.
>
> See:
> https://setuptools.pypa.io/en/latest/setuptools.html#setup-cfg-only-projects
>
> Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>

Tested-by: Yegor Yefremov <yegorslists at googlemail.com>

Regards,
Yegor

> ---
>  package/pkg-python.mk | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/package/pkg-python.mk b/package/pkg-python.mk
> index 452fa0d3ea..5794e3a195 100644
> --- a/package/pkg-python.mk
> +++ b/package/pkg-python.mk
> @@ -86,6 +86,9 @@ PKG_PYTHON_SETUPTOOLS_ENV = \
>         $(PKG_PYTHON_ENV) \
>         SETUPTOOLS_USE_DISTUTILS=stdlib
>
> +PKG_PYTHON_SETUPTOOLS_CMD = \
> +       $(if $(wildcard $($(PKG)_BUILDDIR)/setup.py),setup.py,-c 'from setuptools import setup;setup()')
> +
>  PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \
>         --install-headers=/usr/include/python$(PYTHON3_VERSION_MAJOR) \
>         --prefix=/usr \
> @@ -180,13 +183,13 @@ endif
>  else ifeq ($$($(2)_SETUP_TYPE),setuptools)
>  ifeq ($(4),target)
>  $(2)_BASE_ENV = $$(PKG_PYTHON_SETUPTOOLS_ENV)
> -$(2)_BASE_BUILD_CMD = setup.py build
> -$(2)_BASE_INSTALL_TARGET_CMD = setup.py install --no-compile $$(PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS)
> -$(2)_BASE_INSTALL_STAGING_CMD = setup.py install $$(PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS)
> +$(2)_BASE_BUILD_CMD = $$(PKG_PYTHON_SETUPTOOLS_CMD) build
> +$(2)_BASE_INSTALL_TARGET_CMD = $$(PKG_PYTHON_SETUPTOOLS_CMD) install --no-compile $$(PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS)
> +$(2)_BASE_INSTALL_STAGING_CMD = $$(PKG_PYTHON_SETUPTOOLS_CMD) install $$(PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS)
>  else
>  $(2)_BASE_ENV = $$(HOST_PKG_PYTHON_SETUPTOOLS_ENV)
> -$(2)_BASE_BUILD_CMD = setup.py build
> -$(2)_BASE_INSTALL_CMD = setup.py install $$(HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS)
> +$(2)_BASE_BUILD_CMD = $$(PKG_PYTHON_SETUPTOOLS_CMD) build
> +$(2)_BASE_INSTALL_CMD = $$(PKG_PYTHON_SETUPTOOLS_CMD) install $$(HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS)
>  endif
>  else ifneq ($$(filter flit pep517,$$($(2)_SETUP_TYPE)),)
>  ifeq ($(4),target)
> --
> 2.25.1
>



More information about the buildroot mailing list