[libvirt-python PATCH] build: Adapt to PEP 625 distribution file naming

Jiri Denemark via Devel posted 1 patch 3 weeks, 3 days ago
Failed in applying to current master (apply log)
.gitlab-ci.yml         |  4 ++--
Makefile               |  2 +-
libvirt-python.spec.in | 10 ++++++++--
3 files changed, 11 insertions(+), 5 deletions(-)
[libvirt-python PATCH] build: Adapt to PEP 625 distribution file naming
Posted by Jiri Denemark via Devel 3 weeks, 3 days ago
The version of setuptools shipped by Fedora 42 is PEP 625 compliant,
which requires distribution files to contain a normalized package name.
Thus the generated tarball is called libvirt_python-$VER.tar.gz rather
than libvirt-python-$VER.tar.gz created by older setuptools. The source
directory inside the tarball follows the same naming.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 .gitlab-ci.yml         |  4 ++--
 Makefile               |  2 +-
 libvirt-python.spec.in | 10 ++++++++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bc4ff48..1267c47 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -34,7 +34,7 @@ stages:
     - if test -x /usr/bin/rpmbuild && test "$RPM" != "skip" ;
       then
           unset CFLAGS ;
-          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt-python*tar.gz ;
+          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt[-_]python*tar.gz ;
           mv rpmbuild/RPMS/x86_64/ libvirt-python-rpms ;
       fi
 
@@ -51,7 +51,7 @@ stages:
     - if test -x /usr/bin/rpmbuild && test "$RPM" != "skip" ;
       then
           unset CFLAGS ;
-          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt-python*tar.gz ;
+          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt[-_]python*tar.gz ;
           mv rpmbuild/RPMS/x86_64/ libvirt-python-rpms ;
       fi
 
diff --git a/Makefile b/Makefile
index 925af40..0b2af28 100644
--- a/Makefile
+++ b/Makefile
@@ -19,4 +19,4 @@ test: all
 	tox
 
 rpm: all
-	rpmbuild -ta dist/libvirt-python-$(shell tr -d '\n' < VERSION).tar.gz
+	rpmbuild -ta dist/libvirt[-_]python-$(shell tr -d '\n' < VERSION).tar.gz
diff --git a/libvirt-python.spec.in b/libvirt-python.spec.in
index e260eaf..dd0c71b 100644
--- a/libvirt-python.spec.in
+++ b/libvirt-python.spec.in
@@ -12,11 +12,17 @@
     %define supported_platform 0
 %endif
 
+%if 0%{?rhel} || 0%{?fedora} < 42
+    %define dist_name %{name}
+%else
+    %define dist_name libvirt_python
+%endif
+
 Summary: The libvirt virtualization API python3 binding
 Name: libvirt-python
 Version: @VERSION@
 Release: 1%{?dist}
-Source0: https://libvirt.org/sources/python/%{name}-%{version}.tar.gz
+Source0: https://libvirt.org/sources/python/%{dist_name}-%{version}.tar.gz
 Url: https://libvirt.org
 License: LGPL-2.1-or-later
 BuildRequires: libvirt-devel == %{version}
@@ -51,7 +57,7 @@ supplied by the libvirt library to use the virtualization capabilities
 of recent versions of Linux (and other OSes).
 
 %prep
-%setup -q
+%setup -q -n %{dist_name}-%{version}
 
 # Unset execute bit for example scripts; it can introduce spurious
 # RPM dependencies, like /usr/bin/python3
