Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions py2pack/templates/opensuse.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

{%- set scripts_or_console_scripts = (
(scripts|map('basename')|list if scripts and scripts is not none else []) +
(console_scripts if console_scripts and console_scripts is not none else [])) %}
{%- if scripts_or_console_scripts %}
# Enable libalternatives by default
%bcond_without libalternatives
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be inside a %if 0%{?suse_version} > 1500 block

{%- endif %}


Name: python-{{ name }}
Version: {{ version }}
Expand Down Expand Up @@ -47,6 +55,10 @@ BuildRequires: %{python_module {{ req }}}
BuildRequires: unzip
{%- endif %}
BuildRequires: fdupes
{%- if scripts_or_console_scripts %}
BuildRequires: alts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be inside a %if 0%{?suse_version} > 1500 block

Requires: alts
{%- endif %}
{%- if install_requires and install_requires is not none %}
{%- for req in install_requires|sort %}
Requires: python-{{ req }}
Expand Down Expand Up @@ -78,9 +90,6 @@ export CFLAGS="%{optflags}"

%install
%pyproject_install
{%- set scripts_or_console_scripts = (
(scripts|map('basename')|list if scripts and scripts is not none else []) +
(console_scripts if console_scripts and console_scripts is not none else [])) %}
{%- for script in scripts_or_console_scripts %}
%python_clone -a %{buildroot}%{_bindir}/{{ script }}
{%- endfor %}
Expand All @@ -100,15 +109,6 @@ CHOOSE: %pytest OR %pyunittest -v OR CUSTOM
{%- endif %}
{%- endif %}

{%- if scripts_or_console_scripts %}

%post
%python_install_alternative {{ scripts_or_console_scripts|join(" ") }}

%postun
%python_uninstall_alternative {{ scripts_or_console_scripts|first }}
{%- endif %}

%files %{python_files}
{%- if doc_files and doc_files is not none %}
%doc {{ doc_files|join(" ") }}
Expand Down
10 changes: 4 additions & 6 deletions test/examples/poetry-opensuse-augmented.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# Enable libalternatives by default
%bcond_without libalternatives


Name: python-poetry
Expand Down Expand Up @@ -63,6 +65,8 @@ BuildRequires: %{python_module pytest-xdist}
BuildRequires: %{python_module zipp}
# /SECTION
BuildRequires: fdupes
BuildRequires: alts
Requires: alts
Requires: python-build >= 0.10.0
Requires: python-cachecontrol >= 0.12.9
Requires: python-cleo >= 2.0.0
Expand Down Expand Up @@ -223,12 +227,6 @@ installation script
%check
CHOOSE: %pytest OR %pyunittest -v OR CUSTOM

%post
%python_install_alternative poetry

%postun
%python_uninstall_alternative poetry

%files %{python_files}
%doc README.md
%license LICENSE
Expand Down
10 changes: 4 additions & 6 deletions test/examples/py2pack-opensuse-augmented.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# Enable libalternatives by default
%bcond_without libalternatives


Name: python-py2pack
Expand All @@ -34,6 +36,8 @@ BuildRequires: %{python_module metaextract}
BuildRequires: %{python_module six}
# /SECTION
BuildRequires: fdupes
BuildRequires: alts
Requires: alts
Requires: python-Jinja2
Requires: python-metaextract
Requires: python-setuptools
Expand All @@ -59,12 +63,6 @@ Generate distribution packages from PyPI
%check
CHOOSE: %pytest OR %pyunittest -v OR CUSTOM

%post
%python_install_alternative py2pack

%postun
%python_uninstall_alternative py2pack

%files %{python_files}
%doc AUTHORS ChangeLog README.rst
%license LICENSE
Expand Down
10 changes: 4 additions & 6 deletions test/examples/sampleproject-opensuse-augmented.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# Enable libalternatives by default
%bcond_without libalternatives


Name: python-sampleproject
Expand Down Expand Up @@ -51,6 +53,8 @@ BuildRequires: %{python_module peppercorn}
BuildRequires: %{python_module coverage}
# /SECTION
BuildRequires: fdupes
BuildRequires: alts
Requires: alts
Requires: python-peppercorn
Suggests: python-check-manifest
BuildArch: noarch
Expand All @@ -70,12 +74,6 @@ A sample Python project
%python_clone -a %{buildroot}%{_bindir}/sample
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%post
%python_install_alternative sample

%postun
%python_uninstall_alternative sample

%files %{python_files}
%doc README.md
%license LICENSE.txt
Expand Down
2 changes: 1 addition & 1 deletion test/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ def test_template(tmpdir, template, fetch_tarball, project, version):
required = filehandle.read()
required = required.replace('__USER__', username, 1)
required = required.replace('__YEAR__', str(datetime.date.today().year), 1)
assert written_spec == required
assert written_spec == required, filehandle