fedora-python / pyp2rpm

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

EPEL7 makes two Python 3 packages with -b3 #178

Closed MrMEEE closed 4 years ago

MrMEEE commented 5 years ago

When running:

scl enable rh-python36 "pyp2rpm -b3 -s -d SPECS/ xmlsec -v1.3.3 -tepel6 --sclize" It get this output??:

%{?scl:%scl_package python-%{pypi_name}}
%{!?scl:%global pkg_name %{name}}

# Created by pyp2rpm-3.3.2
%global pypi_name xmlsec

Name:           %{?scl_prefix}python-%{pypi_name}
Version:        1.3.3
Release:        1%{?dist}
Summary:        Python bindings for the XML Security Library

License:        MIT
URL:            https://github.com/mehcode/python-xmlsec
Source0:        https://files.pythonhosted.org/packages/source/x/%{pypi_name}/%{pypi_name}-%{version}.tar.gz

%{?scl:Requires: %{scl}-runtime}
%{?scl:BuildRequires: %{scl}-runtime}
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-devel
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-setuptools

BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-devel
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig
BuildRequires:  %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-setuptools

%description

%package -n     %{?scl_prefix}python%{python3_pkgversion}-%{pypi_name}
Summary:        Python bindings for the XML Security Library

Requires:       %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
Requires:       %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig

%description -n %{?scl_prefix}python%{python3_pkgversion}-%{pypi_name}

%package -n     %{?scl_prefix}python%{python3_pkgversion}-%{pypi_name}
Summary:        Python bindings for the XML Security Library

Requires:       %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
Requires:       %{?scl_prefix}python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig

%description -n %{?scl_prefix}python%{python3_pkgversion}-%{pypi_name}

%prep
%{?scl:scl enable %{scl} - << \EOF}
set -e
%autosetup -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%{?scl:EOF}

%build
%{?scl:scl enable %{scl} - << \EOF}
set -e
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
%{?scl:EOF}

%install
%{?scl:scl enable %{scl} - << \EOF}
set -e
# Must do the default python version install last because
# the scripts in /usr/bin are overwritten with every setup.py install.
%{__python3} setup.py install --skip-build --root %{buildroot}
%{__python3} setup.py install --skip-build --root %{buildroot}
%{?scl:EOF}

