Last active
December 6, 2018 16:26
-
-
Save carlwgeorge/d1a59be753d2b01bdf816a8bc7aef4da to your computer and use it in GitHub Desktop.
example python module spec file for Fedora and EPEL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# what it's called on pypi | |
%global srcname example | |
# what it's imported as | |
%global libname %{srcname} | |
# name of egg info directory | |
%global eggname %{srcname} | |
# package name fragment | |
%global pkgname %{srcname} | |
%global common_description %{expand: | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor | |
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis | |
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | |
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu | |
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in | |
culpa qui officia deserunt mollit anim id est laborum.} | |
# These conditionals will vary by package. These are examples, use whatever | |
# combination works for your desired set of subpackages. | |
%bcond_without python3 | |
%if %{defined rhel} | |
%bcond_without python2 | |
%bcond_without python3_other | |
%endif | |
%bcond_without python3 | |
%bcond_without python3_tests | |
%if %{defined rhel} | |
%bcond_without python2 | |
%bcond_with python2_tests | |
%bcond_without python3_other | |
%bcond_with python3_other_tests | |
%endif | |
%if (%{defined rhel} && 0%{?rhel} < 8) || (%{defined fedora} && 0%{?fedora} < 30) | |
%bcond_without python2 | |
%endif | |
%bcond_without python3 | |
%if %{defined el7} | |
%bcond_without python3_other | |
%endif | |
%bcond_without tests | |
Name: python-%{pkgname} | |
Version: 0.0.0 | |
Release: 0%{?dist} | |
Summary: Lorem ipsum dolor sit amet | |
License: Lorem | |
URL: https://github.com/lorem/ipsum | |
Source0: %pypi_source | |
# PyPI tarball doesn't have tests | |
#Source0: %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz | |
BuildArch: noarch | |
%description %{common_description} | |
%if %{with python2} | |
%package -n python2-%{pkgname} | |
Summary: %{summary} | |
BuildRequires: python2-devel | |
BuildRequires: python2-setuptools | |
%if %{with tests} | |
BuildRequires: python2-pytest | |
BuildRequires: python2-six | |
%endif | |
Requires: python2-six | |
%{?python_provide:%python_provide python2-%{pkgname}} | |
%description -n python2-%{pkgname} %{common_description} | |
%endif | |
%if %{with python3} | |
%package -n python%{python3_pkgversion}-%{pkgname} | |
Summary: %{summary} | |
BuildRequires: python%{python3_pkgversion}-devel | |
BuildRequires: python%{python3_pkgversion}-setuptools | |
%if %{with tests} | |
BuildRequires: python%{python3_pkgversion}-pytest | |
BuildRequires: python%{python3_pkgversion}-six | |
%endif | |
Requires: python%{python3_pkgversion}-six | |
%{?python_provide:%python_provide python%{python3_pkgversion}-%{pkgname}} | |
%description -n python%{python3_pkgversion}-%{pkgname} %{common_description} | |
%endif | |
%if %{with python3_other} | |
%package -n python%{python3_other_pkgversion}-%{pkgname} | |
Summary: %{summary} | |
BuildRequires: python%{python3_other_pkgversion}-devel | |
BuildRequires: python%{python3_other_pkgversion}-setuptools | |
%if %{with tests} | |
BuildRequires: python%{python3_other_pkgversion}-pytest | |
BuildRequires: python%{python3_other_pkgversion}-six | |
%endif | |
Requires: python%{python3_other_pkgversion}-six | |
%description -n python%{python3_other_pkgversion}-%{pkgname} %{common_description} | |
%endif | |
%prep | |
%autosetup -n %{srcname}-%{version} | |
rm -rf %{eggname}.egg-info | |
%build | |
%{?with_python2:%py2_build} | |
%{?with_python3:%py3_build} | |
%{?with_python3_other:%py3_other_build} | |
%install | |
%{?with_python2:%py2_install} | |
%{?with_python3:%py3_install} | |
%{?with_python3_other:%py3_other_install} | |
%if %{with tests} | |
%check | |
%{?with_python2:PYTHONPATH=%{buildroot}%{python2_sitelib} py.test-%{python2_version} --verbose tests} | |
%{?with_python3:PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} --verbose tests} | |
%{?with_python3_other:PYTHONPATH=%{buildroot}%{python3_other_sitelib} py.test-%{python3_other_version} --verbose tests} | |
%endif | |
%if %{with python2} | |
%files -n python2-%{pkgname} | |
%license LICENSE | |
%doc README.rst | |
# For a python "package", own the directory. | |
%{python2_sitelib}/%{libname} | |
# For a python "module", own the file and related cache files. | |
#{python2_sitelib}/%{libname}.py* | |
%{python2_sitelib}/%{eggname}-%{version}-py%{python2_version}.egg-info | |
%endif | |
%if %{with python3} | |
%files -n python%{python3_pkgversion}-%{pkgname} | |
%license LICENSE | |
%doc README.rst | |
# For a python "package", own the directory. | |
%{python3_sitelib}/%{libname} | |
# For a python "module", own the file and related cache files. | |
#{python3_sitelib}/%{libname}.py | |
#{python3_sitelib}/__pycache__/%{libname}.cpython-%{python3_version_nodots}*.py* | |
%{python3_sitelib}/%{eggname}-%{version}-py%{python3_version}.egg-info | |
%endif | |
%if %{with python3_other} | |
%files -n python%{python3_other_pkgversion}-%{pkgname} | |
%license LICENSE | |
%doc README.rst | |
# For a python "package", own the directory. | |
%{python3_other_sitelib}/%{libname} | |
# For a python "module", own the file and related cache files. | |
#{python3_other_sitelib}/%{libname}.py | |
#{python3_other_sitelib}/__pycache__/%{libname}.cpython-%{python3_other_version_nodots}*.py* | |
%{python3_other_sitelib}/%{eggname}-%{version}-py%{python3_other_version}.egg-info | |
%endif | |
%changelog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment