#66 Implement %pyproject_extras_subpkg
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros pyproject_extras_subpkg  into  master

file modified
+19 -3
@@ -11,6 +11,7 @@ 

  %_pyproject_builddir .pyproject-builddir

  

  %pyproject_files %{_builddir}/pyproject-files

+ %pyproject_ghost_distinfo %{_builddir}/pyproject-ghost-distinfo

  

  %pyproject_wheel() %{expand:\\\

  export TMPDIR="${PWD}/%{_pyproject_builddir}"
@@ -28,15 +29,30 @@ 

    pathfix.py -pni "%{__python3}" -k%{?py3_shbang_opts: -a%{py3_shbang_opts_nodash}} %{buildroot}%{_bindir}/*

    rm -rfv %{buildroot}%{_bindir}/__pycache__

  fi

+ rm -f %{pyproject_ghost_distinfo}

  if [ -d %{buildroot}%{python3_sitelib} ]; then

-   sed -i 's/pip/rpm/' %{buildroot}%{python3_sitelib}/*.dist-info/INSTALLER

+   for distinfo in %{buildroot}%{python3_sitelib}/*.dist-info; do

+     echo "%ghost ${distinfo#%{buildroot}}" >> %{pyproject_ghost_distinfo}

+     sed -i 's/pip/rpm/' ${distinfo}/INSTALLER

+   done

  fi

- if [ -d %{buildroot}%{python3_sitearch} ]; then

-   sed -i 's/pip/rpm/' %{buildroot}%{python3_sitearch}/*.dist-info/INSTALLER

+ if [ %{buildroot}%{python3_sitearch} != %{buildroot}%{python3_sitelib} ] && [ -d %{buildroot}%{python3_sitearch} ]; then

+   for distinfo in %{buildroot}%{python3_sitearch}/*.dist-info; do

+     echo "%ghost ${distinfo#%{buildroot}}" >> %{pyproject_ghost_distinfo}

+     sed -i 's/pip/rpm/' ${distinfo}/INSTALLER

+   done

+ fi

+ lines=$(wc -l %{pyproject_ghost_distinfo} | cut -f1 -d" ")

+ if [ $lines -ne 1 ]; then

+   echo -e "\\n\\nWARNING: %%%%pyproject_extras_subpkg won't work without explicit -i or -F, found $lines dist-info directories.\\n\\n" >/dev/stderr

+   rm %{pyproject_ghost_distinfo}  # any attempt to use this will fail

  fi

  }

  

  

+ %python_extras_subpkg(n:i:f:F) %{expand:%{?python_extras_subpkg:%{python_extras_subpkg%{?!-i:%{?!-f:%{?!-F: -f %{pyproject_ghost_distinfo}}}} %**}}}

I might be totally lost, but why are you defining %python_extras_subpkg here and not %pyproject_extras_subpkg?

Also, it took me longer than I care to admit to understand the %{?!-i:%{?!-f:%{?!-F: -f ... part and its reasoning, so it would be nice to have an explanatory comment.

+ 

+ 

  %pyproject_save_files() %{expand:\\\

  %{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\

    --output "%{pyproject_files}" \\

file modified
+4 -1
@@ -6,7 +6,7 @@ 

  

  # Keep the version at zero and increment only release

  Version:        0

- Release:        19%{?dist}

+ Release:        20%{?dist}

  

  # Macro files

  Source001:      macros.pyproject
@@ -101,6 +101,9 @@ 

  %license LICENSE

  

  %changelog

+ * Wed Jul 29 2020 Miro Hrončok <mhroncok@redhat.com> - 0-20

+ - Implement %%pyproject_extras_subpkg

+ 

  * Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0-19

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

  

@@ -0,0 +1,55 @@ 

+ Name:           python-setuptools_scm

+ Version:        3.5.0

+ Release:        0%{?dist}

+ Summary:        The blessed package to manage your versions by SCM tags

+ License:        MIT

+ URL:            https://github.com/pypa/setuptools_scm/

+ Source0:        %{pypi_source setuptools_scm}

+ 

+ BuildArch:      noarch

+ BuildRequires:  python3-devel

+ BuildRequires:  pyproject-rpm-macros

+ 

+ %description

+ Here we test that %%pyproject_extras_subpkg works and generates

+ setuptools_scm[toml] extra subpackage.

+ 

+ Note that it only works on Fedora 33+.

+ 

+ %package -n python3-setuptools_scm

+ Summary:        %{summary}

+ 

+ %description -n python3-setuptools_scm

+ ...

+ 

+ %pyproject_extras_subpkg -n python3-setuptools_scm toml

+ 

+ 

+ %prep

+ %autosetup -p1 -n setuptools_scm-%{version}

+ 

+ 

+ %generate_buildrequires

+ %pyproject_buildrequires

+ 

+ 

+ %build

+ %pyproject_wheel

+ 

+ 

+ %install

+ %pyproject_install

+ %pyproject_save_files setuptools_scm

+ 

+ 

+ %check

+ # Internal check for our macros

+ # making sure that %%{pyproject_ghost_distinfo} has the right content

+ test -f %{pyproject_ghost_distinfo}

+ test "$(cat %{pyproject_ghost_distinfo})" == "%ghost %{python3_sitelib}/setuptools_scm-%{version}.dist-info"

+ 

+ 

+ %files -n python3-setuptools_scm -f %{pyproject_files}

+ %doc README.rst

+ %doc CHANGELOG.rst

+ %license LICENSE

file modified
+3
@@ -40,6 +40,9 @@ 

      - mistune:

          dir: .

          run: ./mocktest.sh python-mistune

+     - setuptools_scm:

+         dir: .

+         run: ./mocktest.sh python-setuptools_scm

      required_packages:

      - mock

      - rpmdevtools

no initial comment

rebased onto 3be98927bd2c86d425f4e9d7e5d8f08839a1dfa6

3 years ago

rebased onto 16d48a0c6f751c9a900f136bfb7bb1bf0a2a4423

3 years ago

Build succeeded.

Should %pyproject_extras_subpkg take -f as well? It would be easier to document if it took the same arguments as %python_extras_subpkg.

I intend to not document %pyproject_ghost_distinfo, keeping it an implementation detail. Is that OK?

It could take -f as well, yes.

%pyproject_ghost_distinfo is indeed an implementation detail.

rebased onto cb4e43c

3 years ago

Build succeeded.

Fedora CI / Jenkins fails to run mock:

Start: dnf install
ERROR: Command failed: 
 # /usr/bin/systemd-nspawn -q -M 8a90cecbb9b2498fb83beb71fd0488a6 -D /var/lib/mock/fedora-rawhide-x86_64-bootstrap/root -a --capability=cap_ipc_lock --bind=/tmp/mock-resolv.omgskivc:/etc/resolv.conf --console=pipe --setenv=TERM=vt100 --setenv=SHELL=/bin/bash --setenv=HOME=/var/lib/mock/fedora-rawhide-x86_64/root/installation-homedir --setenv=HOSTNAME=mock --setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --setenv=PROMPT_COMMAND=printf "\033]0;<mock-chroot>\007" --setenv=PS1=<mock-chroot> \s-\v\$  --setenv=LANG=C.UTF-8 --setenv=LC_MESSAGES=C.UTF-8 /usr/bin/dnf --installroot /var/lib/mock/fedora-rawhide-x86_64/root/ --releasever 33 --enablerepo local --setopt=deltarpm=False --allowerasing --disableplugin=local --disableplugin=spacewalk install @buildsys-build --setopt=tsflags=nocontexts
Failed to register machine: Connection timed out

Will try again to see if this is something to report as a bug. [citest]

In the meantime, Zuul works as normally.

Build succeeded.

+1, the patch and tests look good.

Metadata Update from @churchyard:
- Request assigned

3 years ago

I'Ve opened https://src.fedoraproject.org/rpms/pyproject-rpm-macros/pull-request/69 and https://src.fedoraproject.org/rpms/pyproject-rpm-macros/pull-request/70 to ensure this does nto break the CI on Fedora without Python extras. If the CIs pass, I'll merge all.

Pull-Request has been merged by churchyard

3 years ago

I might be totally lost, but why are you defining %python_extras_subpkg here and not %pyproject_extras_subpkg?

Also, it took me longer than I care to admit to understand the %{?!-i:%{?!-f:%{?!-F: -f ... part and its reasoning, so it would be nice to have an explanatory comment.

I might be totally lost, but why are you defining %python_extras_subpkg here and not %pyproject_extras_subpkg?

You are not lost, this is a mistake. OMG. Thanks.