#71 Make specfile more universal with %{python3_pkgversion} bcond main_python
Closed 2 years ago by churchyard. Opened 3 years ago by lbalhar.
rpms/ lbalhar/python-pip compatibility  into  rawhide

file modified
+40 -17
@@ -12,6 +12,11 @@ 

  %bcond_without doc

  %endif

  

+ # Similar to what we have in pythonX.Y.spec files.

+ # If enabled, provides unversioned executables and other stuff.

+ # Disable it if you build this package in an alternative stack.

+ %bcond_without main_python

+ 

  %global srcname pip

  %global base_version 21.0.1

  %global upstream_version %{base_version}%{?prerel}
@@ -206,12 +211,13 @@ 

  Recommends:     python%{python3_pkgversion}-setuptools

  

  # Virtual provides for the packages bundled by pip:

- %{bundled 3}

+ %{bundled %{python3_pkgversion}}

  

+ %if %{with main_python}

  Provides:       pip = %{version}-%{release}

- Conflicts:      python-pip < %{version}-%{release}

+ %endif

  

- %{crypt_compat_recommends 3}

+ %{crypt_compat_recommends %{python3_pkgversion}}

  

  %description -n python%{python3_pkgversion}-%{srcname}

  pip is a package management system used to install and manage software packages
@@ -237,10 +243,10 @@ 

  

  # Virtual provides for the packages bundled by pip:

  %{bundled 2}

- %{bundled 3}

+ %{bundled %{python3_pkgversion}}

  

  %{crypt_compat_recommends 2}

- %{crypt_compat_recommends 3}

+ %{crypt_compat_recommends %{python3_pkgversion}}

  

  %description wheel

  A Python wheel of pip to use with venv.
@@ -295,10 +301,13 @@ 

  pushd docs/build/man

  install -d %{buildroot}%{_mandir}/man1

  for MAN in *1; do

- install -pm0644 $MAN %{buildroot}%{_mandir}/man1/$MAN

- for pip in "pip3" "pip-3" "pip%{python3_version}" "pip-%{python3_version}"; do

- echo ".so $MAN" > %{buildroot}%{_mandir}/man1/${MAN/pip/$pip}

+ install -pm0644 $MAN %{buildroot}%{_mandir}/man1/${MAN/pip/pip-%{python3_version}}

+ echo ".so ${MAN/pip/pip-%{python3_version}}" > %{buildroot}%{_mandir}/man1/${MAN/pip/pip%{python3_version}}

+ %if %{with main_python}

+ for pip in "pip" "pip3" "pip-3"; do

+ echo ".so ${MAN/pip/pip-%{python3_version}}" > %{buildroot}%{_mandir}/man1/${MAN/pip/$pip}

  done

+ %endif

  done

  popd

  %endif
@@ -311,18 +320,28 @@ 

  mkdir -p %{buildroot}%{bashcompdir}

  PYTHONPATH=%{buildroot}%{python3_sitelib} \

      %{buildroot}%{_bindir}/pip completion --bash \

-     > %{buildroot}%{bashcompdir}/pip3

+     > %{buildroot}%{bashcompdir}/pip-%{python3_pkgversion}

  

- # Make bash completion apply to all the 5 symlinks we install

+ # Make bash completion apply to all symlinks we install

+ %if %{with main_python}

  sed -i -e "s/^\\(complete.*\\) pip\$/\\1 pip pip{,-}{3,%{python3_version}}/" \

-     -e s/_pip_completion/_pip3_completion/ \

-     %{buildroot}%{bashcompdir}/pip3

- 

+     -e s/_pip_completion/_pip%{python3_pkgversion}_completion/ \

+     %{buildroot}%{bashcompdir}/pip-%{python3_pkgversion}

+ %else

+ sed -i -e "s/^\\(complete.*\\) pip\$/\\1 pip{,-}%{python3_version}/" \

+     -e s/_pip_completion/_pip%{python3_pkgversion}_completion/ \

+     %{buildroot}%{bashcompdir}/pip-%{python3_pkgversion}

+ %endif

  

- # Provide symlinks to executables to comply with Fedora guidelines for Python

  ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version}

- ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3

  

+ # Add symlinks or remove unversioned executables based on main_python bcond

+ %if %{with main_python}

+ ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3

+ %else

+ rm %{buildroot}%{_bindir}/pip

+ rm  %{buildroot}%{_bindir}/pip3

+ %endif

  

  # Make sure the INSTALLER is not pip and remove RECORD

  # %%pyproject macros do this for all packages
@@ -370,19 +389,23 @@ 

  %license LICENSE.txt

  %doc README.rst

  %if %{with doc}

+ %if %{with main_python}

  %{_mandir}/man1/pip.*

+ %{_mandir}/man1/pip3-*.*

+ %endif

  %{_mandir}/man1/pip-*.*

  %{_mandir}/man1/pip3.*

- %{_mandir}/man1/pip3-*.*

  %endif

+ %if %{with main_python}

  %{_bindir}/pip

  %{_bindir}/pip3

  %{_bindir}/pip-3

+ %endif

  %{_bindir}/pip%{python3_version}

  %{_bindir}/pip-%{python3_version}

  %{python3_sitelib}/pip*

  %dir %{bashcompdir}

- %{bashcompdir}/pip3

+ %{bashcompdir}/pip-%{python3_pkgversion}

  

  %if %{with doc}

  %files doc

This one is more complex because of a lot of executables and man pages but it seems to work well. The main idea is to always ship pipX.Y and pip-X.Y and only add pipX and pip-X for the main package. This applies to executables, man pages, and also bash completion definitions. All three mentioned groups tested manually.

I don't understand why is the pip provide replaced with pip-%{python3_pkgversion}. Is that a typo?

rebased onto 75c26d7de12cf5aa6c8510767ca53d87cd65f7a5

3 years ago

I don't understand why is the pip provide replaced with pip-%{python3_pkgversion}. Is that a typo?

Fixed. Would it make sense to add a versioned provides so non-main package would provide something similar?

Build succeeded.

Fixed. Would it make sense to add a versioned provides so non-main package would provide something similar?

The same question might be applied to tox.

What kind of versioned provides?

What kind of versioned provides?

pip-%{python3_pkgversion} = %{version}-%{release} or better pip-%{python3_version} = %{version}-%{release} — mean as a substitution for missing unversioned provide in an alternative stack.

The reason for providing pip is that we expect some users might try to run dnf install pip.

Do you expect some people to run dnf install pip-3.9? For me, that seem rather far-fetched, but frankly, it's only based on my own way of thinking, no data.

The reason for providing pip is that we expect some users might try to run dnf install pip.

Do you expect some people to run dnf install pip-3.9? For me, that seem rather far-fetched, but frankly, it's only based on my own way of thinking, no data.

I don't. From my point of view, there is no big difference between dnf install python3.11-pip and dnf install pip-3.11 so I'm fine to just omit this provide from non-main_python build.

rebased onto 64d4646

3 years ago

Build succeeded.

Not sure if this is still needed or wanted.

I never wanted it. No idea if it is needed. Is suppose it might be needed when we decide to import this to RHEL 9 Python 3.XY. But we might as well do that there :/

This has long diverged. Let's close ti and only restart if needed when we import this to RHEL 9 python3.X thing.

Pull-Request has been closed by churchyard

2 years ago