Skip to content

Commit

Permalink
Enhance BuildRequires when %check is present
Browse files Browse the repository at this point in the history
Add all install_requires listed in setup.py to BuildRequires
when test suite is present.
  • Loading branch information
mcyprian committed Dec 5, 2017
1 parent 9c9048c commit 083f6f4
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 20 deletions.
20 changes: 14 additions & 6 deletions pyp2rpm/metadata_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,20 @@ def runtime_deps(self): # install_requires
install_requires, runtime=True)))

@property
def build_deps(self): # setup_requires + tests_require
"""Same as runtime_deps, but build dependencies. Test requires
are included only if package contains test suite.
def build_deps(self): # setup_requires [tests_require, install_requires]
"""Same as runtime_deps, but build dependencies. Test and install
requires are included if package contains test suite to prevent
%check phase crashes because of missing dependencies
Returns:
list of build dependencies of the package
"""
build_requires = self.metadata['setup_requires'] + self.metadata[
'tests_require']
build_requires = self.metadata['setup_requires']

if self.has_test_suite:
build_requires += self.metadata['tests_require'] + self.metadata[
'install_requires']

if 'setuptools' not in build_requires:
build_requires.append('setuptools')
return sorted(self.name_convert_deps_list(deps_from_pyp_format(
Expand Down Expand Up @@ -555,7 +560,10 @@ def runtime_deps(self):

@property
def build_deps(self):
build_requires = self.get_requires(['build_requires', 'test_requires'])
build_requires = self.get_requires(['build_requires'])
if self.has_test_suite:
build_requires += self.get_requires([
'test_requires', 'run_requires'])
if 'setuptools' not in build_requires:
build_requires.append('setuptools')
return self.name_convert_deps_list(deps_from_pydit_json(
Expand Down
10 changes: 9 additions & 1 deletion tests/test_data/python-Jinja2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2-Babel >= 0.8
BuildRequires: python2-MarkupSafe
BuildRequires: python2-setuptools

BuildRequires: python3-devel
BuildRequires: python3-Babel >= 0.8
BuildRequires: python3-MarkupSafe
BuildRequires: python3-setuptools
BuildRequires: python3-sphinx

Expand Down Expand Up @@ -78,6 +82,10 @@ rm -rf html/.{doctrees,buildinfo}
%py2_install
%py3_install

%check
%{__python2} setup.py test
%{__python3} setup.py test

%files -n python2-%{pypi_name}
%license docs/_themes/LICENSE LICENSE
%doc README.rst
Expand All @@ -95,5 +103,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Wed Oct 11 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
10 changes: 9 additions & 1 deletion tests/test_data/python-Jinja2_autonc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2dist(babel) >= 0.8
BuildRequires: python2dist(markupsafe)
BuildRequires: python2dist(setuptools)

BuildRequires: python3-devel
BuildRequires: python3dist(babel) >= 0.8
BuildRequires: python3dist(markupsafe)
BuildRequires: python3dist(setuptools)
BuildRequires: python3dist(sphinx)

Expand Down Expand Up @@ -78,6 +82,10 @@ rm -rf html/.{doctrees,buildinfo}
%py2_install
%py3_install

%check
%{__python2} setup.py test
%{__python3} setup.py test

%files -n python2-%{pypi_name}
%license docs/_themes/LICENSE LICENSE
%doc README.rst
Expand All @@ -95,5 +103,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Wed Oct 11 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
7 changes: 6 additions & 1 deletion tests/test_data/python-Jinja2_base.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python3-devel
BuildRequires: python3-Babel >= 0.8
BuildRequires: python3-MarkupSafe
BuildRequires: python3-setuptools
BuildRequires: python3-sphinx

Expand Down Expand Up @@ -57,6 +59,9 @@ rm -rf html/.{doctrees,buildinfo}
%install
%py3_install

%check
%{__python3} setup.py test

%files -n python3-%{pypi_name}
%license docs/_themes/LICENSE LICENSE
%doc README.rst
Expand All @@ -68,5 +73,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Wed Oct 11 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
7 changes: 6 additions & 1 deletion tests/test_data/python-Jinja2_base_dnfnc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python3-devel
BuildRequires: python3-babel >= 0.8
BuildRequires: python3-markupsafe
BuildRequires: python3-setuptools
BuildRequires: python3-sphinx

Expand Down Expand Up @@ -57,6 +59,9 @@ rm -rf html/.{doctrees,buildinfo}
%install
%py3_install

%check
%{__python3} setup.py test

%files -n python3-%{pypi_name}
%license docs/_themes/LICENSE LICENSE
%doc README.rst
Expand All @@ -68,5 +73,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Mon Oct 23 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
10 changes: 9 additions & 1 deletion tests/test_data/python-Jinja2_dnfnc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2-babel >= 0.8
BuildRequires: python2-markupsafe
BuildRequires: python2-setuptools

BuildRequires: python3-devel
BuildRequires: python3-babel >= 0.8
BuildRequires: python3-markupsafe
BuildRequires: python3-setuptools
BuildRequires: python3-sphinx

Expand Down Expand Up @@ -78,6 +82,10 @@ rm -rf html/.{doctrees,buildinfo}
%py2_install
%py3_install

%check
%{__python2} setup.py test
%{__python3} setup.py test

%files -n python2-%{pypi_name}
%license docs/_themes/LICENSE LICENSE
%doc README.rst
Expand All @@ -95,5 +103,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Mon Oct 23 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
9 changes: 7 additions & 2 deletions tests/test_data/python-Jinja2_epel6.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Created by pyp2rpm-3.2.2
# Created by pyp2rpm-3.2.3
%global pypi_name Jinja2

Name: python-%{pypi_name}
Expand All @@ -12,6 +12,8 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2-Babel >= 0.8
BuildRequires: python2-MarkupSafe
BuildRequires: python2-setuptools
BuildRequires: python2-sphinx

Expand Down Expand Up @@ -47,6 +49,9 @@ rm -rf html/.{doctrees,buildinfo}

%install
%{__python2} setup.py install --skip-build --root %{buildroot}
%check
%{__python2} setup.py test


%files
%doc README.rst
Expand All @@ -58,5 +63,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Tue Aug 15 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
7 changes: 6 additions & 1 deletion tests/test_data/python-Jinja2_epel6_dnfnc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2-babel >= 0.8
BuildRequires: python2-markupsafe
BuildRequires: python2-setuptools
BuildRequires: python2-sphinx

Expand Down Expand Up @@ -47,6 +49,9 @@ rm -rf html/.{doctrees,buildinfo}

%install
%{__python2} setup.py install --skip-build --root %{buildroot}
%check
%{__python2} setup.py test


%files
%doc README.rst
Expand All @@ -58,5 +63,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Mon Oct 23 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
10 changes: 9 additions & 1 deletion tests/test_data/python-Jinja2_epel7.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2-Babel >= 0.8
BuildRequires: python2-MarkupSafe
BuildRequires: python2-setuptools
BuildRequires: python2-sphinx

BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-Babel >= 0.8
BuildRequires: python%{python3_pkgversion}-MarkupSafe
BuildRequires: python%{python3_pkgversion}-setuptools

%description
Expand Down Expand Up @@ -76,6 +80,10 @@ rm -rf html/.{doctrees,buildinfo}
%{__python3} setup.py install --skip-build --root %{buildroot}
%{__python2} setup.py install --skip-build --root %{buildroot}

%check
%{__python2} setup.py test
%{__python3} setup.py test

%files -n python2-%{pypi_name}
%doc README.rst
%{python2_sitelib}/jinja2
Expand All @@ -91,5 +99,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Wed Oct 11 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
10 changes: 9 additions & 1 deletion tests/test_data/python-Jinja2_epel7_dnfnc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2-babel >= 0.8
BuildRequires: python2-markupsafe
BuildRequires: python2-setuptools
BuildRequires: python2-sphinx

BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-babel >= 0.8
BuildRequires: python%{python3_pkgversion}-markupsafe
BuildRequires: python%{python3_pkgversion}-setuptools

%description
Expand Down Expand Up @@ -76,6 +80,10 @@ rm -rf html/.{doctrees,buildinfo}
%{__python3} setup.py install --skip-build --root %{buildroot}
%{__python2} setup.py install --skip-build --root %{buildroot}

%check
%{__python2} setup.py test
%{__python3} setup.py test

%files -n python2-%{pypi_name}
%doc README.rst
%{python2_sitelib}/jinja2
Expand All @@ -91,5 +99,5 @@ rm -rf html/.{doctrees,buildinfo}
%license docs/_themes/LICENSE LICENSE

%changelog
* Mon Oct 23 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 2.8-1
- Initial package.
5 changes: 4 additions & 1 deletion tests/test_data/python-StructArray.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ rm -rf %{pypi_name}.egg-info
%install
%py2_install

%check
%{__python2} setup.py test

%files -n python2-%{pypi_name}
%doc
%{python2_sitearch}/%{pypi_name}
%{python2_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%changelog
* Tue Nov 14 2017 Michal Cyprian <mcyprian@redhat.com> - 0.1-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 0.1-1
- Initial package.
5 changes: 4 additions & 1 deletion tests/test_data/python-StructArray_dnfnc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ rm -rf %{pypi_name}.egg-info
%install
%py2_install

%check
%{__python2} setup.py test

%files -n python2-%{pypi_name}
%doc
%{python2_sitearch}/%{pypi_name}
%{python2_sitearch}/%{pypi_name}-%{version}-py?.?.egg-info

%changelog
* Tue Nov 14 2017 Michal Cyprian <mcyprian@redhat.com> - 0.1-1
* Tue Dec 05 2017 Michal Cyprian <mcyprian@redhat.com> - 0.1-1
- Initial package.
Loading

0 comments on commit 083f6f4

Please sign in to comment.