turboapi 0.4.12__cp314-cp314t-macosx_11_0_arm64.whl
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.
- turboapi/__init__.py +24 -0
- turboapi/async_limiter.py +86 -0
- turboapi/async_pool.py +141 -0
- turboapi/decorators.py +69 -0
- turboapi/main_app.py +314 -0
- turboapi/middleware.py +342 -0
- turboapi/models.py +148 -0
- turboapi/request_handler.py +227 -0
- turboapi/routing.py +219 -0
- turboapi/rust_integration.py +335 -0
- turboapi/security.py +542 -0
- turboapi/server_integration.py +436 -0
- turboapi/turbonet.cpython-314t-darwin.so +0 -0
- turboapi/version_check.py +268 -0
- turboapi-0.4.12.dist-info/METADATA +31 -0
- turboapi-0.4.12.dist-info/RECORD +17 -0
- turboapi-0.4.12.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TurboAPI Free-Threading Version Check
|
|
4
|
+
Ensures TurboAPI only runs on Python 3.13+ free-threading builds
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import io
|
|
8
|
+
import sys
|
|
9
|
+
import threading
|
|
10
|
+
|
|
11
|
+
# Configure stdout to use UTF-8 encoding on Windows
|
|
12
|
+
if sys.platform == 'win32':
|
|
13
|
+
# Ensure UTF-8 encoding for print() on Windows
|
|
14
|
+
if hasattr(sys.stdout, 'reconfigure'):
|
|
15
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
16
|
+
elif not isinstance(sys.stdout, io.TextIOWrapper):
|
|
17
|
+
# Fallback for older Python or special stdout
|
|
18
|
+
import codecs
|
|
19
|
+
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict')
|
|
20
|
+
|
|
21
|
+
# Define symbols that work across all platforms
|
|
22
|
+
CHECK_MARK = "[OK]"
|
|
23
|
+
CROSS_MARK = "[X]"
|
|
24
|
+
ROCKET = "[ROCKET]"
|
|
25
|
+
THREAD = "[THREAD]"
|
|
26
|
+
BULB = "[INFO]"
|
|
27
|
+
TARGET = "[TARGET]"
|
|
28
|
+
BOOK = "[DOCS]"
|
|
29
|
+
MAG = "[CHECK]"
|
|
30
|
+
PARTY = "[SUCCESS]"
|
|
31
|
+
|
|
32
|
+
# Try to use Unicode emojis if the terminal supports it
|
|
33
|
+
try:
|
|
34
|
+
# Test if we can encode/print emojis
|
|
35
|
+
test_str = "โ
"
|
|
36
|
+
if sys.platform == 'win32':
|
|
37
|
+
# On Windows, test if console can display the emoji
|
|
38
|
+
test_str.encode(sys.stdout.encoding or 'utf-8')
|
|
39
|
+
# If we get here, emojis work
|
|
40
|
+
CHECK_MARK = "โ
"
|
|
41
|
+
CROSS_MARK = "โ"
|
|
42
|
+
ROCKET = "๐"
|
|
43
|
+
THREAD = "๐งต"
|
|
44
|
+
BULB = "๐ก"
|
|
45
|
+
TARGET = "๐ฏ"
|
|
46
|
+
BOOK = "๐"
|
|
47
|
+
MAG = "๐"
|
|
48
|
+
PARTY = "๐"
|
|
49
|
+
except (UnicodeEncodeError, LookupError, AttributeError):
|
|
50
|
+
# Fallback to ASCII symbols already set above
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def check_free_threading_support():
|
|
55
|
+
"""
|
|
56
|
+
Check if Python is running with free-threading (no-GIL) enabled.
|
|
57
|
+
Raises ImportError if not compatible.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
# Check Python version first
|
|
61
|
+
|
|
62
|
+
# Check for free-threading build (multiple detection methods)
|
|
63
|
+
is_free_threading = _detect_free_threading()
|
|
64
|
+
|
|
65
|
+
if not is_free_threading:
|
|
66
|
+
raise ImportError(
|
|
67
|
+
f"{CROSS_MARK} TurboAPI requires Python free-threading build (no-GIL).\n"
|
|
68
|
+
f" Current: Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} with GIL enabled\n"
|
|
69
|
+
f" \n"
|
|
70
|
+
f" {THREAD} Free-threading required for:\n"
|
|
71
|
+
f" โข 5-10x performance improvements\n"
|
|
72
|
+
f" โข True multi-threading parallelism\n"
|
|
73
|
+
f" โข Zero Python middleware overhead\n"
|
|
74
|
+
f" โข Rust-native concurrency\n"
|
|
75
|
+
f" \n"
|
|
76
|
+
f" Install free-threading Python:\n"
|
|
77
|
+
f" โข python3.13t (if available)\n"
|
|
78
|
+
f" โข pyenv install 3.13t-dev\n"
|
|
79
|
+
f" โข Build from source: ./configure --disable-gil\n"
|
|
80
|
+
f" \n"
|
|
81
|
+
f" {ROCKET} Experience revolutionary performance with free-threading!\n"
|
|
82
|
+
f" {BOOK} See: PYTHON_FREE_THREADING_GUIDE.md"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Success! Print confirmation
|
|
86
|
+
print(f"{CHECK_MARK} TurboAPI: Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} free-threading detected!")
|
|
87
|
+
print(f"{THREAD} True parallelism enabled - ready for 5-10x performance!")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _detect_free_threading():
|
|
91
|
+
"""
|
|
92
|
+
Detect if Python is running in free-threading mode.
|
|
93
|
+
Uses multiple detection methods for reliability.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
# Method 1: Check for GIL-related functions (most reliable)
|
|
97
|
+
try:
|
|
98
|
+
# In free-threading builds, some GIL-related functions are removed/modified
|
|
99
|
+
if not hasattr(sys, '_current_frames'):
|
|
100
|
+
return True
|
|
101
|
+
except Exception:
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
# Method 2: Check sys.flags for free-threading flag
|
|
105
|
+
try:
|
|
106
|
+
if hasattr(sys, 'flags') and hasattr(sys.flags, 'nogil'):
|
|
107
|
+
return sys.flags.nogil
|
|
108
|
+
except Exception:
|
|
109
|
+
pass
|
|
110
|
+
|
|
111
|
+
# Method 3: Check threading module behavior
|
|
112
|
+
try:
|
|
113
|
+
# In free-threading, threading.get_ident() behavior changes
|
|
114
|
+
import threading
|
|
115
|
+
# This is a heuristic - may need adjustment based on actual free-threading behavior
|
|
116
|
+
if hasattr(threading, '_thread') and hasattr(threading._thread, 'get_native_id'):
|
|
117
|
+
# Free-threading builds often have enhanced native thread support
|
|
118
|
+
return True
|
|
119
|
+
except Exception:
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
# Method 4: Check interpreter flags in sys
|
|
123
|
+
try:
|
|
124
|
+
if hasattr(sys, 'implementation') and hasattr(sys.implementation, 'name'):
|
|
125
|
+
# Check if implementation has free-threading indicators
|
|
126
|
+
if 'free' in sys.implementation.name.lower() or 'nogil' in str(sys.implementation):
|
|
127
|
+
return True
|
|
128
|
+
except Exception:
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
# Method 5: Check version string for free-threading indicators
|
|
132
|
+
try:
|
|
133
|
+
version_str = sys.version.lower()
|
|
134
|
+
if 'free-threading' in version_str or 'nogil' in version_str or '+free' in version_str:
|
|
135
|
+
return True
|
|
136
|
+
except Exception:
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
# Method 6: Check for experimental free-threading modules
|
|
140
|
+
try:
|
|
141
|
+
# Free-threading builds may have special modules
|
|
142
|
+
import _thread
|
|
143
|
+
if hasattr(_thread, 'get_native_id') and not hasattr(sys, '_current_frames'):
|
|
144
|
+
return True
|
|
145
|
+
except Exception:
|
|
146
|
+
pass
|
|
147
|
+
|
|
148
|
+
# Method 7: Runtime test - try true parallel execution
|
|
149
|
+
try:
|
|
150
|
+
return _test_parallel_execution()
|
|
151
|
+
except Exception:
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
# Default: assume GIL is present
|
|
155
|
+
return False
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _test_parallel_execution():
|
|
159
|
+
"""
|
|
160
|
+
Runtime test to detect if threads can execute Python code in parallel.
|
|
161
|
+
This is the most definitive test but also the most expensive.
|
|
162
|
+
"""
|
|
163
|
+
import threading
|
|
164
|
+
import time
|
|
165
|
+
|
|
166
|
+
# Quick parallel execution test
|
|
167
|
+
results = []
|
|
168
|
+
start_times = []
|
|
169
|
+
|
|
170
|
+
def worker():
|
|
171
|
+
start_times.append(time.time())
|
|
172
|
+
# CPU work that would be blocked by GIL
|
|
173
|
+
total = sum(i * i for i in range(10000))
|
|
174
|
+
results.append(total)
|
|
175
|
+
|
|
176
|
+
# Start threads simultaneously
|
|
177
|
+
threads = [threading.Thread(target=worker) for _ in range(2)]
|
|
178
|
+
|
|
179
|
+
overall_start = time.time()
|
|
180
|
+
for t in threads:
|
|
181
|
+
t.start()
|
|
182
|
+
|
|
183
|
+
for t in threads:
|
|
184
|
+
t.join()
|
|
185
|
+
|
|
186
|
+
overall_time = time.time() - overall_start
|
|
187
|
+
|
|
188
|
+
# If threads started within 1ms of each other and completed quickly,
|
|
189
|
+
# it's likely true parallelism (no GIL blocking)
|
|
190
|
+
if len(start_times) >= 2:
|
|
191
|
+
start_spread = max(start_times) - min(start_times)
|
|
192
|
+
# True parallelism: threads start nearly simultaneously and complete fast
|
|
193
|
+
if start_spread < 0.01 and overall_time < 0.05: # 10ms start spread, 50ms total
|
|
194
|
+
return True
|
|
195
|
+
|
|
196
|
+
return False
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def get_python_threading_info():
|
|
200
|
+
"""Get detailed information about Python threading capabilities."""
|
|
201
|
+
info = {
|
|
202
|
+
'python_version': f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
|
|
203
|
+
'free_threading': _detect_free_threading(),
|
|
204
|
+
'gil_enabled': hasattr(sys, '_current_frames'),
|
|
205
|
+
'threading_native_id': hasattr(threading._thread, 'get_native_id') if hasattr(threading, '_thread') else False,
|
|
206
|
+
'implementation': sys.implementation.name if hasattr(sys, 'implementation') else 'unknown',
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
# Add performance prediction
|
|
210
|
+
if info['free_threading']:
|
|
211
|
+
info['performance_multiplier'] = '5-10x FastAPI'
|
|
212
|
+
info['concurrency'] = 'True parallelism'
|
|
213
|
+
info['gil_overhead'] = 'Zero (Rust-native)'
|
|
214
|
+
else:
|
|
215
|
+
info['performance_multiplier'] = 'Limited by GIL'
|
|
216
|
+
info['concurrency'] = 'Serialized threads'
|
|
217
|
+
info['gil_overhead'] = 'High (Python bottleneck)'
|
|
218
|
+
|
|
219
|
+
return info
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
# Perform the check when module is imported
|
|
223
|
+
if __name__ != "__main__":
|
|
224
|
+
try:
|
|
225
|
+
check_free_threading_support()
|
|
226
|
+
except ImportError as e:
|
|
227
|
+
# Re-raise with additional context
|
|
228
|
+
raise ImportError(
|
|
229
|
+
f"{e}\n\n"
|
|
230
|
+
f"{BULB} TurboAPI is designed exclusively for free-threading Python builds.\n"
|
|
231
|
+
f" This ensures maximum performance and true parallelism.\n"
|
|
232
|
+
f" \n"
|
|
233
|
+
f" {TARGET} Why free-threading only?\n"
|
|
234
|
+
f" โข 5-10x performance gains over FastAPI\n"
|
|
235
|
+
f" โข True multi-threading without GIL bottlenecks\n"
|
|
236
|
+
f" โข Rust-native concurrency integration\n"
|
|
237
|
+
f" โข Future-proof architecture\n"
|
|
238
|
+
f" \n"
|
|
239
|
+
f" {BOOK} Setup Guide: PYTHON_FREE_THREADING_GUIDE.md\n"
|
|
240
|
+
) from e
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
if __name__ == "__main__":
|
|
244
|
+
# Direct execution - show diagnostic information
|
|
245
|
+
print(f"{MAG} TurboAPI Python Free-Threading Compatibility Check")
|
|
246
|
+
print("=" * 60)
|
|
247
|
+
|
|
248
|
+
info = get_python_threading_info()
|
|
249
|
+
|
|
250
|
+
print(f"Python Version: {info['python_version']}")
|
|
251
|
+
print(f"Implementation: {info['implementation']}")
|
|
252
|
+
print(f"Free-Threading: {CHECK_MARK + ' YES' if info['free_threading'] else CROSS_MARK + ' NO'}")
|
|
253
|
+
print(f"GIL Enabled: {CROSS_MARK + ' YES' if info['gil_enabled'] else CHECK_MARK + ' NO'}")
|
|
254
|
+
print(f"Native Thread ID: {CHECK_MARK + ' YES' if info['threading_native_id'] else CROSS_MARK + ' NO'}")
|
|
255
|
+
print()
|
|
256
|
+
print(f"Expected Performance: {info['performance_multiplier']}")
|
|
257
|
+
print(f"Concurrency Model: {info['concurrency']}")
|
|
258
|
+
print(f"GIL Overhead: {info['gil_overhead']}")
|
|
259
|
+
|
|
260
|
+
print("\n" + "=" * 60)
|
|
261
|
+
|
|
262
|
+
try:
|
|
263
|
+
check_free_threading_support()
|
|
264
|
+
print(f"{PARTY} TurboAPI compatibility: PASSED")
|
|
265
|
+
print(f"{ROCKET} Ready for revolutionary performance!")
|
|
266
|
+
except ImportError as e:
|
|
267
|
+
print(f"{CROSS_MARK} TurboAPI compatibility: FAILED")
|
|
268
|
+
print(f" {e}")
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: turboapi
|
|
3
|
+
Version: 0.4.12
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Classifier: Programming Language :: Rust
|
|
11
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
13
|
+
Requires-Dist: satya>=0.4.0
|
|
14
|
+
Requires-Dist: pytest>=7.0.0 ; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest-asyncio>=0.21.0 ; extra == 'dev'
|
|
16
|
+
Requires-Dist: ruff==0.13.2 ; extra == 'dev'
|
|
17
|
+
Requires-Dist: mypy>=1.0.0 ; extra == 'dev'
|
|
18
|
+
Requires-Dist: httpx>=0.24.0 ; extra == 'benchmark'
|
|
19
|
+
Requires-Dist: uvloop>=0.17.0 ; extra == 'benchmark'
|
|
20
|
+
Requires-Dist: matplotlib>=3.5.0 ; extra == 'benchmark'
|
|
21
|
+
Requires-Dist: seaborn>=0.11.0 ; extra == 'benchmark'
|
|
22
|
+
Requires-Dist: pandas>=1.3.0 ; extra == 'benchmark'
|
|
23
|
+
Requires-Dist: requests>=2.25.0 ; extra == 'benchmark'
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Provides-Extra: benchmark
|
|
26
|
+
Summary: Revolutionary Python web framework with FastAPI syntax and 12x performance - Pure Rust Async Runtime (Python 3.13+ free-threading required)
|
|
27
|
+
Keywords: web,framework,http,server,rust,performance,free-threading,no-gil,fastapi-compatible
|
|
28
|
+
Home-Page: https://github.com/justrach/turboAPI
|
|
29
|
+
Author-email: Rach Pradhan <rach@turboapi.dev>
|
|
30
|
+
License: MIT
|
|
31
|
+
Requires-Python: >=3.13
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
turboapi-0.4.12.dist-info/METADATA,sha256=IBt2GTnjmkVpSOn-PzMpMzXtwdB4jcqesqC2Bvj64_E,1482
|
|
2
|
+
turboapi-0.4.12.dist-info/WHEEL,sha256=7YkbvGPyO4S4VhLSbt938HzEQY4G0UD-jiXTURzdsKE,105
|
|
3
|
+
turboapi/__init__.py,sha256=Fs0UWaxFgDuTi80VKQ7MGc4tBMTi5-wx-r59IbhGkos,668
|
|
4
|
+
turboapi/async_limiter.py,sha256=qblDnGvnMH3fH7C_s1Rapwgfp9RJ375U3-eVElsONN4,2330
|
|
5
|
+
turboapi/async_pool.py,sha256=jITdIXDJ6s5K-YSnMouavr6HfewDrj6uYrGX0V_ynk4,4348
|
|
6
|
+
turboapi/decorators.py,sha256=CKxjVpMpwR0NnviyXISjNt_clL9cB_ZG8h3hhhusNMY,1719
|
|
7
|
+
turboapi/main_app.py,sha256=FnaTmKuR9CjOgvhOrxYV3b8aNXYpHW1Pt1oudUdMx-s,11364
|
|
8
|
+
turboapi/middleware.py,sha256=AhLL8OHc9ELH3jEsA-UgRkCq3FXFAY6M8fc-CMRd48w,10858
|
|
9
|
+
turboapi/models.py,sha256=YT5BiHdt1mGAJjmSfcv10vayRD0FWU4DzeVa6sAL2cw,5215
|
|
10
|
+
turboapi/request_handler.py,sha256=cuxJ7L_GDrYnLJ8dKhiI61qnG3fd77VFygT7luPUVpA,8186
|
|
11
|
+
turboapi/routing.py,sha256=lfWja7OWD8OEHcX5UuKBtC8oQauVyI7qOzKNSAE-N98,7527
|
|
12
|
+
turboapi/rust_integration.py,sha256=rDmGUTtX7TzSxyePTLTGZyELLrdssOa2h726qYHakEs,14595
|
|
13
|
+
turboapi/security.py,sha256=M-N75sIDrxKGVI3k6adhVMYYOVVUPq_qSzS_ArQierE,16688
|
|
14
|
+
turboapi/server_integration.py,sha256=cnyT4Eqrw3lkZjdVkDvN2qMH5yXh68LJhC2w9ccH9Qc,17904
|
|
15
|
+
turboapi/turbonet.cpython-314t-darwin.so,sha256=bUTv-1hgpfQjOieKkVbSzWO-6lvRyej4OpzypKY2VdQ,3151936
|
|
16
|
+
turboapi/version_check.py,sha256=NmKEt9Qloi5NrGYvVusjFTDhMhZzZfazuXyjcOPO2vc,9357
|
|
17
|
+
turboapi-0.4.12.dist-info/RECORD,,
|