diff mbox series

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

Message ID 20220509010917.1485280-1-james.hilliard1@gmail.com
State Accepted
Headers show
Series [1/2] package/pkg-python: add setup.cfg-only setuptools project support | expand

Commit Message

James Hilliard May 9, 2022, 1:09 a.m. UTC
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@gmail.com>
---
 package/pkg-python.mk | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Yegor Yefremov May 10, 2022, 12:15 p.m. UTC | #1
Hi James,

On Mon, May 9, 2022 at 3:09 AM James Hilliard <james.hilliard1@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@gmail.com>

Tested-by: Yegor Yefremov <yegorslists@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
>
Arnout Vandecappelle May 13, 2022, 10:07 p.m. UTC | #2
On 09/05/2022 03:09, James Hilliard 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).

  I found this explanation a bit confusing, but I *think* you're saying "We 
can't simply always use the 'from setuptools import setup' approach".

  Anyway, applied both to master, thanks.

  Regards,
  Arnout

> 
> 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@gmail.com>
> ---
>   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)
diff mbox series

Patch

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)