Blob Blame History Raw
%global pypi_name tomlkit
%global tests_name toml-test
%global tests_commit 39bb76d631ba103a94b377aaf52c979456677fb1
%global tests_shortcommit %(c=%{tests_commit}; echo ${c:0:7})

%{?python_enable_dependency_generator}

%global common_description %{expand:
TOML Kit is a 0.5.0-compliant TOML library.

It includes a parser that preserves all comments, indentations,
whitespace and internal element ordering, and makes them accessible and
editable via an intuitive API.

You can also create new TOML documents from scratch using the provided
helpers.

Part of the implementation as been adapted, improved and fixed from
Molten.}

Name:           python-%{pypi_name}
Summary:        Style preserving TOML library
Version:        0.5.3
Release:        3%{?dist}
License:        MIT

URL:            https://github.com/sdispater/tomlkit
Source0:        %{pypi_source}

# pypi source doesn't have tests
Source1:        %{url}/archive/%{version}/%{pypi_name}-sources-%{version}.tar.gz

# data for unit tests from a separate git submodule
Source2:        https://github.com/BurntSushi/%{tests_name}/archive/%{tests_commit}/%{tests_name}-%{tests_shortcommit}.tar.gz

# patch setup.py to use setuptools::setup instead of distutils.core::setup
Patch0:         00-use-setuptools-not-distutils.patch

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  python3dist(setuptools)
BuildRequires:  python3dist(pytest)

%description %{common_description}


%package -n     python3-%{pypi_name}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}

%description -n python3-%{pypi_name} %{common_description}


%prep
%autosetup -n %{pypi_name}-%{version} -p1

# extract unit tests
tar -xzf %{SOURCE1}
cp -rp ./%{pypi_name}-%{version}/tests ./tests
rm -rf ./%{pypi_name}-%{version}

# extract test data
tar -xzf %{SOURCE2}
cp -rp ./%{tests_name}-%{tests_commit}/tests/ ./tests/toml-test/
rm -rf ./%{tests_name}-%{tests_commit}


%build
%py3_build


%install
%py3_install


%check
%{__python3} -m pytest tests/


%files -n python3-%{pypi_name}
%license LICENSE
%doc README.md

%{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info


%changelog
* Sat May 04 2019 Fabio Valentini <decathorpe@gmail.com> - 0.5.3-3
- Use setup from setuptools, not distutils.core.

* Mon Feb 11 2019 Patrik Kopkan <pkopkan@redhat.com> - 0.5.3-2
- Added check section.

* Wed Dec 19 2018 Fabio Valentini <decathorpe@gmail.com> - 0.5.3-1
- Initial package.