Enable tests suite
- Build python3 and python2 in the same directory - Use %py2_build, %py3_build, %py2_install and %py2_install - Move python2 package in its own subpackage
This commit is contained in:
parent
03d3d92400
commit
a555416a3e
@ -1,16 +1,21 @@
|
|||||||
%global pypi_name toml
|
%global pypi_name toml
|
||||||
|
%global with_test 0
|
||||||
|
|
||||||
Name: python-%{pypi_name}
|
Name: python-%{pypi_name}
|
||||||
Version: 0.9.1
|
Version: 0.9.1
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: Python Library for Tom's Obvious, Minimal Language
|
Summary: Python Library for Tom's Obvious, Minimal Language
|
||||||
|
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://pypi.python.org/pypi/%{pypi_name}
|
URL: https://pypi.python.org/pypi/%{pypi_name}
|
||||||
Source0: https://pypi.python.org/packages/source/t/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
|
Source0: https://pypi.python.org/packages/source/t/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
|
||||||
|
# Tests files are not provided in pypi release as they require toml-test to run
|
||||||
|
Source1: https://raw.githubusercontent.com/uiri/toml/da6d593944d08569e08ff32f2bb2e73da91d3578/toml_test.py
|
||||||
|
Source2: https://raw.githubusercontent.com/uiri/toml/da6d593944d08569e08ff32f2bb2e73da91d3578/toml_test3.py
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: python2-devel
|
BuildRequires: python2-devel
|
||||||
|
BuildRequires: golang-github-BurntSushi-toml-test
|
||||||
|
|
||||||
%description
|
%description
|
||||||
TOML aims to be a minimal configuration file format that's easy to read due to
|
TOML aims to be a minimal configuration file format that's easy to read due to
|
||||||
@ -20,9 +25,22 @@ This package loads toml file into python dictionary and dump dictionary into
|
|||||||
toml file.
|
toml file.
|
||||||
|
|
||||||
|
|
||||||
|
%package -n python2-%{pypi_name}
|
||||||
|
Summary: Python Library for Tom's Obvious, Minimal Language
|
||||||
|
%{?python_provide:%python_provide python2-%{pypi_name}}
|
||||||
|
|
||||||
|
%description -n python2-%{pypi_name}
|
||||||
|
TOML aims to be a minimal configuration file format that's easy to read due to
|
||||||
|
obvious semantics. TOML is designed to map unambiguously to a hash table. TOML
|
||||||
|
should be easy to parse into data structures in a wide variety of languages.
|
||||||
|
This package loads toml file into python dictionary and dump dictionary into
|
||||||
|
toml file.
|
||||||
|
|
||||||
|
|
||||||
%package -n python3-%{pypi_name}
|
%package -n python3-%{pypi_name}
|
||||||
Summary: Python Library for Tom's Obvious, Minimal Language
|
Summary: Python Library for Tom's Obvious, Minimal Language
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
|
%{?python_provide:%python_provide python2-%{pypi_name}}
|
||||||
|
|
||||||
%description -n python3-%{pypi_name}
|
%description -n python3-%{pypi_name}
|
||||||
TOML aims to be a minimal configuration file format that's easy to read due to
|
TOML aims to be a minimal configuration file format that's easy to read due to
|
||||||
@ -34,35 +52,32 @@ toml file.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{pypi_name}-%{version}
|
%setup -q -n %{pypi_name}-%{version}
|
||||||
rm -rf %{py3dir}
|
# Copy test files and make them executable so toml-test can work
|
||||||
cp -a . %{py3dir}
|
cp -a %{SOURCE1} %{SOURCE2} .
|
||||||
|
chmod +x toml_test.py toml_test3.py
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
pushd %{py3dir}
|
%py2_build
|
||||||
%{__python3} setup.py build
|
%py3_build
|
||||||
popd
|
|
||||||
|
|
||||||
%{__python2} setup.py build
|
|
||||||
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
pushd %{py3dir}
|
%py2_install
|
||||||
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
|
%py3_install
|
||||||
popd
|
|
||||||
|
|
||||||
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
|
|
||||||
|
|
||||||
|
|
||||||
%check
|
%check
|
||||||
# No test suite at present, so we'll just try importing
|
# Using the language independent toml-test suite to launch tests
|
||||||
pushd %{py3dir}
|
# link the the tests files
|
||||||
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -c "import toml"
|
%if 0%{with_test}
|
||||||
popd
|
ln -s /usr/share/toml-test/tests tests
|
||||||
|
toml-test $(pwd)/toml_test3.py
|
||||||
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} -c "import toml"
|
toml-test $(pwd)/toml_test.py
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
||||||
%files
|
%files -n python2-%{pypi_name}
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%doc README.rst
|
%doc README.rst
|
||||||
%{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info
|
%{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info
|
||||||
@ -76,6 +91,12 @@ PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} -c "import toml"
|
|||||||
%{python3_sitelib}/__pycache__/%{pypi_name}.cpython-*.py*
|
%{python3_sitelib}/__pycache__/%{pypi_name}.cpython-*.py*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Aug 8 2015 Julien Enselme <jujens@jujens.eu> - 0.9.1-2
|
||||||
|
- Enable tests suite
|
||||||
|
- Build python3 and python2 in the same directory
|
||||||
|
- Use %%py2_build, %%py3_build, %%py2_install and %%py2_install
|
||||||
|
- Move python2 package in its own subpackage
|
||||||
|
|
||||||
* Sat Jul 11 2015 Fedora Release Monitoring <release-monitoring@fedoraproject.org> - 0.9.1-1
|
* Sat Jul 11 2015 Fedora Release Monitoring <release-monitoring@fedoraproject.org> - 0.9.1-1
|
||||||
- Update to 0.9.1 (#1242131)
|
- Update to 0.9.1 (#1242131)
|
||||||
|
|
||||||
|
|||||||
56
toml_test.py
Normal file
56
toml_test.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import toml
|
||||||
|
|
||||||
|
try:
|
||||||
|
_range = xrange
|
||||||
|
iteritems = dict.iteritems
|
||||||
|
except NameError:
|
||||||
|
unicode = str
|
||||||
|
_range = range
|
||||||
|
basestring = str
|
||||||
|
unichr = chr
|
||||||
|
iteritems = dict.items
|
||||||
|
long = int
|
||||||
|
|
||||||
|
def tag(value):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
d = { }
|
||||||
|
for k, v in iteritems(value):
|
||||||
|
d[k] = tag(v)
|
||||||
|
return d
|
||||||
|
elif isinstance(value, list):
|
||||||
|
a = []
|
||||||
|
for v in value:
|
||||||
|
a.append(tag(v))
|
||||||
|
try:
|
||||||
|
a[0]["value"]
|
||||||
|
except KeyError:
|
||||||
|
return a
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return {'type': 'array', 'value': a}
|
||||||
|
elif isinstance(value, basestring):
|
||||||
|
return {'type': 'string', 'value': value}
|
||||||
|
elif isinstance(value, bool):
|
||||||
|
return {'type': 'bool', 'value': str(value).lower()}
|
||||||
|
elif isinstance(value, int):
|
||||||
|
return {'type': 'integer', 'value': str(value)}
|
||||||
|
elif isinstance(value, long):
|
||||||
|
return {'type': 'integer', 'value': str(value)}
|
||||||
|
elif isinstance(value, float):
|
||||||
|
return {'type': 'float', 'value': repr(value)}
|
||||||
|
elif isinstance(value, datetime.datetime):
|
||||||
|
sdate = value.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
return {'type': 'datetime', 'value': sdate}
|
||||||
|
assert False, 'Unknown type: %s' % type(value)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
tdata = toml.loads(sys.stdin.read())
|
||||||
|
tagged = tag(tdata)
|
||||||
|
print(json.dumps(tagged))
|
||||||
|
|
||||||
11
toml_test3.py
Normal file
11
toml_test3.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import toml_test
|
||||||
|
import toml
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
tdata = toml.loads(sys.stdin.read())
|
||||||
|
tagged = toml_test.tag(tdata)
|
||||||
|
print(json.dumps(tagged))
|
||||||
Loading…
Reference in New Issue
Block a user