%files -n %{?scl_prefix}python%{python3_pkgversion}-%{pypi_name}
%doc README.rst
%{python3_sitearch}/%{pypi_name}
%{python3_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%files -n %{?scl_prefix}python%{python3_pkgversion}-%{pypi_name}
%doc README.rst
%{python3_sitearch}/%{pypi_name}
%{python3_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%changelog
* Fri Jan 18 2019  - 1.3.3-1
- Initial pscl enable rh-python36 "pyp2rpm -b3 -s -d /home/awx/depends/python3/SPECS/ xmlsec -v1.3.3 -tepel6 --sclize"

This also happens when i'm not using the software collection... also tried without "--sclize", same result, with out scl...

When using the fedora template (-dfedora), this does not happen???

%{?scl:%scl_package python-%{pypi_name}}
%{!?scl:%global pkg_name %{name}}

# Created by pyp2rpm-3.3.2
%global pypi_name xmlsec

Name:           %{?scl_prefix}python-%{pypi_name}
Version:        1.3.3
Release:        1%{?dist}
Summary:        Python bindings for the XML Security Library

License:        MIT
URL:            https://github.com/mehcode/python-xmlsec
Source0:        https://files.pythonhosted.org/packages/source/x/%{pypi_name}/%{pypi_name}-%{version}.tar.gz

%{?scl:Requires: %{scl}-runtime}
%{?scl:BuildRequires: %{scl}-runtime}
BuildRequires:  %{?scl_prefix}python3-devel
BuildRequires:  %{?scl_prefix}python3dist(lxml) >= 3.0
BuildRequires:  %{?scl_prefix}python3dist(pkgconfig)
BuildRequires:  %{?scl_prefix}python3dist(setuptools)

%description

%package -n     %{?scl_prefix}python3-%{pypi_name}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}

Requires:       %{?scl_prefix}python3dist(lxml) >= 3.0
Requires:       %{?scl_prefix}python3dist(pkgconfig)

%description -n %{?scl_prefix}python3-%{pypi_name}

%prep
%{?scl:scl enable %{scl} - << \EOF}
set -e
%autosetup -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%{?scl:EOF}

%build
%{?scl:scl enable %{scl} - << \EOF}
set -e
%py3_build
%{?scl:EOF}

%install
%{?scl:scl enable %{scl} - << \EOF}
set -e
%py3_install
%{?scl:EOF}

%files -n %{?scl_prefix}python3-%{pypi_name}
%license LICENSE
%doc README.rst
%{python3_sitearch}/%{pypi_name}
%{python3_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%changelog
* Fri Jan 18 2019  - 1.3.3-1
- Initial package.
hroncok commented 5 years ago

Could you please also paste the exact output of the epel template without scl option?

MrMEEE commented 5 years ago

pyp2rpm -b3 -s -d /home/awx/depends/python3/SPECS/ xmlsec -v1.3.3 -tepel7

=

# Created by pyp2rpm-3.3.2
%global pypi_name xmlsec

Name:           python-%{pypi_name}
Version:        1.3.3
Release:        1%{?dist}
Summary:        Python bindings for the XML Security Library

License:        MIT
URL:            https://github.com/mehcode/python-xmlsec
Source0:        https://files.pythonhosted.org/packages/source/x/%{pypi_name}/%{pypi_name}-%{version}.tar.gz

BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
BuildRequires:  python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig
BuildRequires:  python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-setuptools

BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
BuildRequires:  python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig
BuildRequires:  python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-setuptools

%description

%package -n     python%{python3_pkgversion}-%{pypi_name}
Summary:        Python bindings for the XML Security Library

Requires:       python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
Requires:       python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig
%description -n python%{python3_pkgversion}-%{pypi_name}

%package -n     python%{python3_pkgversion}-%{pypi_name}
Summary:        Python bindings for the XML Security Library

Requires:       python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-lxml >= 3.0
Requires:       python%{python3_pkgversion}-python%{python%{python3_pkgversion}_pkgversion}-pkgconfig
%description -n python%{python3_pkgversion}-%{pypi_name}

%prep
%autosetup -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info

%build
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build

%install
# Must do the default python version install last because
# the scripts in /usr/bin are overwritten with every setup.py install.
%{__python3} setup.py install --skip-build --root %{buildroot}
%{__python3} setup.py install --skip-build --root %{buildroot}

%files -n python%{python3_pkgversion}-%{pypi_name}
%doc README.rst
%{python3_sitearch}/%{pypi_name}
%{python3_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%files -n python%{python3_pkgversion}-%{pypi_name}
%doc README.rst
%{python3_sitearch}/%{pypi_name}
%{python3_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%changelog
* Fri Jan 18 2019  - 1.3.3-1
MrMEEE commented 5 years ago

Template looks fine:

{{ data.credit_line }}
{% from 'macros.spec' import dependencies, for_python_versions, underscored_or_pypi -%}
%global pypi_name {{ data.name }}
{%- if data.srcname %}
%global srcname {{ data.srcname }}
{%- endif %}

Name:           {{ data.pkg_name|macroed_pkg_name(data.srcname) }}
Version:        {{ data.version }}
Release:        1%{?dist}
Summary:        {{ data.summary }}

License:        {{ data.license }}
URL:            {{ data.home_page }}
Source0:        {{ data.source0|replace(data.name, '%{pypi_name}')|replace(data.version, '%{version}') }}

{%- if not data.has_extension %}
BuildArch:      noarch
{%- endif %}
{%- for pv in data.sorted_python_versions %}
{{ dependencies(data.build_deps, False, pv, data.base_python_version, use_with=False) }}
{%- endfor %}

%description
{{ data.description|truncate(400)|wordwrap }}
{% for pv in data.sorted_python_versions %}
%package -n     {{data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True)}}
Summary:        {{ data.summary }}
{{ dependencies(data.runtime_deps, True, pv, pv, use_with=False) }}
%description -n {{data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True)}}
{{ data.description|truncate(400)|wordwrap }}
{% endfor -%}
{%- if data.sphinx_dir %}
%package -n python-%{pypi_name}-doc
Summary:        {{ data.name }} documentation
%description -n python-%{pypi_name}-doc
Documentation for {{ data.name }}
{%- endif %}

%prep
%autosetup -n {{ data.dirname|replace(data.name, '%{pypi_name}')|replace(data.version, '%{version}')|default('%{pypi_name}-%{version}', true) }}
{%- if data.has_bundled_egg_info %}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
{%- endif %}

%build
{%- for pv in data.sorted_python_versions %}
{% if data.has_extension %}CFLAGS="$RPM_OPT_FLAGS" {% endif %}%{__python{{ pv }}} setup.py build
{%- endfor %}
{%- if data.sphinx_dir %}
# generate html docs
PYTHONPATH=${PWD} {{ "sphinx-build"|script_name_for_python_version(data.base_python_version, False, False) }} {{ data.sphinx_dir }} html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
{%- endif %}

%install
{%- if data.python_versions|length > 0 %}
# Must do the default python version install last because
# the scripts in /usr/bin are overwritten with every setup.py install.
{%- endif %}
{%- for pv in data.python_versions + [data.base_python_version] %}
{%- if pv == data.base_python_version and data.python_versions and data.scripts %}
rm -rf %{buildroot}%{_bindir}/*
{%- endif %}
%{__python{{ pv }}} setup.py install --skip-build --root %{buildroot}
{%- endfor -%}
{% if data.has_test_suite %}

%check
{%- for pv in data.sorted_python_versions %}
%{__python{{ pv }}} setup.py test
{%- endfor %}
{%- endif %}
{% for pv in data.sorted_python_versions %}
%files -n {{ data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True) }}
{%- if data.doc_files %}
%doc {{data.doc_files|join(' ') }}
{%- endif %}
{%- if pv == data.base_python_version %}
{%- for script in data.scripts %}
%{_bindir}/{{ script }}
{%- endfor %}
{%- endif %}
{%- if data.py_modules %}
{%- for module in data.py_modules -%}
{%- if pv == '3' %}
%dir %{python{{ pv }}_sitelib}/__pycache__/
%{python{{ pv }}_sitelib}/__pycache__/*
{%- endif %}
%{python{{ pv }}_sitelib}/{{ data.name | module_to_path(module) }}.py{% if pv != '3'%}*{% endif %}
{%- endfor %}
{%- endif %}
{%- if data.has_extension %}
{%- if data.has_packages %}
{%- for package in data.packages %}
%{python{{ pv }}_sitearch}/{{ package | package_to_path(data.name) }}
{%- endfor %}
{%- endif %}
{%- if data.has_pth %}
%{python{{ pv }}_sitearch}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py?.?-*.pth
{%- endif %}
%{python{{ pv }}_sitearch}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py?.?.egg-info
{%- else %}
{%- if data.has_packages %}
{%- for package in data.packages %}
%{python{{ pv }}_sitelib}/{{ package | package_to_path(data.name) }}
{%- endfor %}
{%- endif %}
{%- if data.has_pth %}
%{python{{ pv }}_sitelib}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py?.?-*.pth
{%- endif %}
%{python{{ pv }}_sitelib}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py?.?.egg-info
{%- endif %}
{% endfor %}
{%- if data.sphinx_dir %}
%files -n python-%{pypi_name}-doc
%doc html
{%- if data.doc_license %}
%license {{data.doc_license|join(' ')}}
{%- endif %}
{% endif %}
%changelog
* {{ data.changelog_date_packager }} - {{ data.version }}-1
- Initial package.
MrMEEE commented 5 years ago

btw. version is the newest installed from git 2 days ago...

hroncok commented 5 years ago

I can reproduce this.

The epel template uses Python 2 as default base and Python 3 as default additional.

Without -b3, a valid py2+py3 spec is created.

I was able to create a py3 only package with -b3 -p3. Not very intuitive, but it works.

hroncok commented 5 years ago

I've marked this a s a bug, but currently there is nobody who has free cycles to fix pyp2rpm bugs. Sorry about that. Hope the workaround works for you in the meantime.

MrMEEE commented 5 years ago

Ok.. thanks for the workarounds :)

MrMEEE commented 5 years ago

Well it's not double anymore, but something is wrong with the deps:

with -b3 -p3:

bash-4.2$ scl enable rh-python36 "rpmbuild -ba --define 'scl rh-python36' python-xmlsec.spec"
error: Failed build dependencies:
        rh-python36-python34-devel is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64
        rh-python36-python34-python%{python34_pkgversion}-lxml >= 3.0 is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64
        rh-python36-python34-python%{python34_pkgversion}-pkgconfig is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64
        rh-python36-python34-python%{python34_pkgversion}-setuptools is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64

with no -b or -p:

bash-4.2$ scl enable rh-python36 "rpmbuild -ba --define 'scl rh-python36' python-xmlsec.spec"
error: Failed build dependencies:
        rh-python36-python2-devel is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64
        rh-python36-python2-setuptools is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64
        rh-python36-python34-devel is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64
        rh-python36-python34-setuptools is needed by rh-python36-python-xmlsec-1.3.3-1.el7.centos.x86_64

This might be in regards to spec2scl

hroncok commented 5 years ago

Yes I don't think that spec2scl was ever tested on EPEL Python 3 packages.

gordonmessmer commented 4 years ago

This should be resolved in v.3.3.4. Please re-open if you can reproduce the issue.