-- 
2.51.0
Re: [libvirt-python PATCH] build: Adapt to PEP 625 distribution file naming
Posted by Daniel P. Berrangé via Devel 3 weeks, 3 days ago
On Wed, Sep 10, 2025 at 02:04:39PM +0200, Jiri Denemark via Devel wrote:
> The version of setuptools shipped by Fedora 42 is PEP 625 compliant,
> which requires distribution files to contain a normalized package name.
> Thus the generated tarball is called libvirt_python-$VER.tar.gz rather
> than libvirt-python-$VER.tar.gz created by older setuptools. The source
> directory inside the tarball follows the same naming.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  .gitlab-ci.yml         |  4 ++--
>  Makefile               |  2 +-
>  libvirt-python.spec.in | 10 ++++++++--
>  3 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index bc4ff48..1267c47 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -34,7 +34,7 @@ stages:
>      - if test -x /usr/bin/rpmbuild && test "$RPM" != "skip" ;
>        then
>            unset CFLAGS ;
> -          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt-python*tar.gz ;
> +          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt[-_]python*tar.gz ;
>            mv rpmbuild/RPMS/x86_64/ libvirt-python-rpms ;
>        fi
>  
> @@ -51,7 +51,7 @@ stages:
>      - if test -x /usr/bin/rpmbuild && test "$RPM" != "skip" ;
>        then
>            unset CFLAGS ;
> -          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt-python*tar.gz ;
> +          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt[-_]python*tar.gz ;
>            mv rpmbuild/RPMS/x86_64/ libvirt-python-rpms ;
>        fi
>  
> diff --git a/Makefile b/Makefile
> index 925af40..0b2af28 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -19,4 +19,4 @@ test: all
>  	tox
>  
>  rpm: all
> -	rpmbuild -ta dist/libvirt-python-$(shell tr -d '\n' < VERSION).tar.gz
> +	rpmbuild -ta dist/libvirt[-_]python-$(shell tr -d '\n' < VERSION).tar.gz
> diff --git a/libvirt-python.spec.in b/libvirt-python.spec.in
> index e260eaf..dd0c71b 100644
> --- a/libvirt-python.spec.in
> +++ b/libvirt-python.spec.in
> @@ -12,11 +12,17 @@
>      %define supported_platform 0
>  %endif
>  
> +%if 0%{?rhel} || 0%{?fedora} < 42
> +    %define dist_name %{name}
> +%else
> +    %define dist_name libvirt_python
> +%endif

This isn't correct. The dist name depends on the OS on which we create
the release tarball, not the OS we are building for. IOW, while this
may work in CI, it will break in real builds.

