cygclass python-wheel setup.cfg-only projects
Jon Turney
jon.turney@dronecode.org.uk
Sun Dec 4 14:55:52 GMT 2022
On 02/12/2022 12:10, Jon Turney wrote:
> On 01/12/2022 22:20, Libor Ukropec wrote:
>> Hello,
>>
>> I have question to cygclass python-wheel. It seems that setup.py is
>> being omited in some python packages (here I faced it in the
>> python-fasteners) and as described here:
>> https://setuptools.pypa.io/en/latest/setuptools.html , chapter
>> "setup.cfg-only projects"
>>
>> > If setup.py is missing from the project directory when a PEP 517
>> build is invoked,
>> > setuptools emulates a dummy setup.py file containing only a
>> setuptools.setup() call.
>>
>> Currently the cyglass requires the setup.py being present, otherwise
>> it throws error "No Python Distutils module detected"
>>
>> IMHO would be nice if the cygclass handle this case. Or should I
>> create a patch that inserts empty setup.py module instead?
>
> Yeah, it seems this is definitely something that needs updating in
> cygport, so thanks for pointing that out.
>
> It's fairly straightforward to drop the check at [1], or perhaps it's
> more appropriate to change it to check for either setup.py or setup.cfg?
>
> But then we want to run 'python -msetuptools.launch setup.py
> bdist_wheel' to build the wheel.
>
> In a very quick bit of research, it' seems the modern equivalent would
> be something like 'python -m build --wheel', but we don't seem to have a
> python-build package?
The other alternative seems to be 'pip wheel'
Attached is a cygport patch which uses that for the setup.py-less case.
(possibly we could use it in all cases, but I'm being conservative with
this change)
> I'm not very familiar with the evolving state of python packaging, so I
> think I may need a bit of help getting this right!
-------------- next part --------------
From a44b2e970293b34062da61844f7071fae70a230c Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
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
More information about the Cygwin-apps
mailing list