From a44b2e970293b34062da61844f7071fae70a230c Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 2 Dec 2022 11:50:33 +0000 Subject: [PATCH cygport] python-wheel: Handle projects without a setup.py Since setuptools 40.9.0, projects can have just a setup.cfg, and a default setup.py is emulated. Rather than setuptools, use 'pip wheel' to build the wheel. Note: possibly could use pypa build module to do the build, but we need pip for the install anyhow? --- cygclass/python-wheel.cygclass | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/cygclass/python-wheel.cygclass b/cygclass/python-wheel.cygclass index b6ed68b..4d97945 100644 --- a/cygclass/python-wheel.cygclass +++ b/cygclass/python-wheel.cygclass @@ -24,9 +24,10 @@ #****h* Cygclasses/python-wheel.cygclass # DESCRIPTION # Wheels are the new standard for installing Python libraries and programs. -# The build is defined by a setup.py file in the top source directory, which -# controls the installation of files and the building of C Python extensions. -# Many such packages are hosted on the Python Package Index (PyPI). +# The build is defined by a PEP 517 conformant source tree, or by a top-level +# setup.py file, which controls the installation of files and the building of C +# Python extensions. Many such packages are hosted on the Python Package Index +# (PyPI). # # This cygclass handles the building of wheel-based Python module packages # for multiple Python versions simultaneously. @@ -148,23 +149,28 @@ fi # SYNOPSIS # python_wheel_compile [OPTIONS] # DESCRIPTION -# Runs the setup.py 'bdist_wheel' command, to which any arguments are passed. -#**** +# Runs 'pip wheel', or the setup.py 'bdist_wheel' command, to which any +# arguments are passed. **** python_wheel_compile() { local ver - if [ ! -e setup.py ] + if [ ! -e setup.py ] && [ ! -e setup.cfg ] then - error "No Python Distutils module detected" + error "No Python Distutils module detected in source tree" fi for ver in ${PYTHON_WHEEL_VERSIONS//:/ } do [ ! -d build/lib ] || find build/lib -delete - # setuptools.launch imports setuptools hooks regardles of setup.py if [ ! -f dist/*-py2.py3*-none-any.whl -a ! -f dist/*py${ver:0:1}-none-any.whl ] then - /usr/bin/python${ver} -msetuptools.launch setup.py bdist_wheel "${@}" || error "setup.py bdist_wheel failed" + if [ ! -e setup.py ] + then + pip${ver} wheel --no-deps -w dist . || error "pip${ver} wheel failed" + else + # setuptools.launch imports setuptools hooks regardles of setup.py + /usr/bin/python${ver} -msetuptools.launch setup.py bdist_wheel "${@}" || error "setup.py bdist_wheel failed" + fi fi done } @@ -178,9 +184,9 @@ python_wheel_compile() { python_wheel_install() { local ver whl - if [ ! -e setup.py ] + if [ ! -e setup.py ] && [ ! -e setup.cfg ] then - error "No Python Distutils module detected" + error "No Python Distutils module detected in source tree" fi for ver in ${PYTHON_WHEEL_VERSIONS//:/ } -- 2.38.1