> +
>  Summary: The libvirt virtualization API python3 binding
>  Name: libvirt-python
>  Version: @VERSION@
>  Release: 1%{?dist}
> -Source0: https://libvirt.org/sources/python/%{name}-%{version}.tar.gz
> +Source0: https://libvirt.org/sources/python/%{dist_name}-%{version}.tar.gz
>  Url: https://libvirt.org
>  License: LGPL-2.1-or-later
>  BuildRequires: libvirt-devel == %{version}
> @@ -51,7 +57,7 @@ supplied by the libvirt library to use the virtualization capabilities
>  of recent versions of Linux (and other OSes).
>  
>  %prep
> -%setup -q
> +%setup -q -n %{dist_name}-%{version}
>  
>  # Unset execute bit for example scripts; it can introduce spurious
>  # RPM dependencies, like /usr/bin/python3
> -- 
> 2.51.0
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [libvirt-python PATCH] build: Adapt to PEP 625 distribution file naming
Posted by Jiří Denemark via Devel 3 weeks, 3 days ago
On Wed, Sep 10, 2025 at 13:43:01 +0100, Daniel P. Berrangé wrote:
> On Wed, Sep 10, 2025 at 02:04:39PM +0200, Jiri Denemark via Devel wrote:
> > The version of setuptools shipped by Fedora 42 is PEP 625 compliant,
> > which requires distribution files to contain a normalized package name.
> > Thus the generated tarball is called libvirt_python-$VER.tar.gz rather
> > than libvirt-python-$VER.tar.gz created by older setuptools. The source
> > directory inside the tarball follows the same naming.
> > 
> > Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> > ---
> >  .gitlab-ci.yml         |  4 ++--
> >  Makefile               |  2 +-
> >  libvirt-python.spec.in | 10 ++++++++--
> >  3 files changed, 11 insertions(+), 5 deletions(-)
> > 
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index bc4ff48..1267c47 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -34,7 +34,7 @@ stages:
> >      - if test -x /usr/bin/rpmbuild && test "$RPM" != "skip" ;
> >        then
> >            unset CFLAGS ;
> > -          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt-python*tar.gz ;
> > +          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt[-_]python*tar.gz ;
> >            mv rpmbuild/RPMS/x86_64/ libvirt-python-rpms ;
> >        fi
> >  
> > @@ -51,7 +51,7 @@ stages:
> >      - if test -x /usr/bin/rpmbuild && test "$RPM" != "skip" ;
> >        then
> >            unset CFLAGS ;
> > -          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt-python*tar.gz ;
> > +          rpmbuild --clean --nodeps --define "_topdir $PWD/rpmbuild" -ta dist/libvirt[-_]python*tar.gz ;
> >            mv rpmbuild/RPMS/x86_64/ libvirt-python-rpms ;
> >        fi
> >  
> > diff --git a/Makefile b/Makefile
> > index 925af40..0b2af28 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -19,4 +19,4 @@ test: all
> >  	tox
> >  
> >  rpm: all
> > -	rpmbuild -ta dist/libvirt-python-$(shell tr -d '\n' < VERSION).tar.gz
> > +	rpmbuild -ta dist/libvirt[-_]python-$(shell tr -d '\n' < VERSION).tar.gz
> > diff --git a/libvirt-python.spec.in b/libvirt-python.spec.in
> > index e260eaf..dd0c71b 100644
> > --- a/libvirt-python.spec.in
> > +++ b/libvirt-python.spec.in
> > @@ -12,11 +12,17 @@
> >      %define supported_platform 0
> >  %endif
> >  
> > +%if 0%{?rhel} || 0%{?fedora} < 42
> > +    %define dist_name %{name}
> > +%else
> > +    %define dist_name libvirt_python
> > +%endif
> 
> This isn't correct. The dist name depends on the OS on which we create
> the release tarball, not the OS we are building for. IOW, while this
> may work in CI, it will break in real builds.

Ah, right, originally I changed the spec file unconditionally as I'm
going to create the release tarballs on Fedora 42. But then CI failed...
I guess we'll need to set this when generating .spec from .spec.in :-/

Jirka
Re: [libvirt-python PATCH] build: Adapt to PEP 625 distribution file naming
Posted by Michal Prívozník via Devel 3 weeks, 3 days ago
On 9/10/25 14:04, Jiri Denemark via Devel wrote:
> The version of setuptools shipped by Fedora 42 is PEP 625 compliant,
> which requires distribution files to contain a normalized package name.
> Thus the generated tarball is called libvirt_python-$VER.tar.gz rather
> than libvirt-python-$VER.tar.gz created by older setuptools. The source
> directory inside the tarball follows the same naming.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  .gitlab-ci.yml         |  4 ++--
>  Makefile               |  2 +-
>  libvirt-python.spec.in | 10 ++++++++--
>  3 files changed, 11 insertions(+), 5 deletions(-)

Don't forget to create an MR ;-)

Michal
Re: [libvirt-python PATCH] build: Adapt to PEP 625 distribution file naming
Posted by Pavel Hrdina via Devel 3 weeks, 3 days ago
On Wed, Sep 10, 2025 at 02:04:39PM +0200, Jiri Denemark via Devel wrote:
> The version of setuptools shipped by Fedora 42 is PEP 625 compliant,
> which requires distribution files to contain a normalized package name.
> Thus the generated tarball is called libvirt_python-$VER.tar.gz rather
> than libvirt-python-$VER.tar.gz created by older setuptools. The source
> directory inside the tarball follows the same naming.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  .gitlab-ci.yml         |  4 ++--
>  Makefile               |  2 +-
>  libvirt-python.spec.in | 10 ++++++++--
>  3 files changed, 11 insertions(+), 5 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>