turbopipe 1.0.5__tar.gz → 1.1.0__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 turbopipe might be problematic. Click here for more details.

@@ -48,8 +48,6 @@ jobs:
48
48
  - name: Install MSVC
49
49
  if: matrix.os == 'windows-latest'
50
50
  uses: bus1/cabuild/action/msdevshell@v1
51
- with:
52
- architecture: x64
53
51
 
54
52
  - name: deps
55
53
  run: python -m pip install cibuildwheel==2.19.2
@@ -86,3 +84,23 @@ jobs:
86
84
  TWINE_USERNAME: __token__
87
85
  TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}}
88
86
  run: twine upload package/*
87
+
88
+ tag:
89
+ needs: publish
90
+ name: Create Release Tag
91
+ runs-on: ubuntu-latest
92
+
93
+ steps:
94
+ - uses: actions/checkout@v4
95
+ - uses: actions/setup-python@v5
96
+
97
+ - name: Get version
98
+ run: echo VERSION=$(python turbopipe/version.py) >> $GITHUB_ENV
99
+ shell: bash
100
+
101
+ - name: Create Release Tag
102
+ run: |
103
+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
104
+ git config --local user.name "github-actions[bot]"
105
+ git tag -a v$VERSION -m "Release v$VERSION"
106
+ git push origin v$VERSION
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: turbopipe
3
- Version: 1.0.5
4
- Summary: 🌀 Faster ModernGL Buffer inter process data transfers
3
+ Version: 1.1.0
4
+ Summary: 🌀 Faster MemoryView inter-process data transfers for subprocesses
5
5
  Home-page: https://brokensrc.dev
6
6
  Author-Email: Tremeschin <29046864+Tremeschin@users.noreply.github.com>
7
7
  License: MIT License
@@ -35,12 +35,18 @@ Description-Content-Type: text/markdown
35
35
 
36
36
  > [!IMPORTANT]
37
37
  > <sub>Also check out [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow), where **TurboPipe** shines! 😉</sub>
38
-
38
+ <!-- PyPI -->
39
39
  <div align="center">
40
40
  <a href="https://brokensrc.dev/"><img src="https://raw.githubusercontent.com/BrokenSource/TurboPipe/main/turbopipe/resources/images/turbopipe.png" width="200"></a>
41
41
  <h1>TurboPipe</h1>
42
+ Faster <a href="https://github.com/moderngl/moderngl"><b>ModernGL Buffers</b></a> inter-process data transfers for subprocesses
43
+ <br>
42
44
  <br>
43
- Faster <a href="https://github.com/moderngl/moderngl"><b>ModernGL</b></a> inter-process data transfers
45
+ <a href="https://pypi.org/project/turbopipe/"><img src="https://img.shields.io/pypi/v/turbopipe?label=PyPI&color=blue"></a>
46
+ <a href="https://pypi.org/project/turbopipe/"><img src="https://img.shields.io/pypi/dw/turbopipe?label=Installs&color=blue"></a>
47
+ <a href="https://github.com/BrokenSource/TurboPipe"><img src="https://img.shields.io/github/v/tag/BrokenSource/TurboPipe?label=GitHub&color=orange"></a>
48
+ <a href="https://github.com/BrokenSource/TurboPipe/stargazers"><img src="https://img.shields.io/github/stars/BrokenSource/TurboPipe?label=Stars&style=flat&color=orange"></a>
49
+ <a href="https://discord.gg/KjqvcYwRHm"><img src="https://img.shields.io/discord/1184696441298485370?label=Discord&style=flat&color=purple"></a>
44
50
  </div>
45
51
 
46
52
  <br>
@@ -53,7 +59,7 @@ The **optimizations** involved are:
53
59
 
54
60
  - **Zero-copy**: Avoid unnecessary memory copies or allocation (intermediate `buffer.read()`)
55
61
  - **C++**: The core of TurboPipe is written in C++ for speed, efficiency and low-level control
56
- - **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy
62
+ - **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy (Unix)
57
63
  - **Threaded**:
58
64
  - Doesn't block Python code execution, allows to render next frame
59
65
  - Decouples the main thread from the I/O thread for performance
@@ -68,7 +74,7 @@ It couldn't be easier! Just install the [**`turbopipe`**](https://pypi.org/proje
68
74
 
69
75
  ```bash
70
76
  # With pip (https://pip.pypa.io/)
71
- python -m pip install turbopipe
77
+ pip install turbopipe
72
78
 
73
79
  # With Poetry (https://python-poetry.org/)
74
80
  poetry add turbopipe
@@ -84,7 +90,7 @@ rye add turbopipe
84
90
 
85
91
  # 🚀 Usage
86
92
 
87
- See also the [**Examples**](https://github.com/BrokenSource/TurboPipe/tree/main/examples) folder for more controlled usage, and [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow/blob/main/ShaderFlow/Scene.py) usage of it!
93
+ See also the [**Examples**](https://github.com/BrokenSource/TurboPipe/tree/main/examples) folder for comparisons, and [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow/blob/main/ShaderFlow/Scene.py) usage of it!
88
94
 
89
95
  ```python
90
96
  import subprocess
@@ -106,7 +112,7 @@ ffmpeg = subprocess.Popen(
106
112
  for _ in range(60 * 60):
107
113
  turbopipe.pipe(buffer, ffmpeg.stdin.fileno())
108
114
 
109
- # Finalize writing
115
+ # Finalize writing, encoding
110
116
  turbopipe.sync()
111
117
  ffmpeg.stdin.close()
112
118
  ffmpeg.wait()
@@ -148,9 +154,9 @@ ffmpeg.wait()
148
154
  | 🐢 | Null | 1 | 882 fps | 2.44 GB/s | |
149
155
  | 🚀 | Null | 1 | 793 fps | 2.19 GB/s | -10.04% |
150
156
  | 🌀 | Null | 1 | 1911 fps | 5.28 GB/s | 116.70% |
151
- | 🐢 | Null | 4 | 880 fps | 2.43 GB/s | |
152
- | 🚀 | Null | 4 | 924 fps | 2.56 GB/s | 5.05% |
153
- | 🌀 | Null | 4 | 2037 fps | 5.63 GB/s | 131.59% |
157
+ | 🐢 | Null | 4 | 857 fps | 2.37 GB/s | |
158
+ | 🚀 | Null | 4 | 891 fps | 2.47 GB/s | 4.05% |
159
+ | 🌀 | Null | 4 | 2309 fps | 6.38 GB/s | 169.45% |
154
160
  | 🐢 | ultrafast | 4 | 714 fps | 1.98 GB/s | |
155
161
  | 🚀 | ultrafast | 4 | 670 fps | 1.85 GB/s | -6.10% |
156
162
  | 🌀 | ultrafast | 4 | 1093 fps | 3.02 GB/s | 53.13% |
@@ -166,9 +172,9 @@ ffmpeg.wait()
166
172
  | 🐢 | Null | 4 | 390 fps | 2.43 GB/s | |
167
173
  | 🚀 | Null | 4 | 391 fps | 2.43 GB/s | 0.26% |
168
174
  | 🌀 | Null | 4 | 756 fps | 4.71 GB/s | 94.01% |
169
- | 🐢 | ultrafast | 4 | 277 fps | 1.73 GB/s | |
170
- | 🚀 | ultrafast | 4 | 270 fps | 1.68 GB/s | -2.40% |
171
- | 🌀 | ultrafast | 4 | 402 fps | 2.50 GB/s | 45.32% |
175
+ | 🐢 | ultrafast | 4 | 269 fps | 1.68 GB/s | |
176
+ | 🚀 | ultrafast | 4 | 272 fps | 1.70 GB/s | 1.48% |
177
+ | 🌀 | ultrafast | 4 | 409 fps | 2.55 GB/s | 52.29% |
172
178
  | 🐢 | slow | 4 | 115 fps | 0.72 GB/s | |
173
179
  | 🚀 | slow | 4 | 118 fps | 0.74 GB/s | 3.40% |
174
180
  | 🌀 | slow | 4 | 119 fps | 0.75 GB/s | 4.34% |
@@ -178,9 +184,9 @@ ffmpeg.wait()
178
184
  | 🐢 | Null | 1 | 210 fps | 2.33 GB/s | |
179
185
  | 🚀 | Null | 1 | 239 fps | 2.64 GB/s | 13.84% |
180
186
  | 🌀 | Null | 1 | 534 fps | 5.91 GB/s | 154.32% |
181
- | 🐢 | Null | 4 | 233 fps | 2.58 GB/s | |
182
- | 🚀 | Null | 4 | 232 fps | 2.57 GB/s | -0.08% |
183
- | 🌀 | Null | 4 | 495 fps | 5.48 GB/s | 112.64% |
187
+ | 🐢 | Null | 4 | 219 fps | 2.43 GB/s | |
188
+ | 🚀 | Null | 4 | 231 fps | 2.56 GB/s | 5.64% |
189
+ | 🌀 | Null | 4 | 503 fps | 5.56 GB/s | 129.75% |
184
190
  | 🐢 | ultrafast | 4 | 141 fps | 1.56 GB/s | |
185
191
  | 🚀 | ultrafast | 4 | 150 fps | 1.67 GB/s | 6.92% |
186
192
  | 🌀 | ultrafast | 4 | 226 fps | 2.50 GB/s | 60.37% |
@@ -360,9 +366,7 @@ On realistically loads, like [**ShaderFlow**](https://github.com/BrokenSource/Sh
360
366
 
361
367
  # 📚 Future work
362
368
 
363
- - Add support for NumPy arrays, memoryviews, and byte-like objects
364
369
  - Disable/investigate performance degradation on Windows iGPUs
365
370
  - Improve the thread synchronization and/or use a ThreadPool
366
- - Stabler way for finding mglo struct offsets (moderngl.h?)
367
371
  - Maybe use `mmap` instead of chunks writing on Linux
368
- - Test on MacOS 🙈
372
+ - Test on macOS 🙈
@@ -1,11 +1,17 @@
1
1
  > [!IMPORTANT]
2
2
  > <sub>Also check out [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow), where **TurboPipe** shines! 😉</sub>
3
-
3
+ <!-- PyPI -->
4
4
  <div align="center">
5
5
  <a href="https://brokensrc.dev/"><img src="https://raw.githubusercontent.com/BrokenSource/TurboPipe/main/turbopipe/resources/images/turbopipe.png" width="200"></a>
6
6
  <h1>TurboPipe</h1>
7
+ Faster <a href="https://github.com/moderngl/moderngl"><b>ModernGL Buffers</b></a> inter-process data transfers for subprocesses
8
+ <br>
7
9
  <br>
8
- Faster <a href="https://github.com/moderngl/moderngl"><b>ModernGL</b></a> inter-process data transfers
10
+ <a href="https://pypi.org/project/turbopipe/"><img src="https://img.shields.io/pypi/v/turbopipe?label=PyPI&color=blue"></a>
11
+ <a href="https://pypi.org/project/turbopipe/"><img src="https://img.shields.io/pypi/dw/turbopipe?label=Installs&color=blue"></a>
12
+ <a href="https://github.com/BrokenSource/TurboPipe"><img src="https://img.shields.io/github/v/tag/BrokenSource/TurboPipe?label=GitHub&color=orange"></a>
13
+ <a href="https://github.com/BrokenSource/TurboPipe/stargazers"><img src="https://img.shields.io/github/stars/BrokenSource/TurboPipe?label=Stars&style=flat&color=orange"></a>
14
+ <a href="https://discord.gg/KjqvcYwRHm"><img src="https://img.shields.io/discord/1184696441298485370?label=Discord&style=flat&color=purple"></a>
9
15
  </div>
10
16
 
11
17
  <br>
@@ -18,7 +24,7 @@ The **optimizations** involved are:
18
24
 
19
25
  - **Zero-copy**: Avoid unnecessary memory copies or allocation (intermediate `buffer.read()`)
20
26
  - **C++**: The core of TurboPipe is written in C++ for speed, efficiency and low-level control
21
- - **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy
27
+ - **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy (Unix)
22
28
  - **Threaded**:
23
29
  - Doesn't block Python code execution, allows to render next frame
24
30
  - Decouples the main thread from the I/O thread for performance
@@ -33,7 +39,7 @@ It couldn't be easier! Just install the [**`turbopipe`**](https://pypi.org/proje
33
39
 
34
40
  ```bash
35
41
  # With pip (https://pip.pypa.io/)
36
- python -m pip install turbopipe
42
+ pip install turbopipe
37
43
 
38
44
  # With Poetry (https://python-poetry.org/)
39
45
  poetry add turbopipe
@@ -49,7 +55,7 @@ rye add turbopipe
49
55
 
50
56
  # 🚀 Usage
51
57
 
52
- See also the [**Examples**](https://github.com/BrokenSource/TurboPipe/tree/main/examples) folder for more controlled usage, and [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow/blob/main/ShaderFlow/Scene.py) usage of it!
58
+ See also the [**Examples**](https://github.com/BrokenSource/TurboPipe/tree/main/examples) folder for comparisons, and [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow/blob/main/ShaderFlow/Scene.py) usage of it!
53
59
 
54
60
  ```python
55
61
  import subprocess
@@ -71,7 +77,7 @@ ffmpeg = subprocess.Popen(
71
77
  for _ in range(60 * 60):
72
78
  turbopipe.pipe(buffer, ffmpeg.stdin.fileno())
73
79
 
74
- # Finalize writing
80
+ # Finalize writing, encoding
75
81
  turbopipe.sync()
76
82
  ffmpeg.stdin.close()
77
83
  ffmpeg.wait()
@@ -113,9 +119,9 @@ ffmpeg.wait()
113
119
  | 🐢 | Null | 1 | 882 fps | 2.44 GB/s | |
114
120
  | 🚀 | Null | 1 | 793 fps | 2.19 GB/s | -10.04% |
115
121
  | 🌀 | Null | 1 | 1911 fps | 5.28 GB/s | 116.70% |
116
- | 🐢 | Null | 4 | 880 fps | 2.43 GB/s | |
117
- | 🚀 | Null | 4 | 924 fps | 2.56 GB/s | 5.05% |
118
- | 🌀 | Null | 4 | 2037 fps | 5.63 GB/s | 131.59% |
122
+ | 🐢 | Null | 4 | 857 fps | 2.37 GB/s | |
123
+ | 🚀 | Null | 4 | 891 fps | 2.47 GB/s | 4.05% |
124
+ | 🌀 | Null | 4 | 2309 fps | 6.38 GB/s | 169.45% |
119
125
  | 🐢 | ultrafast | 4 | 714 fps | 1.98 GB/s | |
120
126
  | 🚀 | ultrafast | 4 | 670 fps | 1.85 GB/s | -6.10% |
121
127
  | 🌀 | ultrafast | 4 | 1093 fps | 3.02 GB/s | 53.13% |
@@ -131,9 +137,9 @@ ffmpeg.wait()
131
137
  | 🐢 | Null | 4 | 390 fps | 2.43 GB/s | |
132
138
  | 🚀 | Null | 4 | 391 fps | 2.43 GB/s | 0.26% |
133
139
  | 🌀 | Null | 4 | 756 fps | 4.71 GB/s | 94.01% |
134
- | 🐢 | ultrafast | 4 | 277 fps | 1.73 GB/s | |
135
- | 🚀 | ultrafast | 4 | 270 fps | 1.68 GB/s | -2.40% |
136
- | 🌀 | ultrafast | 4 | 402 fps | 2.50 GB/s | 45.32% |
140
+ | 🐢 | ultrafast | 4 | 269 fps | 1.68 GB/s | |
141
+ | 🚀 | ultrafast | 4 | 272 fps | 1.70 GB/s | 1.48% |
142
+ | 🌀 | ultrafast | 4 | 409 fps | 2.55 GB/s | 52.29% |
137
143
  | 🐢 | slow | 4 | 115 fps | 0.72 GB/s | |
138
144
  | 🚀 | slow | 4 | 118 fps | 0.74 GB/s | 3.40% |
139
145
  | 🌀 | slow | 4 | 119 fps | 0.75 GB/s | 4.34% |
@@ -143,9 +149,9 @@ ffmpeg.wait()
143
149
  | 🐢 | Null | 1 | 210 fps | 2.33 GB/s | |
144
150
  | 🚀 | Null | 1 | 239 fps | 2.64 GB/s | 13.84% |
145
151
  | 🌀 | Null | 1 | 534 fps | 5.91 GB/s | 154.32% |
146
- | 🐢 | Null | 4 | 233 fps | 2.58 GB/s | |
147
- | 🚀 | Null | 4 | 232 fps | 2.57 GB/s | -0.08% |
148
- | 🌀 | Null | 4 | 495 fps | 5.48 GB/s | 112.64% |
152
+ | 🐢 | Null | 4 | 219 fps | 2.43 GB/s | |
153
+ | 🚀 | Null | 4 | 231 fps | 2.56 GB/s | 5.64% |
154
+ | 🌀 | Null | 4 | 503 fps | 5.56 GB/s | 129.75% |
149
155
  | 🐢 | ultrafast | 4 | 141 fps | 1.56 GB/s | |
150
156
  | 🚀 | ultrafast | 4 | 150 fps | 1.67 GB/s | 6.92% |
151
157
  | 🌀 | ultrafast | 4 | 226 fps | 2.50 GB/s | 60.37% |
@@ -325,9 +331,7 @@ On realistically loads, like [**ShaderFlow**](https://github.com/BrokenSource/Sh
325
331
 
326
332
  # 📚 Future work
327
333
 
328
- - Add support for NumPy arrays, memoryviews, and byte-like objects
329
334
  - Disable/investigate performance degradation on Windows iGPUs
330
335
  - Improve the thread synchronization and/or use a ThreadPool
331
- - Stabler way for finding mglo struct offsets (moderngl.h?)
332
336
  - Maybe use `mmap` instead of chunks writing on Linux
333
- - Test on MacOS 🙈
337
+ - Test on macOS 🙈
@@ -28,7 +28,6 @@ endif
28
28
  # ----------------------------------------------|
29
29
  # Source files
30
30
 
31
- incdir = include_directories('turbopipe/include')
32
31
  source = files('turbopipe/_turbopipe.cpp')
33
32
 
34
33
  # ----------------------------------------------|
@@ -37,7 +36,6 @@ python = import('python').find_installation()
37
36
 
38
37
  python.extension_module(
39
38
  '_turbopipe', source,
40
- include_directories: incdir,
41
39
  cpp_args: cpp_args,
42
40
  install: true,
43
41
  subdir: 'turbopipe'
@@ -7,7 +7,7 @@ homepage = "https://brokensrc.dev"
7
7
  [project]
8
8
  name = "turbopipe"
9
9
  dynamic = ["version"]
10
- description = "🌀 Faster ModernGL Buffer inter process data transfers"
10
+ description = "🌀 Faster MemoryView inter-process data transfers for subprocesses"
11
11
  authors = [{name="Tremeschin", email="29046864+Tremeschin@users.noreply.github.com"}]
12
12
  readme = "Readme.md"
13
13
  license = {file="License.md"}
@@ -15,8 +15,15 @@ dependencies = ["moderngl"]
15
15
  requires-python = ">=3.7"
16
16
 
17
17
  [build-system]
18
- requires = ["meson-python", "ninja"]
18
+ requires = ["meson-python", "ninja", "hatch-fancy-pypi-readme"]
19
19
  build-backend = "mesonpy"
20
20
 
21
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
22
+ content-type = "text/markdown"
23
+
24
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
25
+ start-after = "<!-- PyPI -->"
26
+ path = "Readme.md"
27
+
21
28
  [tool.ruff.format]
22
29
  exclude = ["*"]
@@ -1,13 +1,13 @@
1
- from io import IOBase
1
+ from typing import Union
2
2
 
3
3
  from moderngl import Buffer
4
4
 
5
5
  from turbopipe import _turbopipe
6
6
 
7
7
 
8
- def pipe(buffer: Buffer, file: IOBase) -> None:
8
+ def pipe(buffer: Union[Buffer, memoryview], fileno: int) -> None:
9
9
  """
10
- Pipe the content of a moderngl.Buffer to a file descriptor,
10
+ Pipe the content of a moderngl.Buffer or memoryview to a file descriptor,
11
11
  Fast, threaded and non-blocking. Call `sync()` when done!
12
12
 
13
13
  Usage:
@@ -24,7 +24,10 @@ def pipe(buffer: Buffer, file: IOBase) -> None:
24
24
  turbopipe.pipe(buffer, child.stdin.fileno())
25
25
  ```
26
26
  """
27
- _turbopipe.pipe(buffer.mglo, file)
27
+ if isinstance(buffer, Buffer):
28
+ buffer = memoryview(buffer.mglo)
29
+ _turbopipe.pipe(buffer, fileno)
30
+ del buffer
28
31
 
29
32
  def sync() -> None:
30
33
  """Waits for all jobs to finish"""
@@ -1,6 +1,6 @@
1
1
  // ------------------------------------------------------------------------------------------------|
2
2
  //
3
- // TurboPipe - Faster ModernGL Buffer inter process data transfers
3
+ // TurboPipe - Faster ModernGL Buffers inter-process data transfers for subprocesses
4
4
  //
5
5
  // (c) 2024, Tremeschin, MIT License
6
6
  //
@@ -11,7 +11,6 @@
11
11
 
12
12
  // Standard library
13
13
  #include <functional>
14
- #include <iostream>
15
14
  #include <chrono>
16
15
 
17
16
  // Threading
@@ -24,60 +23,9 @@
24
23
  #include <unordered_map>
25
24
  #include <deque>
26
25
 
27
- // Third party
28
- #include "gl_methods.hpp"
29
-
30
26
  #define dict std::unordered_map
31
27
  using namespace std;
32
28
 
33
- // ------------------------------------------------------------------------------------------------|
34
- // ModernGL Types - Courtesy of the moderngl package developers (MIT)
35
-
36
- static PyTypeObject* MGLBuffer_type = nullptr;
37
-
38
- struct MGLContext;
39
- struct MGLFramebuffer;
40
-
41
- struct MGLBuffer {
42
- PyObject_HEAD
43
- MGLContext* context;
44
- int buffer;
45
- Py_ssize_t size;
46
- bool dynamic;
47
- bool released;
48
- };
49
-
50
- struct MGLContext {
51
- PyObject_HEAD
52
- PyObject * ctx;
53
- PyObject * extensions;
54
- MGLFramebuffer * default_framebuffer;
55
- MGLFramebuffer * bound_framebuffer;
56
- PyObject * includes;
57
- int version_code;
58
- int max_samples;
59
- int max_integer_samples;
60
- int max_color_attachments;
61
- int max_texture_units;
62
- int default_texture_unit;
63
- float max_anisotropy;
64
- int enable_flags;
65
- int front_face;
66
- int cull_face;
67
- int depth_func;
68
- bool depth_clamp;
69
- double depth_range[2];
70
- int blend_func_src;
71
- int blend_func_dst;
72
- bool wireframe;
73
- bool multisample;
74
- int provoking_vertex;
75
- float polygon_offset_factor;
76
- float polygon_offset_units;
77
- GLMethods gl;
78
- bool released;
79
- };
80
-
81
29
  // ------------------------------------------------------------------------------------------------|
82
30
  // TurboPipe internals
83
31
 
@@ -96,14 +44,9 @@ public:
96
44
  TurboPipe(): running(true) {}
97
45
  ~TurboPipe() {close();}
98
46
 
99
- void pipe(MGLBuffer* buffer, int file) {
100
- const GLMethods& gl = buffer->context->gl;
101
-
102
- gl.BindBuffer(GL_ARRAY_BUFFER, buffer->buffer);
103
- void* data = gl.MapBufferRange(GL_ARRAY_BUFFER, 0, buffer->size, GL_MAP_READ_BIT);
104
- gl.UnmapBuffer(GL_ARRAY_BUFFER);
105
-
106
- this->_pipe(data, buffer->size, file);
47
+ void pipe(PyObject* memoryview, int file) {
48
+ Py_buffer view = *PyMemoryView_GET_BUFFER(memoryview);
49
+ this->_pipe(view.buf, view.len, file);
107
50
  }
108
51
 
109
52
  void sync() {
@@ -211,11 +154,15 @@ static PyObject* turbopipe_pipe(
211
154
  PyObject* Py_UNUSED(self),
212
155
  PyObject* args
213
156
  ) {
214
- PyObject* buffer;
157
+ PyObject* memoryview;
215
158
  PyObject* file;
216
- if (!PyArg_ParseTuple(args, "OO", &buffer, &file))
159
+ if (!PyArg_ParseTuple(args, "OO", &memoryview, &file))
217
160
  return NULL;
218
- turbopipe->pipe((MGLBuffer*) buffer, PyLong_AsLong(file));
161
+ if (!PyMemoryView_Check(memoryview)) {
162
+ PyErr_SetString(PyExc_TypeError, "Expected a memoryview object");
163
+ return NULL;
164
+ }
165
+ turbopipe->pipe(memoryview, PyLong_AsLong(file));
219
166
  Py_RETURN_NONE;
220
167
  }
221
168
 
@@ -259,9 +206,8 @@ static struct PyModuleDef turbopipe_module = {
259
206
 
260
207
  PyMODINIT_FUNC PyInit__turbopipe(void) {
261
208
  PyObject* module = PyModule_Create(&turbopipe_module);
262
- PyObject* moderngl = PyImport_ImportModule("moderngl");
263
- PyObject* buffer = PyObject_GetAttrString(moderngl, "Buffer");
264
- MGLBuffer_type = (PyTypeObject*) buffer;
209
+ if (module == NULL)
210
+ return NULL;
265
211
  turbopipe = new TurboPipe();
266
212
  Py_AtExit(turbopipe_exit);
267
213
  return module;
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env python3
2
+ __version__ = "1.1.0"
3
+
4
+ if __name__ == "__main__":
5
+ print(__version__)
@@ -1,42 +0,0 @@
1
- name: debug
2
-
3
- on:
4
- workflow_dispatch:
5
-
6
- jobs:
7
- wheels:
8
- name: Build ${{matrix.pyver}} wheels on ${{matrix.os}}
9
- runs-on: ${{matrix.os}}
10
- strategy:
11
- matrix:
12
- os: [windows-latest]
13
- pyver: [cp311]
14
-
15
- env:
16
- CIBW_BUILD: ${{matrix.pyver}}-*
17
- CIBW_ARCHS_LINUX: auto
18
- CIBW_ARCHS_MACOS: arm64
19
- CIBW_ARCHS_WINDOWS: auto
20
- CIBW_SKIP: '*musllinux* *i686* *-win32'
21
-
22
- steps:
23
- - uses: actions/checkout@v4
24
- - uses: actions/setup-python@v5
25
-
26
- - name: Prepare MSVC
27
- if: matrix.os == 'windows-latest'
28
- uses: bus1/cabuild/action/msdevshell@v1
29
- with:
30
- architecture: x64
31
-
32
- - name: deps
33
- run: python -m pip install build
34
-
35
- - name: wheels
36
- run: python -m build
37
-
38
- - name: upload
39
- uses: actions/upload-artifact@v3
40
- with:
41
- name: package
42
- path: dist/*.whl