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 with_test 0
|
||||
|
||||
Name: python-%{pypi_name}
|
||||
Version: 0.9.1
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: Python Library for Tom's Obvious, Minimal Language
|
||||
|
||||
License: MIT
|
||||
URL: https://pypi.python.org/pypi/%{pypi_name}
|
||||
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
|
||||
BuildRequires: python2-devel
|
||||
BuildRequires: golang-github-BurntSushi-toml-test
|
||||
|
||||
%description
|
||||
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.
|
||||
|
||||
|
||||
%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}
|
||||
Summary: Python Library for Tom's Obvious, Minimal Language
|
||||
BuildRequires: python3-devel
|
||||
%{?python_provide:%python_provide python2-%{pypi_name}}
|
||||
|
||||
%description -n python3-%{pypi_name}
|
||||
TOML aims to be a minimal configuration file format that's easy to read due to
|
||||
@ -34,35 +52,32 @@ toml file.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{pypi_name}-%{version}
|
||||
rm -rf %{py3dir}
|
||||
cp -a . %{py3dir}
|
||||
# Copy test files and make them executable so toml-test can work
|
||||
cp -a %{SOURCE1} %{SOURCE2} .
|
||||
chmod +x toml_test.py toml_test3.py
|
||||
|
||||
|
||||
%build
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py build
|
||||
popd
|
||||
|
||||
%{__python2} setup.py build
|
||||
%py2_build
|
||||
%py3_build
|
||||
|
||||
|
||||
%install
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
|
||||
popd
|
||||
|
||||
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
|
||||
%py2_install
|
||||
%py3_install
|
||||
|
||||
|
||||
%check
|
||||
# No test suite at present, so we'll just try importing
|
||||
pushd %{py3dir}
|
||||
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -c "import toml"
|
||||
popd
|
||||
|
||||
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} -c "import toml"
|
||||
# Using the language independent toml-test suite to launch tests
|
||||
# link the the tests files
|
||||
%if 0%{with_test}
|
||||
ln -s /usr/share/toml-test/tests tests
|
||||
toml-test $(pwd)/toml_test3.py
|
||||
toml-test $(pwd)/toml_test.py
|
||||
%endif
|
||||
|
||||
|
||||
%files
|
||||
%files -n python2-%{pypi_name}
|
||||
%license LICENSE
|
||||
%doc README.rst
|
||||
%{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*
|
||||
|
||||
%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
|
||||
- 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