Skip to content

Commit

Permalink
Merge pull request #78 from toabctl/improve-requires-support
Browse files Browse the repository at this point in the history
Improve requires support
  • Loading branch information
toabctl committed Feb 28, 2017
2 parents 2a528a4 + 8a4af34 commit 29b6c3e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py2pack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def fetch(args):


def _canonicalize_setup_data(data):
if data.get('setup_requires', None):
# setup_requires may be a string, convert to list of strings:
if isinstance(data["setup_requires"], str):
data["setup_requires"] = data["setup_requires"].splitlines()
data["setup_requires"] = \
py2pack.requires._requirements_sanitize(data["setup_requires"])

if data.get('install_requires', None):
# install_requires may be a string, convert to list of strings:
if isinstance(data["install_requires"], str):
Expand Down
12 changes: 12 additions & 0 deletions py2pack/templates/opensuse.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without test
Name: python-{{ name }}
Version: {{ version }}
Release: 0
Expand All @@ -27,16 +28,25 @@ Source: {{ source_url|replace(version, '%{version}') }}
BuildRequires: python-rpm-macros
BuildRequires: %{python_module devel} {%- if requires_python %} = {{ requires_python }} {% endif %}
BuildRequires: %{python_module setuptools}
{%- if setup_requires and setup_requires is not none %}
{%- for req in setup_requires|sort %}
BuildRequires: %{python_module {{ req }}}
{%- endfor %}
{%- endif %}
{%- if install_requires and install_requires is not none %}
%if %{with test}
{%- for req in install_requires|sort %}
BuildRequires: %{python_module {{ req }}}
{%- endfor %}
%endif
{%- endif %}
{%- if tests_require and tests_require is not none %}
# SECTION test requirements
%if %{with test}
{%- for req in tests_require|sort %}
BuildRequires: %{python_module {{ req }}}
{%- endfor %}
%endif
# /SECTION
{%- endif %}
{%- if source_url.endswith('.zip') %}
Expand Down Expand Up @@ -75,8 +85,10 @@ BuildArch: noarch
%python_install

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

%files %{python_files}
Expand Down
4 changes: 4 additions & 0 deletions test/test_py2pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def test__prepare_template_env(self):
{'install_requires': 'six >=1.9,!=1.0 # comment\nfoobar>=0.1,>=0.5'},
{'install_requires': ['six >= 1.9', 'foobar >= 0.1']}
),
(
{'setup_requires': 'six >=1.9,!=1.0 # comment\nfoobar>=0.1,>=0.5'},
{'setup_requires': ['six >= 1.9', 'foobar >= 0.1']}
),
(
{'tests_require': ['six >=1.9', 'foobar>=0.1,>=0.5']},
{'tests_require': ['six >= 1.9', 'foobar >= 0.1']}
Expand Down

0 comments on commit 29b6c3e

Please sign in to comment.