From b9c09bd3c4cb8b6e2e104f3ca2de3c82ce1147fa Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sat, 27 Apr 2024 17:30:44 +0200 Subject: [PATCH] package/python-mpmath: new package mpmath is a free (BSD licensed) Python library for real and complex floating-point arithmetic with arbitrary precision. https://mpmath.org/ Signed-off-by: Julien Olivain Signed-off-by: Thomas Petazzoni --- DEVELOPERS | 2 ++ package/Config.in | 1 + package/python-mpmath/Config.in | 7 +++++++ package/python-mpmath/python-mpmath.hash | 3 +++ package/python-mpmath/python-mpmath.mk | 14 ++++++++++++++ .../tests/package/sample_python_mpmath.py | 16 ++++++++++++++++ .../testing/tests/package/test_python_mpmath.py | 12 ++++++++++++ 7 files changed, 55 insertions(+) create mode 100644 package/python-mpmath/Config.in create mode 100644 package/python-mpmath/python-mpmath.hash create mode 100644 package/python-mpmath/python-mpmath.mk create mode 100644 support/testing/tests/package/sample_python_mpmath.py create mode 100644 support/testing/tests/package/test_python_mpmath.py diff --git a/DEVELOPERS b/DEVELOPERS index 0f020231bb..4af539e3f2 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1781,6 +1781,7 @@ F: support/testing/tests/package/sample_python_gnupg.py F: support/testing/tests/package/sample_python_hwdata.py F: support/testing/tests/package/sample_python_midiutil.py F: support/testing/tests/package/sample_python_ml_dtypes.py +F: support/testing/tests/package/sample_python_mpmath.py F: support/testing/tests/package/sample_python_pyalsa.py F: support/testing/tests/package/sample_python_spake2.py F: support/testing/tests/package/test_acl.py @@ -1874,6 +1875,7 @@ F: support/testing/tests/package/test_python_hwdata.py F: support/testing/tests/package/test_python_magic_wormhole.py F: support/testing/tests/package/test_python_midiutil.py F: support/testing/tests/package/test_python_ml_dtypes.py +F: support/testing/tests/package/test_python_mpmath.py F: support/testing/tests/package/test_python_pyalsa.py F: support/testing/tests/package/test_python_spake2.py F: support/testing/tests/package/test_rdma_core.py diff --git a/package/Config.in b/package/Config.in index deb5d5e10f..e72055f220 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1198,6 +1198,7 @@ menu "External python modules" source "package/python-modbus-tk/Config.in" source "package/python-more-itertools/Config.in" source "package/python-mpd2/Config.in" + source "package/python-mpmath/Config.in" source "package/python-msgfy/Config.in" source "package/python-msgpack/Config.in" source "package/python-multidict/Config.in" diff --git a/package/python-mpmath/Config.in b/package/python-mpmath/Config.in new file mode 100644 index 0000000000..497b7d2ae3 --- /dev/null +++ b/package/python-mpmath/Config.in @@ -0,0 +1,7 @@ +config BR2_PACKAGE_PYTHON_MPMATH + bool "python-mpmath" + help + mpmath is a free (BSD licensed) Python library for real and + complex floating-point arithmetic with arbitrary precision. + + https://mpmath.org/ diff --git a/package/python-mpmath/python-mpmath.hash b/package/python-mpmath/python-mpmath.hash new file mode 100644 index 0000000000..1b263c925f --- /dev/null +++ b/package/python-mpmath/python-mpmath.hash @@ -0,0 +1,3 @@ +# Locally computed sha256 checksums +sha256 7a28eb2a9774d00c7bc92411c19a89209d5da7c4c9a9e227be8330a23a25b91f mpmath-1.3.0.tar.gz +sha256 c26cae81da4508e5e249985777a33821f183223ebb74d7f8cfbf90fe7eef2fb7 LICENSE diff --git a/package/python-mpmath/python-mpmath.mk b/package/python-mpmath/python-mpmath.mk new file mode 100644 index 0000000000..caa6492961 --- /dev/null +++ b/package/python-mpmath/python-mpmath.mk @@ -0,0 +1,14 @@ +################################################################################ +# +# python-mpmath +# +################################################################################ + +PYTHON_MPMATH_VERSION = 1.3.0 +PYTHON_MPMATH_SOURCE = mpmath-$(PYTHON_MPMATH_VERSION).tar.gz +PYTHON_MPMATH_SITE = https://mpmath.org/files +PYTHON_MPMATH_SETUP_TYPE = setuptools +PYTHON_MPMATH_LICENSE = BSD-3-Clause +PYTHON_MPMATH_LICENSE_FILES = LICENSE + +$(eval $(python-package)) diff --git a/support/testing/tests/package/sample_python_mpmath.py b/support/testing/tests/package/sample_python_mpmath.py new file mode 100644 index 0000000000..5e3d9ad1c2 --- /dev/null +++ b/support/testing/tests/package/sample_python_mpmath.py @@ -0,0 +1,16 @@ +#! /usr/bin/env python3 + +# Test inspired from example published on the project page: +# https://mpmath.org/ + +from mpmath import mp + +mp.dps = 50 + +result = mp.quad(lambda x: mp.exp(-x**2), [-mp.inf, mp.inf]) ** 2 + +# Pi digits can be cross-checked here: +# https://www.angio.net/pi/digits.html +expected_result = "3.1415926535897932384626433832795028841971693993751" + +assert str(result) == expected_result diff --git a/support/testing/tests/package/test_python_mpmath.py b/support/testing/tests/package/test_python_mpmath.py new file mode 100644 index 0000000000..c20c910fbe --- /dev/null +++ b/support/testing/tests/package/test_python_mpmath.py @@ -0,0 +1,12 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3MpMath(TestPythonPackageBase): + __test__ = True + + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_MPMATH=y + """ + sample_scripts = ["tests/package/sample_python_mpmath.py"]