Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package: mahotas #997

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
13 changes: 13 additions & 0 deletions server/pypi/packages/mahotas/meta.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 14 additions & 0 deletions server/pypi/packages/mahotas/patches/chaquopy.patch
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions server/pypi/packages/mahotas/test.py
Original file line number Diff line number Diff line change
@@ -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])