normal-grain-merge 0.0.0__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of normal-grain-merge might be problematic. Click here for more details.

Files changed (17) hide show
  1. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/PKG-INFO +108 -78
  2. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/README.md +30 -0
  3. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge/normal_grain_merge.pyi +28 -28
  4. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge.egg-info/PKG-INFO +108 -78
  5. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/pyproject.toml +31 -31
  6. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/setup.cfg +4 -4
  7. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/setup.py +8 -4
  8. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/LICENSE +0 -0
  9. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge/__init__.py +0 -0
  10. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge/kernel_kind.py +0 -0
  11. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge/normal_grain_merge.c +0 -0
  12. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge.egg-info/SOURCES.txt +0 -0
  13. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge.egg-info/dependency_links.txt +0 -0
  14. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge.egg-info/requires.txt +0 -0
  15. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/normal_grain_merge.egg-info/top_level.txt +0 -0
  16. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/tests/test_ngm.py +0 -0
  17. {normal_grain_merge-0.0.0 → normal_grain_merge-0.0.2}/tests/test_speed.py +0 -0
@@ -1,78 +1,108 @@
1
- Metadata-Version: 2.4
2
- Name: normal_grain_merge
3
- Version: 0.0.0
4
- Summary: Fused normal and grain merge C extension
5
- Author: Samuel Howard
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/samhaswon/normal_grain_merge
8
- Project-URL: Bug Tracker, https://github.com/samhaswon/normal_grain_merge/issues
9
- Keywords: image,processing
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: C
12
- Classifier: Operating System :: OS Independent
13
- Requires-Python: >=3.7
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: numpy<2.3.0
17
- Dynamic: license-file
18
-
19
- # normal_grain_merge
20
-
21
- This implements a combined version of the blend modes normal and grain merge.
22
- Grain merge is performed on *s* and *t* with the result normal-merged with *b*.
23
- Subscripts indicate channels, with alpha (α) channels broadcast to three channels.
24
-
25
- $$
26
- (((\mathrm{t_{rgb}} + \mathrm{s_{rgb}} - 0.5) * \mathrm{t_\alpha} + \mathrm{t_{rgb}} * (1 - \mathrm{t_\alpha})) * (1 - 0.3) + \mathrm{s_{rgb}} * 0.3) * \mathrm{t_\alpha} + \mathrm{b_{rgb}} * (1 - \mathrm{t_\alpha})
27
- $$
28
-
29
- ## Usage
30
- ```py
31
- import numpy as np
32
- from normal_grain_merge import normal_grain_merge, KernelKind
33
-
34
-
35
- # Example arrays
36
- base = np.zeros((100, 100, 3), dtype=np.uint8)
37
- texture = np.zeros((100, 100, 3), dtype=np.uint8)
38
- skin = np.zeros((100, 100, 4), dtype=np.uint8)
39
- im_alpha = np.zeros((100, 100), dtype=np.uint8)
40
-
41
- result_scalar = normal_grain_merge(base, texture, skin, im_alpha, KernelKind.KERNEL_SCALAR.value)
42
- print(result_scalar.shape, result_scalar.dtype)
43
- ```
44
-
45
- There are three kernels implemented in this module as defined in `KernelKind`.
46
-
47
- - `KERNEL_AUTO`: Automatically chooses the kernel, preferring AVX2
48
- - `KERNEL_SCALAR`: Portable scalar implementation.
49
- - `KERNEL_SSE42`: SSE4.2 intrinsics kernel. Likely better on AMD CPUs.
50
- - `KERNEL_AVX2`: AVX2 intrinsics kernel. Likely better on Intel CPUs.
51
-
52
- ### Parameters
53
-
54
- All input matrices should have the same height and width.
55
-
56
- #### `base`
57
-
58
- RGB or RGBA, dropping the alpha channel if it exists.
59
- The base image for application.
60
-
61
- #### `texture`
62
-
63
- RGB or RGBA, applying the alpha if it exists.
64
- This is the texture to be applied.
65
-
66
- #### `skin`
67
-
68
- RGBA, the segmented portion of base to texture.
69
- The "skin" of the object the texture is to be applied to.
70
-
71
- #### `im_alpha`
72
-
73
- The alpha of parameter `skin`.
74
- This is mostly a holdover from the Python implementation to deal with NumPy.
75
-
76
- #### `kernel`
77
-
78
- One of `KernelKind`.
1
+ Metadata-Version: 2.4
2
+ Name: normal_grain_merge
3
+ Version: 0.0.2
4
+ Summary: Fused normal and grain merge C extension
5
+ Author: Samuel Howard
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/samhaswon/normal_grain_merge
8
+ Project-URL: Bug Tracker, https://github.com/samhaswon/normal_grain_merge/issues
9
+ Keywords: image,processing
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: C
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: numpy<2.3.0
17
+ Dynamic: license-file
18
+
19
+ # normal_grain_merge
20
+
21
+ This implements a combined version of the blend modes normal and grain merge.
22
+ Grain merge is performed on *s* and *t* with the result normal-merged with *b*.
23
+ Subscripts indicate channels, with alpha (α) channels broadcast to three channels.
24
+
25
+ $$
26
+ (((\mathrm{t_{rgb}} + \mathrm{s_{rgb}} - 0.5) * \mathrm{t_\alpha} + \mathrm{t_{rgb}} * (1 - \mathrm{t_\alpha})) * (1 - 0.3) + \mathrm{s_{rgb}} * 0.3) * \mathrm{t_\alpha} + \mathrm{b_{rgb}} * (1 - \mathrm{t_\alpha})
27
+ $$
28
+
29
+ ## Installation
30
+
31
+ ```shell
32
+ pip install normal-grain-merge
33
+ ```
34
+
35
+ ## Usage
36
+ ```py
37
+ import numpy as np
38
+ from normal_grain_merge import normal_grain_merge, KernelKind
39
+
40
+
41
+ # Example arrays
42
+ base = np.zeros((100, 100, 3), dtype=np.uint8)
43
+ texture = np.zeros((100, 100, 3), dtype=np.uint8)
44
+ skin = np.zeros((100, 100, 4), dtype=np.uint8)
45
+ im_alpha = np.zeros((100, 100), dtype=np.uint8)
46
+
47
+ result_scalar = normal_grain_merge(base, texture, skin, im_alpha, KernelKind.KERNEL_SCALAR.value)
48
+ print(result_scalar.shape, result_scalar.dtype)
49
+ ```
50
+
51
+ There are three kernels implemented in this module as defined in `KernelKind`.
52
+
53
+ - `KERNEL_AUTO`: Automatically chooses the kernel, preferring AVX2
54
+ - `KERNEL_SCALAR`: Portable scalar implementation.
55
+ - `KERNEL_SSE42`: SSE4.2 intrinsics kernel. Likely better on AMD CPUs.
56
+ - `KERNEL_AVX2`: AVX2 intrinsics kernel. Likely better on Intel CPUs.
57
+
58
+ ### Parameters
59
+
60
+ All input matrices should have the same height and width.
61
+
62
+ #### `base`
63
+
64
+ RGB or RGBA, dropping the alpha channel if it exists.
65
+ The base image for application.
66
+
67
+ #### `texture`
68
+
69
+ RGB or RGBA, applying the alpha if it exists.
70
+ This is the texture to be applied.
71
+
72
+ #### `skin`
73
+
74
+ RGBA, the segmented portion of base to texture.
75
+ The "skin" of the object the texture is to be applied to.
76
+
77
+ #### `im_alpha`
78
+
79
+ The alpha of parameter `skin`.
80
+ This is mostly a holdover from the Python implementation to deal with NumPy.
81
+
82
+ #### `kernel`
83
+
84
+ One of `KernelKind`.
85
+
86
+ ## Performance
87
+
88
+ The entire reason for me writing this was NumPy being slow when this operation is in the hot path.
89
+ So, I decided to write a SIMD version that does the type casting outside NumPy with only the intermediate values being in FP32.
90
+
91
+ How much of a speedup is this? All numbers are from a Ryzen 7 4800H running Windows 11 and Python 3.12.4.
92
+
93
+ | Method/Kernel | Average Iteration Time |
94
+ |-------------------|------------------------|
95
+ | C scalar kernel | 0.019565s |
96
+ | C SSE4.2 kernel | 0.013705s |
97
+ | C AVX2 kernel | 0.016842s |
98
+ | NumPy version | 0.228098s |
99
+ | Old NumPy version | 0.350554s |
100
+
101
+ | Method Comparison | Speedup |
102
+ |--------------------|----------|
103
+ | NumPy -> scalar | 91.4227% |
104
+ | NumPy -> SSE4.2 | 93.9915% |
105
+ | NumPy -> AVX2 | 92.6165% |
106
+ | Old np -> SSE4.2 | 96.0904% |
107
+ | C scalar -> SSE4.2 | 29.9487% |
108
+ | C scalar -> AVX2 | 13.9183% |
@@ -8,6 +8,12 @@ $$
8
8
  (((\mathrm{t_{rgb}} + \mathrm{s_{rgb}} - 0.5) * \mathrm{t_\alpha} + \mathrm{t_{rgb}} * (1 - \mathrm{t_\alpha})) * (1 - 0.3) + \mathrm{s_{rgb}} * 0.3) * \mathrm{t_\alpha} + \mathrm{b_{rgb}} * (1 - \mathrm{t_\alpha})
