#
# spec file for package python
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%global flavor %{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define oldpython python
Name:           python-pathlib2%{?psuffix}
Version:        2.3.5
Release:        3.1
Summary:        Object-oriented filesystem paths
License:        MIT
Group:          Development/Languages/Python
URL:            https://github.com/mcmtroffaes/pathlib2
Source:         https://files.pythonhosted.org/packages/source/p/pathlib2/pathlib2-%{version}.tar.gz
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python-six
BuildArch:      noarch
%if %{with test}
BuildRequires:  %{python_module mock}
BuildRequires:  %{python_module scandir}
BuildRequires:  %{python_module six}
BuildRequires:  %{python_module testsuite}
%endif
%ifpython2
Requires:       python-scandir
%endif
%ifpython2
Provides:       %{oldpython}-pathlib2 = %{version}
Obsoletes:      %{oldpython}-pathlib2 <= %{version}
%endif
%python_subpackages

%description
The goal of pathlib2 is to provide a backport of
`standard pathlib <http://docs.python.org/dev/library/pathlib.html>`_
module which tracks the standard library module,
so all the newest features of the standard pathlib can be
used also on older Python versions.

%prep
%autosetup -n pathlib2-%{version}

%build
%python_build

%install
%if !%{with test}
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif

%if %{with test}
%check
export PYTHONPATH="$PWD"
%python_exec tests/test_pathlib2.py
%endif

%if !%{with test}
%files %{python_files}
%license LICENSE.rst
%doc CHANGELOG.rst README.rst
%{python_sitelib}/*
%endif

%changelog
* Fri Mar 13 2020 Tomáš Chvátal <tchvatal@suse.com>
- Fix the py2/py3 dependencies
* Fri Mar 13 2020 Tomáš Chvátal <tchvatal@suse.com>
- Fix fdupes call
* Mon Feb  3 2020 Tomáš Chvátal <tchvatal@suse.com>
- Add multibuild in order to break cycle betwen python3 and mesa
  * Caused by python3-testsuite that is part of the main python
- Add devel dependency for the tests on python2 only
* Tue Oct  8 2019 Tomáš Chvátal <tchvatal@suse.com>
- Update to 2.3.5:
  * Fall back to ascii when getfilesystemencoding returns None (see issue #59).
* Tue Jul 23 2019 Tomáš Chvátal <tchvatal@suse.com>
- Update to 2.3.4:
  * Do not raise windows error when calling resolve on a non-existing path in Python 2.7, to match behaviour on Python 3.x (see issue #54).
  * Use the new collections.abc when possible (see issue #53).
  * Sync with upstream pathlib (see issues #47 and #51).
* Mon Mar 11 2019 John Vandenberg <jayvdb@gmail.com>
- Add Provides/Obsoletes of python-pathlib2, needed by
  python2-jupyter_ipython and python2-pytest-django and others
* Sat Mar  9 2019 John Vandenberg <jayvdb@gmail.com>
- Fix build dependency on python3-scandir, unbreaking Leap 42.3
  and SLE 12 SP4
- Add bcond test to deactivate %%check properly when necessary
* Mon Feb  4 2019 Hans-Peter Jansen <hpj@urpla.net>
- depend on python3-scandir for python3 < 3.5 only
* Wed Jan  2 2019 Tomáš Chvátal <tchvatal@suse.com>
- Always pull in python2-scandir as there is no core functionality
* Fri Dec 28 2018 Martin Pluskal <mpluskal@suse.com>
- Update to version 2.3.3:
  * Bring back old deprecated dependency syntax to ensure
    compatibility with older systems (see issue #46).
  * Drop Python 3.3 support, as scandir no longer supports it.
  * Add Python 3.7 support.
- Update conditionals for tests and dependencies to work on older
  SLE/openSUSE releases as well
* Mon Nov 12 2018 Tomáš Chvátal <tchvatal@suse.com>
- Avoid an issue with accidentally still pulling scandir on python3
* Thu Nov  1 2018 Tomáš Chvátal <tchvatal@suse.com>
- Scandir is needed only on older than 3.5 python
* Tue Aug  7 2018 mimi.vx@gmail.com
- cleanup deps
* Wed May 30 2018 mimi.vx@gmail.com
- update to 2.3.2
- drop pathlib2-2.3.0-fix-tests.patch
- fix requires and drop coverage report
* Tue May 22 2018 mcepl@suse.com
- Clean up SPEC
- Switch on tests (add patch pathlib2-2.3.0-fix-tests.patch)
* Fri Jan  5 2018 alarrosa@suse.com
- Update to version 2.3.0
  * Sync with upstream pathlib from CPython 3.6.1
* Thu Aug 24 2017 jmatejek@suse.com
- singlespec auto-conversion
* Thu Mar 30 2017 toddrme2178@gmail.com
- Initial version