Blob Blame History Raw
Name:           python-mpmath
Version:        1.2.1
Release:        %autorelease
Summary:        A pure Python library for multiprecision floating-point arithmetic
License:        BSD
# Source code

# Switch to 'traditional' theme in RHEL since 'classic' isn't available
Patch0:         python-mpmath-1.0.0-sphinx.patch

# #1974835 - CVE-2021-29063 python-mpmath: Regular expression denial of service in the mpmathify function

BuildRequires:  python3-devel
BuildRequires:  python3-pip
BuildRequires:  python3-setuptools
BuildRequires:  python3-setuptools_scm
BuildRequires:  python3-pytest
BuildRequires:  python3-sphinx
BuildRequires:  xorg-x11-server-Xvfb

# For building documentation
BuildRequires:  dvipng
BuildRequires:  tex(latex)

BuildArch:      noarch

%global _description %{expand:
Mpmath is a pure-Python library for multiprecision floating-point
arithmetic. It provides an extensive set of transcendental functions,
unlimited exponent sizes, complex numbers, interval arithmetic,
numerical integration and differentiation, root-finding, linear
algebra, and much more. Almost any calculation can be performed just
as well at 10-digit or 1000-digit precision, and in many cases mpmath
implements asymptotically fast algorithms that scale well for
extremely high precision work. If available, mpmath will (optionally)
use gmpy to speed up high precision operations.}

%description %_description

%package -n python3-mpmath
Summary:        A pure Python library for multiprecision floating-point arithmetic
%if 0%{?fedora} || 0%{?rhel} > 7
Recommends: python3-matplotlib
%{?python_provide:%python_provide python3-mpmath}

%description -n python3-mpmath %_description

If you require plotting capabilities in mpmath, install python3-matplotlib.

%package doc
Summary:        HTML documentation for %{name}
Requires:       python3-mpmath = %{version}-%{release}

%description doc
This package contains the HTML documentation for %{name}.

%setup -q -n mpmath-%{version}
%if 0%{?rhel} == 6 || 0%{?rhel} == 7
%patch0 -p1 -b .sphinx
%patch1 -p1

# Convert line encodings
for doc in CHANGES LICENSE README.rst TODO mpmath/tests/; do
 sed "s|\r||g" $doc > $ && \
 touch -r $doc $ && \
 mv $ $doc
find doc -name *.txt -exec sed -i "s|\r||g" {} \;

shebangs="mpmath/matrices/ mpmath/matrices/ mpmath/tests/ mpmath/tests/ mpmath/tests/ mpmath/tests/"
# Get rid of unnecessary shebangs
for lib in $shebangs; do
 sed '/^#!.*/d; 1q' $lib > $ && \
 touch -r $lib $ && \
 mv $ $lib

sed -i -r 's/use_scm_version=True/version="%{version}"/'


# Build documentation
cd doc


cd build/lib/mpmath/tests/
xvfb-run -a pytest-3 -v

%files -n python3-mpmath
%license LICENSE

%files doc
%doc doc/build/*