From 99111d15501d6367c683b710356f082ab0f215d2 Mon Sep 17 00:00:00 2001 From: xambroz Date: Sun, 19 Feb 2017 14:31:56 +0100 Subject: [PATCH] update for fedora 25 --- py2pack/__init__.py | 5 +- py2pack/templates/fedora.spec | 166 +++++++++++++++++++++++++++++----- 2 files changed, 145 insertions(+), 26 deletions(-) diff --git a/py2pack/__init__.py b/py2pack/__init__.py index 1b78bf8..a31103c 100644 --- a/py2pack/__init__.py +++ b/py2pack/__init__.py @@ -221,7 +221,10 @@ def generate(args): data['source_url'] = _get_source_url(args.name, url['filename']) else: data['source_url'] = args.name + '-' + args.version + '.zip' - data['year'] = datetime.datetime.now().year # set current year + + now = datetime.datetime.now() + data['year'] = now.year # set current year + data['changelog_date'] = now.strftime("%a %b %d %Y") # set date for RPM changelog data['user_name'] = pwd.getpwuid(os.getuid())[4] # set system user (packager) data['summary_no_ending_dot'] = re.sub('(.*)\.', '\g<1>', data.get('summary', "")) diff --git a/py2pack/templates/fedora.spec b/py2pack/templates/fedora.spec index af2cce9..68462f5 100644 --- a/py2pack/templates/fedora.spec +++ b/py2pack/templates/fedora.spec @@ -1,27 +1,76 @@ -# -# spec file for package python-{{ name }} -# -# Copyright (c) {{ year }} {{ user_name }}. -# +# specfile autogenerated by py2pack from {{ name }} +# Please delete the unused comments serving just as examples +# template based on +# https://fedoraproject.org/wiki/Packaging:Python#Example_common_spec_file +# https://fedoraproject.org/wiki/Packaging:SourceURL +# https://fedoraproject.org/wiki/Packaging:Guidelines -Name: python-{{ name }} +%global srcname {{ name }} +%global sum {{ summary }} + +%global gituser acmegituser +%global gitname {{ name }} +%global commit 40-CHARACTER-HASH-VALUE +%global shortcommit %(c=%{commit}; echo ${c:0:7}) + +# Set to 0 to disable building of the python3 subpackage +%if 0%{?fedora} || ( 0%{?rhel} && 0%{?rhel} >= 7 ) +%global with_python3 1 +%endif + +%if 0%{?rhel} && 0%{?rhel} <= 6 +%{!?__python2: %global __python2 /usr/bin/python2} +%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} +%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} +%endif + + +Name: python-%{srcname} Version: {{ version }} -Release: 0 -Url: {{ home_page }} -Summary: {{ summary }} -License: {{ license }} +#Release: 1.git.%{shortcommit}%{?dist} +Release: 1%{?dist} +Summary: %{sum} Group: Development/Languages/Python -Source: {{ source_url|replace(version, '%{version}') }} -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: python-devel {%- if requires_python %} = {{ requires_python }} {% endif %} + +License: {{ license }} +#URL: https://pypi.python.org/pypi/{{ name }} +#URL: https://pypi.python.org/pypi/%{srcname} +#URL: https://github.com/%{gituser}/{{ name }} +#URL: https://github.com/%{gituser}/%{gitname} +URL: {{ home_page }} +#Source0: https://github.com/%{gituser}/%{srcname}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz +#Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz +#Source0: https://files.pythonhosted.org/packages/source/e/%{srcname}/%{srcname}-%{version}.tar.gz +Source0: {{ source_url|replace(version, '%{version}')|replace(name, '%{srcname}') }} + +{%- if not is_extension %} +BuildArch: noarch +{%- else %} +BuildRequires: gcc +BuildRequires: libtool +BuildRequires: python2-devel +BuildRequires: python-libs +%if 0%{?with_python3} +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-libs +%endif # if with_python3 +{%- endif %} + +BuildRequires: python-setuptools +%if 0%{?with_python3} +BuildRequires: python%{python3_pkgversion}-setuptools +%endif # if with_python3 + {%- for req in requires %} BuildRequires: python-{{ req|replace('(','')|replace(')','') }} Requires: python-{{ req|replace('(','')|replace(')','') }} {%- endfor %} + {%- for req in install_requires %} BuildRequires: python-{{ req|replace('(','')|replace(')','') }} Requires: python-{{ req|replace('(','')|replace(')','') }} {%- endfor %} + {%- if extras_require %} {%- for reqlist in extras_require.values() %} {%- for req in reqlist %} @@ -30,33 +79,100 @@ Suggests: python-{{ req|replace('(','')|replace(')','') }} {%- endfor %} {%- endif %} + + %description {{ description }} +%package -n python2-%{srcname} +Summary: %{sum} +%{?python_provide:%python_provide python2-%{srcname}} + +%description -n python2-%{srcname} +An python2 module {{ name }}. + + +%if 0%{?with_python3} +%package -n python3-%{srcname} +Summary: %{sum} +%{?python_provide:%python_provide python3-%{srcname}} + +%description -n python3-%{srcname} +An python3 module {{ name }}. +%endif # with_python3 + + +#=============================================================================== %prep -%setup -q -n {{ name }}-%{version} +#setup -q -n %{srcname}-%{version} +#autosetup -n %{gitname}-%{commit} +%autosetup -n %{srcname}-%{version} + + +#=============================================================================== %build -{%- if is_extension %} -export CFLAGS="%{optflags}" -{%- endif %} -python setup.py build +#python setup.py build +%py2_build + +%if 0%{?with_python3} +%py3_build +%endif # with_python3 + + +#=============================================================================== %install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} +#python setup.py install --prefix=%{_prefix} --root=%{buildroot} +# Must do the python2 install first because the scripts in /usr/bin are +# overwritten with every setup.py install, and in general we want the +# python3 version to be the default. +# If, however, we're installing separate executables for python2 and python3, +# the order needs to be reversed so the unversioned executable is the python2 one. +%py2_install + +%if 0%{?with_python3} +%py3_install +%endif # with_python3 + + + +#=============================================================================== +%check +%{__python2} setup.py test + +%if 0%{?with_python3} +%{__python3} setup.py test +%endif # with_python3 -%clean -rm -rf %{buildroot} -%files -%defattr(-,root,root,-) + +#=============================================================================== +# Note that there is no %%files section for the unversioned python module if we are building for several python runtimes +%files -n python2-%{srcname} +#%license COPYING {%- if doc_files %} %doc {{ doc_files|join(" ") }} {%- endif %} +%{python2_sitelib}/* {%- for script in scripts %} %{_bindir}/{{ script }} {%- endfor %} -%{python_sitelib}/* -%changelog +%if 0%{?with_python3} +%files -n python3-%{srcname} +#%license COPYING +{%- if doc_files %} +%doc {{ doc_files|join(" ") }} +{%- endif %} +%{python3_sitelib}/* +{%- for script in scripts %} +%{_bindir}/{{ script }} +{%- endfor %} +%endif # with_python3 + +#=============================================================================== +%changelog +* {{ changelog_date }} {{ user_name }} - {{ version }}-1 +- initial {{ name }} package for Fedora generated with py2pack