diff --git a/server/pypi/packages/mahotas/meta.yaml b/server/pypi/packages/mahotas/meta.yaml new file mode 100644 index 0000000000..171714e744 --- /dev/null +++ b/server/pypi/packages/mahotas/meta.yaml @@ -0,0 +1,13 @@ +{% if PY_VER == "3.8" %} + {% set numpy_version = "1.19.5" %} +{% else %} + {% set numpy_version = "1.23.3" %} +{% endif %} + +package: + name: mahotas + version: "1.4.13" + +requirements: + host: + - numpy {{ numpy_version }} diff --git a/server/pypi/packages/mahotas/patches/chaquopy.patch b/server/pypi/packages/mahotas/patches/chaquopy.patch new file mode 100644 index 0000000000..235e2e73e4 --- /dev/null +++ b/server/pypi/packages/mahotas/patches/chaquopy.patch @@ -0,0 +1,14 @@ +--- src-original/setup.py 2022-08-23 17:16:48.000000000 +0000 ++++ src/setup.py 2023-09-05 08:36:00.870847761 +0000 +@@ -20,6 +20,11 @@ + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + # THE SOFTWARE. + ++# Chaquopy ++if "egg_info" not in sys.argv: ++ import builtins ++ builtins.__NUMPY_SETUP__ = True # Prevent the compiled parts from being imported. ++ + from __future__ import division + try: + import setuptools diff --git a/server/pypi/packages/mahotas/test.py b/server/pypi/packages/mahotas/test.py new file mode 100644 index 0000000000..88a172dac3 --- /dev/null +++ b/server/pypi/packages/mahotas/test.py @@ -0,0 +1,22 @@ +import unittest + +class TestMahotas(unittest.TestCase): + + def test_hitmiss(self): + import mahotas + import numpy as np + + A = np.zeros((100,100), np.bool_) + Bc = np.array([ + [0,1,2], + [0,1,1], + [2,1,1]]) + mahotas.morph.hitmiss(A,Bc) + self.assertFalse(mahotas.morph.hitmiss(A,Bc).sum()) + + A[4:7,4:7] = np.array([ + [0,1,1], + [0,1,1], + [0,1,1]]) + self.assertEqual(mahotas.morph.hitmiss(A,Bc).sum(), 1) + self.assertTrue(mahotas.morph.hitmiss(A,Bc)[5,5])