public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* cygclass python-wheel setup.cfg-only projects
@ 2022-12-01 22:20 Libor Ukropec
  2022-12-02 12:10 ` Jon Turney
  0 siblings, 1 reply; 5+ messages in thread
From: Libor Ukropec @ 2022-12-01 22:20 UTC (permalink / raw)
  To: cygwin-apps

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?

Thank you,
Libor

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cygclass python-wheel setup.cfg-only projects
  2022-12-01 22:20 cygclass python-wheel setup.cfg-only projects Libor Ukropec
@ 2022-12-02 12:10 ` Jon Turney
  2022-12-04 14:55   ` Jon Turney
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Turney @ 2022-12-02 12:10 UTC (permalink / raw)
  To: Libor Ukropec, cygwin-apps

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?

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!

[1] 
https://cygwin.com/git/?p=cygwin-apps/cygport.git;a=blob;f=cygclass/python-wheel.cygclass;h=b6ed68b4acda83ada549f898b9ebd611d8a4506f;hb=HEAD#l158


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cygclass python-wheel setup.cfg-only projects
  2022-12-02 12:10 ` Jon Turney
@ 2022-12-04 14:55   ` Jon Turney
  2022-12-06  0:20     ` Libor Ukropec
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Turney @ 2022-12-04 14:55 UTC (permalink / raw)
  To: cygwin-apps, Libor Ukropec

[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]

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!

[-- Attachment #2: 0001-python-wheel-Handle-projects-without-a-setup.py.patch --]
[-- Type: text/plain, Size: 3107 bytes --]

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cygclass python-wheel setup.cfg-only projects
  2022-12-04 14:55   ` Jon Turney
@ 2022-12-06  0:20     ` Libor Ukropec
  2022-12-11 13:58       ` Jon Turney
  0 siblings, 1 reply; 5+ messages in thread
From: Libor Ukropec @ 2022-12-06  0:20 UTC (permalink / raw)
  To: cygwin-apps

Dne 04.12.2022 v 15:55 Jon Turney via Cygwin-apps napsal(a):
> 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!

Hi Jon,

definitely you did not need a help - I did a test on python-fasteners

before your patch:

     $ cygport python-fasteners.cygport download all check
     *** Warning: LICENSE not defined
     >>> Preparing python-fasteners-0.17.3-1.noarch
     >>> Unpacking source 0.17.3.tar.gz
     >>> Preparing working source directory
     >>> Compiling python-fasteners-0.17.3-1.noarch
     *** ERROR: No Python Distutils module detected

applying your patch, all works fine:

     [...]
     >>> Creating source patches
      0 files changed
     >>> Creating source package
     python-fasteners-0.17.3-1.src/
     python-fasteners-0.17.3-1.src/0.17.3.tar.gz
     python-fasteners-0.17.3-1.src/python-fasteners.cygport

     >>> python36-fasteners requires: python36
     >>> python37-fasteners requires: python37
     >>> python38-fasteners requires: python38
     >>> python39-fasteners requires: python39
     >>> python3-fasteners requires:  python39-fasteners
     >>> Testing python-fasteners-0.17.3-1.noarch
     *** Info: No testsuite detected.

Success :)

So I confirm it works at least for this one use case.

Regards,
Libor

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cygclass python-wheel setup.cfg-only projects
  2022-12-06  0:20     ` Libor Ukropec
@ 2022-12-11 13:58       ` Jon Turney
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Turney @ 2022-12-11 13:58 UTC (permalink / raw)
  To: Libor Ukropec, cygwin-apps

On 06/12/2022 00:20, Libor Ukropec via Cygwin-apps wrote:
> Dne 04.12.2022 v 15:55 Jon Turney via Cygwin-apps napsal(a):
>>>
>>> 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!
> 
> Hi Jon,
> 
> definitely you did not need a help - I did a test on python-fasteners
> 
[...]

Well, I'm not quite so confident.  Just because it works for one module, 
doesn't mean I've got it right.

But this change seems pretty low-impact since it should only change the 
behaviour for setup.py-less modules, which can't build at all presently, 
so I included it in cygport 0.35.5

> Success :)
> 
> So I confirm it works at least for this one use case.
> 

Thanks for testing.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-11 13:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 22:20 cygclass python-wheel setup.cfg-only projects Libor Ukropec
2022-12-02 12:10 ` Jon Turney
2022-12-04 14:55   ` Jon Turney
2022-12-06  0:20     ` Libor Ukropec
2022-12-11 13:58       ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).