9
9
  $$
10
10
 
11
+ ## Installation
12
+
13
+ ```shell
14
+ pip install normal-grain-merge
15
+ ```
16
+
11
17
  ## Usage
12
18
  ```py
13
19
  import numpy as np
@@ -58,3 +64,27 @@ This is mostly a holdover from the Python implementation to deal with NumPy.
58
64
  #### `kernel`
59
65
 
60
66
  One of `KernelKind`.
67
+
68
+ ## Performance
69
+
70
+ The entire reason for me writing this was NumPy being slow when this operation is in the hot path.
71
+ So, I decided to write a SIMD version that does the type casting outside NumPy with only the intermediate values being in FP32.
72
+
73
+ How much of a speedup is this? All numbers are from a Ryzen 7 4800H running Windows 11 and Python 3.12.4.
74
+
75
+ | Method/Kernel | Average Iteration Time |
76
+ |-------------------|------------------------|
77
+ | C scalar kernel | 0.019565s |
78
+ | C SSE4.2 kernel | 0.013705s |
79
+ | C AVX2 kernel | 0.016842s |
80
+ | NumPy version | 0.228098s |
81
+ | Old NumPy version | 0.350554s |
82
+
83
+ | Method Comparison | Speedup |
84
+ |--------------------|----------|
85
+ | NumPy -> scalar | 91.4227% |
86
+ | NumPy -> SSE4.2 | 93.9915% |
87
+ | NumPy -> AVX2 | 92.6165% |
88
+ | Old np -> SSE4.2 | 96.0904% |
89
+ | C scalar -> SSE4.2 | 29.9487% |
90
+ | C scalar -> AVX2 | 13.9183% |
@@ -1,28 +1,28 @@
1
- # ngm/normal_grain_merge.pyi
2
- from typing import Literal
3
- import numpy as np
4
- from .kernel_kind import KernelKind
5
-
6
- def normal_grain_merge(
7
- base: np.ndarray,
8
- texture: np.ndarray,
9
- skin: np.ndarray,
10
- im_alpha: np.ndarray,
11
- kernel: Literal["auto", "scalar", "sse42", "avx2"] | KernelKind = "auto",
12
- ) -> np.ndarray:
13
- """
14
- Performs a combined merge: grain merge of skin and texture,
15
- then a normal merge of that result on base.
16
- Channel ordering doesn't matter as long as it is consistent.
17
- :param base: The base RGB image.
18
- :param texture: The texture, either RGB or RGBA.
19
- :param skin: The RGBA skin cutout.
20
- :param im_alpha: The alpha from the cutout.
21
- :param kernel: Which kernel to use.
22
- The `auto` kernel chooses between avx2 and sse4.2 when compiled with gcc and uses `scaler` on Windows.
23
- The `scalar` kernel is a portable implementation that relies on the compiler for SIMD.
24
- The `sse42` kernel uses SSE4.2 intrinsics.
25
- The `avx2` kernel uses AVX2 intrinsics.
26
- :return: RGB np.ndarray.
27
- """
28
- ...
1
+ # ngm/normal_grain_merge.pyi
2
+ from typing import Literal
3
+ import numpy as np
4
+ from .kernel_kind import KernelKind
5
+
6
+ def normal_grain_merge(
7
+ base: np.ndarray,
8
+ texture: np.ndarray,
9
+ skin: np.ndarray,
10
+ im_alpha: np.ndarray,
11
+ kernel: Literal["auto", "scalar", "sse42", "avx2"] | KernelKind = "auto",
12
+ ) -> np.ndarray:
13
+ """
14
+ Performs a combined merge: grain merge of skin and texture,
15
+ then a normal merge of that result on base.
16
+ Channel ordering doesn't matter as long as it is consistent.
17
+ :param base: The base RGB image.
18
+ :param texture: The texture, either RGB or RGBA.
19
+ :param skin: The RGBA skin cutout.
20
+ :param im_alpha: The alpha from the cutout.
21
+ :param kernel: Which kernel to use.
22
+ The `auto` kernel chooses between avx2 and sse4.2 when compiled with gcc and uses `scaler` on Windows.
23
+ The `scalar` kernel is a portable implementation that relies on the compiler for SIMD.
24
+ The `sse42` kernel uses SSE4.2 intrinsics.
25
+ The `avx2` kernel uses AVX2 intrinsics.
26
+ :return: RGB np.ndarray.
27
+ """
28
+ ...
@@ -1,78 +1,108 @@
1
- Metadata-Version: 2.4
2
- Name: normal_grain_merge
3
- Version: 0.0.0
4
- Summary: Fused normal and grain merge C extension
5
- Author: Samuel Howard
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/samhaswon/normal_grain_merge
8
- Project-URL: Bug Tracker, https://github.com/samhaswon/normal_grain_merge/issues
9
- Keywords: image,processing
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: C
12
- Classifier: Operating System :: OS Independent
13
- Requires-Python: >=3.7
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: numpy<2.3.0
17
- Dynamic: license-file
18
-
19
- # normal_grain_merge
20
-
21
- This implements a combined version of the blend modes normal and grain merge.
22
- Grain merge is performed on *s* and *t* with the result normal-merged with *b*.
23
- Subscripts indicate channels, with alpha (α) channels broadcast to three channels.
24
-
25
- $$
26
- (((\mathrm{t_{rgb}} + \mathrm{s_{rgb}} - 0.5) * \mathrm{t_\alpha} + \mathrm{t_{rgb}} * (1 - \mathrm{t_\alpha})) * (1 - 0.3) + \mathrm{s_{rgb}} * 0.3) * \mathrm{t_\alpha} + \mathrm{b_{rgb}} * (1 - \mathrm{t_\alpha})
27
- $$
28
-
29
- ## Usage
30
- ```py
31
- import numpy as np
32
- from normal_grain_merge import normal_grain_merge, KernelKind
33
-
34
-
35
- # Example arrays
36
- base = np.zeros((100, 100, 3), dtype=np.uint8)
37
- texture = np.zeros((100, 100, 3), dtype=np.uint8)
38
- skin = np.zeros((100, 100, 4), dtype=np.uint8)
39
- im_alpha = np.zeros((100, 100), dtype=np.uint8)
40
-
41
- result_scalar = normal_grain_merge(base, texture, skin, im_alpha, KernelKind.KERNEL_SCALAR.value)
42
- print(result_scalar.shape, result_scalar.dtype)
43
- ```
44
-
45
- There are three kernels implemented in this module as defined in `KernelKind`.
46
-
47
- - `KERNEL_AUTO`: Automatically chooses the kernel, preferring AVX2
48
- - `KERNEL_SCALAR`: Portable scalar implementation.
49
- - `KERNEL_SSE42`: SSE4.2 intrinsics kernel. Likely better on AMD CPUs.
50
- - `KERNEL_AVX2`: AVX2 intrinsics kernel. Likely better on Intel CPUs.
51
-
52
- ### Parameters
53
-
54
- All input matrices should have the same height and width.
55
-
56
- #### `base`
57
-
58
- RGB or RGBA, dropping the alpha channel if it exists.
59
- The base image for application.
60
-
61
- #### `texture`
62
-
63
- RGB or RGBA, applying the alpha if it exists.
64
- This is the texture to be applied.
65
-
66
- #### `skin`
67
-
68
- RGBA, the segmented portion of base to texture.
69
- The "skin" of the object the texture is to be applied to.
70
-
71
- #### `im_alpha`
72
-
73
- The alpha of parameter `skin`.
74
- This is mostly a holdover from the Python implementation to deal with NumPy.
75
-
76
- #### `kernel`
77
-
78
- One of `KernelKind`.
1
+ Metadata-Version: 2.4
2
+ Name: normal_grain_merge
3
+ Version: 0.0.2
4
+ Summary: Fused normal and grain merge C extension
5
+ Author: Samuel Howard
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/samhaswon/normal_grain_merge
8
+ Project-URL: Bug Tracker, https://github.com/samhaswon/normal_grain_merge/issues
9
+ Keywords: image,processing
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: C
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: numpy<2.3.0
17
+ Dynamic: license-file
18
+
19
+ # normal_grain_merge
20
+
21
+ This implements a combined version of the blend modes normal and grain merge.
22
+ Grain merge is performed on *s* and *t* with the result normal-merged with *b*.
23
+ Subscripts indicate channels, with alpha (α) channels broadcast to three channels.
24
+
25
+ $$
26
+ (((\mathrm{t_{rgb}} + \mathrm{s_{rgb}} - 0.5) * \mathrm{t_\alpha} + \mathrm{t_{rgb}} * (1 - \mathrm{t_\alpha})) * (1 - 0.3) + \mathrm{s_{rgb}} * 0.3) * \mathrm{t_\alpha} + \mathrm{b_{rgb}} * (1 - \mathrm{t_\alpha})
27
+ $$
28
+
29
+ ## Installation
30
+
31
+ ```shell
32
+ pip install normal-grain-merge
33
+ ```
34
+
35
+ ## Usage
36
+ ```py
37
+ import numpy as np
38
+ from normal_grain_merge import normal_grain_merge, KernelKind
39
+
40
+
41
+ # Example arrays
42
+ base = np.zeros((100, 100, 3), dtype=np.uint8)
43
+ texture = np.zeros((100, 100, 3), dtype=np.uint8)
44
+ skin = np.zeros((100, 100, 4), dtype=np.uint8)
45
+ im_alpha = np.zeros((100, 100), dtype=np.uint8)
46
+
47
+ result_scalar = normal_grain_merge(base, texture, skin, im_alpha, KernelKind.KERNEL_SCALAR.value)
48
+ print(result_scalar.shape, result_scalar.dtype)
49
+ ```
50
+
51
+ There are three kernels implemented in this module as defined in `KernelKind`.
52
+
53
+ - `KERNEL_AUTO`: Automatically chooses the kernel, preferring AVX2
54
+ - `KERNEL_SCALAR`: Portable scalar implementation.
55
+ - `KERNEL_SSE42`: SSE4.2 intrinsics kernel. Likely better on AMD CPUs.
56
+ - `KERNEL_AVX2`: AVX2 intrinsics kernel. Likely better on Intel CPUs.
57
+
58
+ ### Parameters
59
+
60
+ All input matrices should have the same height and width.
61
+
62
+ #### `base`
63
+
64
+ RGB or RGBA, dropping the alpha channel if it exists.
65
+ The base image for application.
66
+
67
+ #### `texture`
68
+
69
+ RGB or RGBA, applying the alpha if it exists.
70
+ This is the texture to be applied.
71
+
72
+ #### `skin`
73
+
74
+ RGBA, the segmented portion of base to texture.
75
+ The "skin" of the object the texture is to be applied to.
76
+
77
+ #### `im_alpha`
78
+
79
+ The alpha of parameter `skin`.
80
+ This is mostly a holdover from the Python implementation to deal with NumPy.
81
+
82
+ #### `kernel`
83
+
84
+ One of `KernelKind`.
85
+
86
+ ## Performance
87
+
88
+ The entire reason for me writing this was NumPy being slow when this operation is in the hot path.
89
+ So, I decided to write a SIMD version that does the type casting outside NumPy with only the intermediate values being in FP32.
90
+
91
+ How much of a speedup is this? All numbers are from a Ryzen 7 4800H running Windows 11 and Python 3.12.4.
92
+
93
+ | Method/Kernel | Average Iteration Time |
94
+ |-------------------|------------------------|
95
+ | C scalar kernel | 0.019565s |
96
+ | C SSE4.2 kernel | 0.013705s |
97
+ | C AVX2 kernel | 0.016842s |
98
+ | NumPy version | 0.228098s |
99
+ | Old NumPy version | 0.350554s |
100
+
101
+ | Method Comparison | Speedup |
102
+ |--------------------|----------|
103
+ | NumPy -> scalar | 91.4227% |
104
+ | NumPy -> SSE4.2 | 93.9915% |
105
+ | NumPy -> AVX2 | 92.6165% |
106
+ | Old np -> SSE4.2 | 96.0904% |
107
+ | C scalar -> SSE4.2 | 29.9487% |
108
+ | C scalar -> AVX2 | 13.9183% |
@@ -1,31 +1,31 @@
1
- [build-system]
2
- requires = [
3
- "setuptools>=64",
4
- "wheel",
5
- "numpy<2.3.0" # Follows opencv-python (cv2)
6
- ]
7
- build-backend = "setuptools.build_meta"
8
-
9
- [project]
10
- name = "normal_grain_merge"
11
- version = "0.0.0"
12
- description = "Fused normal and grain merge C extension"
13
- readme = "README.md"
14
- authors = [
15
- { name = "Samuel Howard" }
16
- ]
17
- dependencies = ["numpy<2.3.0"]
18
- requires-python = ">=3.7"
19
- license = "MIT"
20
- classifiers = [
21
- "Programming Language :: Python :: 3",
22
- "Programming Language :: C",
23
- "Operating System :: OS Independent",
24
- ]
25
- keywords = [
26
- "image",
27
- "processing"
28
- ]
29
- [project.urls]
30
- "Homepage" = "https://github.com/samhaswon/normal_grain_merge"
31
- "Bug Tracker" = "https://github.com/samhaswon/normal_grain_merge/issues"
1
+ [build-system]
2
+ requires = [
3
+ "setuptools>=64",
4
+ "wheel",
5
+ "numpy<2.3.0" # Follows opencv-python (cv2)
6
+ ]
7
+ build-backend = "setuptools.build_meta"
8
+
9
+ [project]
10
+ name = "normal_grain_merge"
11
+ version = "0.0.2"
12
+ description = "Fused normal and grain merge C extension"
13
+ readme = "README.md"
14
+ authors = [
15
+ { name = "Samuel Howard" }
16
+ ]
17
+ dependencies = ["numpy<2.3.0"]
18
+ requires-python = ">=3.8"
19
+ license = { text = "MIT" }
20
+ classifiers = [
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: C",
23
+ "Operating System :: OS Independent",
24
+ ]
25
+ keywords = [
26
+ "image",
27
+ "processing"
28
+ ]
29
+ [project.urls]
30
+ "Homepage" = "https://github.com/samhaswon/normal_grain_merge"
31
+ "Bug Tracker" = "https://github.com/samhaswon/normal_grain_merge/issues"
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,14 +1,18 @@
1
+ import platform
1
2
  from setuptools import setup, Extension
2
- import numpy
3
3
  import sys
4
+ import numpy
4
5
 
5
- extra_compile_args = []
6
6
 
7
+ arch = platform.machine().lower()
7
8
  extra_compile_args = []
9
+
8
10
  if sys.platform == "win32":
9
11
  extra_compile_args += ["/O2", "/arch:AVX2", "/Qpar"] # enables AVX/AVX2; SSE4.2 implied
12
+ elif "arm" in arch or "aarch64" in arch:
13
+ extra_compile_args += ["-O3"]
10
14
  else:
11
- extra_compile_args += ["-O3", "-march=x86-64-v3", "-mavx2", "-msse4.2"]
15
+ extra_compile_args += ["-O3", "-march=x86-64", "-mavx2", "-msse4.2"]
12
16
 
13
17
  module = Extension(
14
18
  "normal_grain_merge.normal_grain_merge",
@@ -19,7 +23,7 @@ module = Extension(
19
23
 
20
24
  setup(
21
25
  name="normal_grain_merge",
22
- version="0.0.0",
26
+ version="0.0.2",
23
27
  description="Normal grain merge C extension",
24
28
  ext_modules=[module],
25
29
  packages=["normal_grain_merge"],