Skip to content

Commit

Permalink
Merge pull request #77 from toabctl/singlespec
Browse files Browse the repository at this point in the history
Singlespec
  • Loading branch information
toabctl committed Feb 28, 2017
2 parents c584e6e + 09ce8ad commit 2a528a4
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 14 deletions.
110 changes: 110 additions & 0 deletions py2pack/templates/opensuse-legacy.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#
# spec file for package python-{{ name }}
#
# Copyright (c) {{ year }} SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/


Name: python-{{ name }}
Version: {{ version }}
Release: 0
License: {{ license }}
Summary: {{ summary_no_ending_dot|default(summary, true) }}
Url: {{ home_page }}
Group: Development/Languages/Python
Source: {{ source_url|replace(version, '%{version}') }}
BuildRequires: python-devel {%- if requires_python %} = {{ requires_python }} {% endif %}
BuildRequires: python-setuptools
{%- if install_requires and install_requires is not none %}
{%- for req in install_requires|sort %}
BuildRequires: python-{{ req }}
{%- endfor %}
{%- endif %}
{%- if tests_require and tests_require is not none %}
# test requirements
{%- for req in tests_require|sort %}
BuildRequires: python-{{ req }}
{%- endfor %}
{%- endif %}
{%- if source_url.endswith('.zip') %}
BuildRequires: unzip
{%- endif %}
{%- if install_requires and install_requires is not none %}
{%- for req in install_requires|sort %}
Requires: python-{{ req }}
{%- endfor %}
{%- endif %}
{%- if extras_require and extras_require is not none %}
{%- for reqlist in extras_require.values() %}
{%- for req in reqlist %}
Suggests: python-{{ req }}
{%- endfor %}
{%- endfor %}
{%- endif %}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
{%- if not has_ext_modules %}
BuildArch: noarch
{%- endif %}

%description
{{ description }}

%prep
%setup -q -n {{ name }}-%{version}

%build
{% if has_ext_modules %}CFLAGS="%{optflags}" {% endif %}python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

{%- if testsuite or test_suite %}
%check
python setup.py test
{%- endif %}

%files
%defattr(-,root,root,-)
{%- if doc_files and doc_files is not none %}
%doc {{ doc_files|join(" ") }}
{%- endif %}
{%- if scripts and scripts is not none %}
{%- for script in scripts %}
%{_bindir}/{{ script|basename }}
{%- endfor %}
{%- endif %}
{%- if console_scripts and console_scripts is not none %}
{%- for script in console_scripts %}
%{_bindir}/{{ script }}
{%- endfor %}
{%- endif %}
{%- if has_ext_modules %}
%{python_sitearch}/*
{%- else %}
%{python_sitelib}/*
{%- endif %}
{%- if data_files and data_files is not none %}
{%- for dir, files in data_files %}
{%- set dir = dir |
replace('/usr/share/doc/'~name, '%doc %{_defaultdocdir}/%{name}', 1) |
replace('/usr/share/man/', '%doc %{_mandir}/', 1) |
replace('/usr/share/', '%{_datadir}/', 1) |
replace('/usr/', '%{_prefix}/', 1) %}
%dir {{ dir }}
{%- for file in files %}
{{ dir }}/{{file|basename }}
{%- endfor %}
{%- endfor %}
{%- endif %}

%changelog
34 changes: 20 additions & 14 deletions py2pack/templates/opensuse.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-{{ name }}
Version: {{ version }}
Release: 0
Expand All @@ -23,31 +24,33 @@ Summary: {{ summary_no_ending_dot|default(summary, true) }}
Url: {{ home_page }}
Group: Development/Languages/Python
Source: {{ source_url|replace(version, '%{version}') }}
BuildRequires: python-devel {%- if requires_python %} = {{ requires_python }} {% endif %}
BuildRequires: python-setuptools
BuildRequires: python-rpm-macros
BuildRequires: %{python_module devel} {%- if requires_python %} = {{ requires_python }} {% endif %}
BuildRequires: %{python_module setuptools}
{%- if install_requires and install_requires is not none %}
{%- for req in install_requires|sort %}
BuildRequires: python-{{ req|replace('(','')|replace(')','') }}
BuildRequires: %{python_module {{ req }}}
{%- endfor %}
{%- endif %}
{%- if tests_require and tests_require is not none %}
# test requirements
# SECTION test requirements
{%- for req in tests_require|sort %}
BuildRequires: python-{{ req|replace('(','')|replace(')','') }}
BuildRequires: %{python_module {{ req }}}
{%- endfor %}
# /SECTION
{%- endif %}
{%- if source_url.endswith('.zip') %}
BuildRequires: unzip
{%- endif %}
{%- if install_requires and install_requires is not none %}
{%- for req in install_requires|sort %}
Requires: python-{{ req|replace('(','')|replace(')','') }}
Requires: %{python_module {{ req }}}
{%- endfor %}
{%- endif %}
{%- if extras_require and extras_require is not none %}
{%- for reqlist in extras_require.values() %}
{%- for req in reqlist %}
Suggests: python-{{ req|replace('(','')|replace(')','') }}
Suggests: %{python_module {{ req }}}
{%- endfor %}
{%- endfor %}
{%- endif %}
Expand All @@ -56,36 +59,39 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
{%- endif %}

%python_subpackages

%description
{{ description }}

%prep
%setup -q -n {{ name }}-%{version}

%build
{% if has_ext_modules %}CFLAGS="%{optflags}" {% endif %}python setup.py build
{% if has_ext_modules %}export CFLAGS="%{optflags}"{% endif %}
%python_build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%python_install

{%- if testsuite or test_suite %}
%check
python setup.py test
%python_exec setup.py test
{%- endif %}

%files
%files %{python_files}
%defattr(-,root,root,-)
{%- if doc_files and doc_files is not none %}
%doc {{ doc_files|join(" ") }}
{%- endif %}
{%- if scripts and scripts is not none %}
{%- for script in scripts %}
%{_bindir}/{{ script|basename }}
%python3_only %{_bindir}/{{ script|basename }}
{%- endfor %}
{%- endif %}
{%- if console_scripts and console_scripts is not none %}
{%- for script in console_scripts %}
%{_bindir}/{{ script }}
%python3_only %{_bindir}/{{ script }}
{%- endfor %}
{%- endif %}
{%- if has_ext_modules %}
Expand All @@ -96,7 +102,7 @@ python setup.py test
{%- if data_files and data_files is not none %}
{%- for dir, files in data_files %}
{%- set dir = dir |
replace('/usr/share/doc/'~name, '%doc %{_defaultdocdir}/%{name}', 1) |
replace('/usr/share/doc/'~name, '%doc %{_defaultdocdir}/%{python_prefix}-{{ name }}', 1) |
replace('/usr/share/man/', '%doc %{_mandir}/', 1) |
replace('/usr/share/', '%{_datadir}/', 1) |
replace('/usr/', '%{_prefix}/', 1) %}
Expand Down

0 comments on commit 2a528a4

Please sign in to comment.