fedora-python / pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE or to generate SRPM.
MIT License
128 stars 39 forks source link

Errors with packages named python-* #66

Closed hroncok closed 7 years ago

hroncok commented 8 years ago

Take a package that is called python-something (on Python level, i.e. on PyPI) and run it trough pyp2rpm, tak for example python-stdnum, this is the current output (shortened where not relevant):

%global pypi_name python-stdnum

Name:           python-stdnum

Source0:        https://files.pythonhosted.org/packages/source/p/%{pypi_name}/%{pypi_name}-%{version}.tar.gz

%package -n     python2-stdnum
%{?python_provide:%python_provide python2-%{pypi_name}}
%description -n python2-stdnum

%package -n     python3-stdnum
%{?python_provide:%python_provide python3-%{pypi_name}}
%description -n python3-stdnum

%package -n python-%{pypi_name}-doc
%description -n python-%{pypi_name}-doc

%files -n python2-stdnum

%files -n python3-stdnum

%files -n python-%{pypi_name}-doc

The important thing here is that pyp2rpm somewhere knows the RPM subpackages should be pythonX-stdnum and not pythonX-python-stdnum, but it does so without honoring macros and does so not in the %python_provide macros, resulting in following provides:

python2-stdnum:

python3-stdnum:

Also, note the python-python-stdnum-doc package.

The correct resolution here would be to set %pypi_name just to stdnum and change the bits where needed to be chnaged. However, that would be a bit false, because the PyPI name is not just stdnum, so maybe rename the macro?

This is the proposed spec:

%global srcname stdnum

Name:           python-%{srcname}

Source0:        https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz

%package -n     python2-%{srcname}
%{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname}

%package -n     python3-%{srcname}
%{?python_provide:%python_provide python3-%{srcname}}
%description -n python3-%{srcname}

%package -n python-%{srcname}-doc
%description -n python-%{srcname}-doc

%files -n python2-%{srcname}

%files -n python3-%{srcname}

%files -n python-%{srcname}-doc
mcyprian commented 8 years ago

We could use macroed_pkg_name filter that is used to generate global name and names of the packages. Result for normal packages would be unchanged and %{?python_provide:%python_provide python3-stdnum} would appear there in corner cases like python-stdnum.

hroncok commented 8 years ago

Based on the commit, i don't think this addresses all the related issues (what about the doc subpackage?). I haven't have time to test it yet, but it certainly seems so based on the commit itself.

mcyprian commented 8 years ago

Yes, you are right. I was probably focused on the provides too much :) I think the main issue is now fixed. Macros aren't used in the spec file, but there isn't so many packages like this one. Do you think this is an acceptable solution?

mcyprian commented 8 years ago

pyp2rpm should ideally use macros in corner cases like python-stdnum.