Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dist
rpm-build

# python
*.py[cod]
*.pyc

# C extensions
*.so
Expand Down Expand Up @@ -36,7 +36,6 @@ pip-log.txt
.coverage
coverage.xml
.tox
nosetests.xml

# Translations
*.mo
Expand Down
81 changes: 2 additions & 79 deletions python-bitmath.spec
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%{!?py2_build: %global py2_build python setup.py build}
%{!?py2_install: %global py2_install python setup.py install -O1 --root=$RPM_BUILD_ROOT}
%endif

%if 0%{?fedora}
%{!?python3_version: %global python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])")}
%global with_python3 1
%else
%global with_python3 0
%endif

%global _short_name bitmath
%global _short_release 1

Name: python-bitmath
Summary: Aids representing and manipulating file sizes in various prefix notations
Version: 1.3.3
Version: 2.0.0
Release: %{_short_release}%{?dist}

Group: Development/Libraries
Expand All @@ -27,20 +12,8 @@ Source0: https://github.com/tbielawa/bitmath/archive/%{version}.%{_short_release
Url: https://github.com/tbielawa/bitmath

BuildArch: noarch
BuildRequires: python2-mock
BuildRequires: python2-nose
BuildRequires: python2-progressbar
BuildRequires: python2-setuptools
BuildRequires: python2-devel
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-mock
BuildRequires: python3-nose
BuildRequires: python3-setuptools
%endif
%{?el6:Requires: python-argparse}
%{?el6:BuildRequires: python-argparse}
%{?el6:BuildRequires: python-unittest2}

%description
bitmath simplifies many facets of interacting with file sizes in
Expand All @@ -65,34 +38,6 @@ always at 100%.

######################################################################
# Sub-package setup
%package -n python2-bitmath
Summary: Aids representing and manipulating file sizes in various prefix notations
%{?python_provide:%python_provide python2-bitmath}

%description -n python2-bitmath
bitmath simplifies many facets of interacting with file sizes in
various units. Examples include: converting between SI and NIST prefix
units (GiB to kB), converting between units of the same type (SI to
SI, or NIST to NIST), basic arithmetic operations (subtracting 42KiB
from 50GiB), and rich comparison operations (1024 Bytes == 1KiB),
bitwise operations, sorting, automatic best human-readable prefix
selection, and completely customizable formatting.

In addition to the conversion and math operations, bitmath provides
human readable representations of values which are suitable for use in
interactive shells as well as larger scripts and applications. It can
also read the capacity of system storage devices. bitmath can parse
strings (like "1 KiB") into proper objects and has support for
integration with the argparse module as a custom argument type and the
progressbar module as a custom file transfer speed widget.

bitmath is thoroughly unittested, with almost 200 individual tests (a
number which is always increasing). bitmath's test-coverage is almost
always at 100%.

#---------------------------------------------------------------------

%if 0%{?with_python3}
%package -n python3-bitmath
Summary: Aids representing and manipulating file sizes in various prefix notations
%{?python_provide:%python_provide python3-bitmath}
Expand All @@ -117,45 +62,32 @@ progressbar module as a custom file transfer speed widget.
bitmath is thoroughly unittested, with almost 200 individual tests (a
number which is always increasing). bitmath's test-coverage is almost
always at 100%.
%endif # with_python3

######################################################################
%check
nosetests -v

%if 0%{?with_python3}
# We can't run the progressbar and argparse tests in python3 until
# progressbar has a python3 package available :(
#
# Skip those tests for now and run the rest
nosetests-%{python3_version} -e 'test_FileTransferSpeed' \
pytest -e 'test_FileTransferSpeed' \
-e 'test_BitmathType_' \
-I '.*test_argparse_type.py' \
-I '.*test_progressbar.py' -v
%endif # with_python3

######################################################################
%prep
%setup -n bitmath-%{version}.%{_short_release} -q

######################################################################
%build
%py2_build
%if 0%{?with_python3}
%py3_build
%endif

######################################################################
%install
%py2_install
mv $RPM_BUILD_ROOT/%{_bindir}/bitmath $RPM_BUILD_ROOT/%{_bindir}/bitmath-2.7

%if 0%{?with_python3}
%py3_install
pushd $RPM_BUILD_ROOT/%{_bindir}/
ln -s bitmath bitmath-%{python3_version}
popd
%endif # with_python3

mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1/
cp -v *.1 $RPM_BUILD_ROOT/%{_mandir}/man1/
Expand All @@ -164,22 +96,13 @@ cp -v -r docsite/source/* $RPM_BUILD_ROOT/%{_docdir}/%{name}/docs/
rm -f $RPM_BUILD_ROOT/%{_docdir}/%{name}/docs/NEWS.rst

######################################################################
%files -n python2-bitmath
%{python2_sitelib}/*
%doc README.rst NEWS.rst LICENSE
%doc %{_mandir}/man1/bitmath.1*
%doc %{_docdir}/%{name}/docs/
%{_bindir}/bitmath-2.7

%if 0%{?with_python3}
%files -n python3-bitmath
%{python3_sitelib}/*
%doc README.rst NEWS.rst LICENSE
%doc %{_mandir}/man1/bitmath.1*
%doc %{_docdir}/%{name}/docs/
%{_bindir}/bitmath
%{_bindir}/bitmath-%{python3_version}
%endif # with_python3

######################################################################
%changelog
Expand Down
79 changes: 2 additions & 77 deletions python-bitmath.spec.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%{!?py2_build: %global py2_build python setup.py build}
%{!?py2_install: %global py2_install python setup.py install -O1 --root=$RPM_BUILD_ROOT}
%endif

%if 0%{?fedora}
%{!?python3_version: %global python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])")}
%global with_python3 1
%else
%global with_python3 0
%endif

%global _short_name bitmath
%global _short_release 1

Expand All @@ -27,20 +12,9 @@ Source0: https://github.com/tbielawa/bitmath/archive/%{version}.%{_short_release
Url: https://github.com/tbielawa/bitmath

BuildArch: noarch
BuildRequires: python2-mock
BuildRequires: python2-nose
BuildRequires: python2-progressbar
BuildRequires: python2-setuptools
BuildRequires: python2-devel
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-mock
BuildRequires: python3-nose
BuildRequires: python3-pytest
BuildRequires: python3-setuptools
%endif
%{?el6:Requires: python-argparse}
%{?el6:BuildRequires: python-argparse}
%{?el6:BuildRequires: python-unittest2}

%description
bitmath simplifies many facets of interacting with file sizes in
Expand All @@ -65,34 +39,6 @@ always at 100%.

######################################################################
# Sub-package setup
%package -n python2-bitmath
Summary: Aids representing and manipulating file sizes in various prefix notations
%{?python_provide:%python_provide python2-bitmath}

%description -n python2-bitmath
bitmath simplifies many facets of interacting with file sizes in
various units. Examples include: converting between SI and NIST prefix
units (GiB to kB), converting between units of the same type (SI to
SI, or NIST to NIST), basic arithmetic operations (subtracting 42KiB
from 50GiB), and rich comparison operations (1024 Bytes == 1KiB),
bitwise operations, sorting, automatic best human-readable prefix
selection, and completely customizable formatting.

In addition to the conversion and math operations, bitmath provides
human readable representations of values which are suitable for use in
interactive shells as well as larger scripts and applications. It can
also read the capacity of system storage devices. bitmath can parse
strings (like "1 KiB") into proper objects and has support for
integration with the argparse module as a custom argument type and the
progressbar module as a custom file transfer speed widget.

bitmath is thoroughly unittested, with almost 200 individual tests (a
number which is always increasing). bitmath's test-coverage is almost
always at 100%.

#---------------------------------------------------------------------

%if 0%{?with_python3}
%package -n python3-bitmath
Summary: Aids representing and manipulating file sizes in various prefix notations
%{?python_provide:%python_provide python3-bitmath}
Expand All @@ -117,45 +63,33 @@ progressbar module as a custom file transfer speed widget.
bitmath is thoroughly unittested, with almost 200 individual tests (a
number which is always increasing). bitmath's test-coverage is almost
always at 100%.
%endif # with_python3

######################################################################
%check
nosetests -v

%if 0%{?with_python3}
# We can't run the progressbar and argparse tests in python3 until
# progressbar has a python3 package available :(
#
# Skip those tests for now and run the rest
nosetests-%{python3_version} -e 'test_FileTransferSpeed' \
pytest -e 'test_FileTransferSpeed' \
-e 'test_BitmathType_' \
-I '.*test_argparse_type.py' \
-I '.*test_progressbar.py' -v
%endif # with_python3

######################################################################
%prep
%setup -n bitmath-%{version}.%{_short_release} -q

######################################################################
%build
%py2_build
%if 0%{?with_python3}
%py3_build
%endif

######################################################################
%install
%py2_install
mv $RPM_BUILD_ROOT/%{_bindir}/bitmath $RPM_BUILD_ROOT/%{_bindir}/bitmath-2.7

%if 0%{?with_python3}
%py3_install
pushd $RPM_BUILD_ROOT/%{_bindir}/
ln -s bitmath bitmath-%{python3_version}
popd
%endif # with_python3

mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1/
cp -v *.1 $RPM_BUILD_ROOT/%{_mandir}/man1/
Expand All @@ -164,22 +98,13 @@ cp -v -r docsite/source/* $RPM_BUILD_ROOT/%{_docdir}/%{name}/docs/
rm -f $RPM_BUILD_ROOT/%{_docdir}/%{name}/docs/NEWS.rst

######################################################################
%files -n python2-bitmath
%{python2_sitelib}/*
%doc README.rst NEWS.rst LICENSE
%doc %{_mandir}/man1/bitmath.1*
%doc %{_docdir}/%{name}/docs/
%{_bindir}/bitmath-2.7

%if 0%{?with_python3}
%files -n python3-bitmath
%{python3_sitelib}/*
%doc README.rst NEWS.rst LICENSE
%doc %{_mandir}/man1/bitmath.1*
%doc %{_docdir}/%{name}/docs/
%{_bindir}/bitmath
%{_bindir}/bitmath-%{python3_version}
%endif # with_python3

######################################################################
%changelog
Expand Down
Loading