pytron-kit 0.3.12__py3-none-macosx_11_0_universal2.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.
Files changed (419) hide show
  1. pytron/__init__.py +112 -0
  2. pytron/application.py +562 -0
  3. pytron/apputils/__init__.py +0 -0
  4. pytron/apputils/chrome_ipc.py +203 -0
  5. pytron/apputils/codegen.py +261 -0
  6. pytron/apputils/config.py +303 -0
  7. pytron/apputils/deadmansswitch.py +47 -0
  8. pytron/apputils/extras.py +76 -0
  9. pytron/apputils/native.py +148 -0
  10. pytron/apputils/shell.py +73 -0
  11. pytron/apputils/windows.py +286 -0
  12. pytron/cli.py +384 -0
  13. pytron/commands/__init__.py +0 -0
  14. pytron/commands/android.py +28 -0
  15. pytron/commands/build.py +26 -0
  16. pytron/commands/doctor.py +221 -0
  17. pytron/commands/engine.py +23 -0
  18. pytron/commands/frontend.py +60 -0
  19. pytron/commands/harvest.py +112 -0
  20. pytron/commands/helpers.py +239 -0
  21. pytron/commands/info.py +50 -0
  22. pytron/commands/init.py +521 -0
  23. pytron/commands/install.py +294 -0
  24. pytron/commands/login.py +130 -0
  25. pytron/commands/package.py +228 -0
  26. pytron/commands/plugin.py +442 -0
  27. pytron/commands/run.py +312 -0
  28. pytron/commands/scan.py +210 -0
  29. pytron/commands/show.py +23 -0
  30. pytron/commands/uninstall.py +150 -0
  31. pytron/commands/utils.py +42 -0
  32. pytron/commands/workflow.py +95 -0
  33. pytron/console.py +133 -0
  34. pytron/core.py +18 -0
  35. pytron/dependencies/WebView2Loader.dll +0 -0
  36. pytron/dependencies/__init__.py +1 -0
  37. pytron/dependencies/pytron_native.so +0 -0
  38. pytron/engines/chrome/adapter.py +445 -0
  39. pytron/engines/chrome/engine.py +576 -0
  40. pytron/engines/chrome/forge.py +147 -0
  41. pytron/engines/chrome/shell/package.json +8 -0
  42. pytron/engines/chrome/shell/preload.js +12 -0
  43. pytron/engines/chrome/shell/shell.js +534 -0
  44. pytron/exceptions.py +36 -0
  45. pytron/inspector.py +201 -0
  46. pytron/inspector_ui.py +512 -0
  47. pytron/installer/Installation.nsi +236 -0
  48. pytron/installer/header.bmp +0 -0
  49. pytron/installer/pytron.ico +0 -0
  50. pytron/installer/sidebar.bmp +0 -0
  51. pytron/llms.md +98 -0
  52. pytron/manifests/README.md +29 -0
  53. pytron/manifests/windows-utf8.manifest +44 -0
  54. pytron/menu.py +128 -0
  55. pytron/nsis-setup.exe +0 -0
  56. pytron/pack/__init__.py +0 -0
  57. pytron/pack/assets.py +131 -0
  58. pytron/pack/compilers.py +289 -0
  59. pytron/pack/crystal.py +297 -0
  60. pytron/pack/graph.py +377 -0
  61. pytron/pack/inference.py +157 -0
  62. pytron/pack/installers.py +402 -0
  63. pytron/pack/introspect.py +357 -0
  64. pytron/pack/metadata.py +213 -0
  65. pytron/pack/modules.py +618 -0
  66. pytron/pack/nuitka.py +108 -0
  67. pytron/pack/pipeline.py +107 -0
  68. pytron/pack/pyinstaller.py +176 -0
  69. pytron/pack/rust_engine.py +273 -0
  70. pytron/pack/secure.py +309 -0
  71. pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
  72. pytron/pack/secure_loader/icon.ico +0 -0
  73. pytron/pack/utils.py +110 -0
  74. pytron/pack/virtual_root.py +124 -0
  75. pytron/platforms/__init__.py +0 -0
  76. pytron/platforms/android/__init__.py +3 -0
  77. pytron/platforms/android/android.py +103 -0
  78. pytron/platforms/android/builder.py +736 -0
  79. pytron/platforms/android/ops/build.py +79 -0
  80. pytron/platforms/android/ops/init.py +63 -0
  81. pytron/platforms/android/ops/run.py +79 -0
  82. pytron/platforms/android/ops/sync.py +770 -0
  83. pytron/platforms/android/ops/utils.py +8 -0
  84. pytron/platforms/android/shell/README.md +30 -0
  85. pytron/platforms/android/shell/app/build.gradle +64 -0
  86. pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
  87. pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
  88. pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
  89. pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
  90. pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
  91. pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
  92. pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
  93. pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
  94. pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
  95. pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
  96. pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
  97. pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
  98. pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
  99. pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
  100. pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
  101. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
  102. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
  103. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
  104. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
  105. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
  106. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
  107. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
  108. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
  109. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
  110. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
  111. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
  112. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
  113. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
  114. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
  115. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
  116. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
  117. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
  118. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
  119. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
  120. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
  121. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
  122. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
  123. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
  124. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
  125. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
  126. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
  127. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
  128. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
  129. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
  130. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
  131. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
  132. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
  133. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
  134. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
  135. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
  136. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
  137. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
  138. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
  139. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
  140. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
  141. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
  142. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
  143. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
  144. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
  145. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
  146. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
  147. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
  148. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
  149. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
  150. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
  151. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
  152. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
  153. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
  154. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
  155. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
  156. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
  157. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
  158. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
  159. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
  160. pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
  161. pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
  162. pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
  163. pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
  164. pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
  165. pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
  166. pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
  167. pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
  168. pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
  169. pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
  170. pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
  171. pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
  172. pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
  173. pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
  174. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
  175. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
  176. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
  177. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
  178. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
  179. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
  180. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
  181. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
  182. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
  183. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
  184. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
  185. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
  186. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
  187. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
  188. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
  189. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
  190. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
  191. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
  192. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
  193. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
  194. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
  195. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
  196. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
  197. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
  198. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
  199. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
  200. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
  201. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
  202. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
  203. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
  204. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
  205. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
  206. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
  207. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
  208. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
  209. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
  210. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
  211. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
  212. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
  213. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
  214. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
  215. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
  216. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
  217. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
  218. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
  219. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
  220. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
  221. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
  222. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
  223. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
  224. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
  225. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
  226. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
  227. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
  228. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
  229. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
  230. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
  231. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
  232. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
  233. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
  234. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
  235. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
  236. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
  237. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
  238. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
  239. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
  240. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
  241. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
  242. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
  243. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
  244. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
  245. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
  246. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
  247. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
  248. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
  249. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
  250. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
  251. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
  252. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
  253. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
  254. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
  255. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
  256. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
  257. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
  258. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
  259. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
  260. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
  261. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
  262. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
  263. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
  264. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
  265. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
  266. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
  267. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
  268. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
  269. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
  270. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
  271. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
  272. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
  273. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
  274. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
  275. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
  276. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
  277. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
  278. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
  279. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
  280. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
  281. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
  282. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
  283. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
  284. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
  285. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
  286. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
  287. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
  288. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
  289. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
  290. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
  291. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
  292. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
  293. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
  294. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
  295. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
  296. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
  297. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
  298. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
  299. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
  300. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
  301. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
  302. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
  303. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
  304. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
  305. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
  306. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
  307. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
  308. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
  309. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
  310. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
  311. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
  312. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
  313. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
  314. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
  315. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
  316. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
  317. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
  318. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
  319. pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
  320. pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
  321. pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
  322. pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
  323. pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
  324. pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
  325. pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
  326. pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
  327. pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
  328. pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
  329. pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
  330. pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
  331. pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
  332. pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
  333. pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
  334. pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
  335. pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
  336. pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
  337. pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
  338. pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
  339. pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
  340. pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
  341. pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
  342. pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
  343. pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
  344. pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
  345. pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
  346. pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
  347. pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
  348. pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
  349. pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
  350. pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
  351. pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
  352. pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
  353. pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
  354. pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
  355. pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
  356. pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
  357. pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
  358. pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
  359. pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
  360. pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
  361. pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
  362. pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
  363. pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
  364. pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
  365. pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
  366. pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
  367. pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
  368. pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
  369. pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
  370. pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
  371. pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
  372. pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
  373. pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
  374. pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
  375. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  376. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  377. pytron/platforms/android/shell/build.gradle +11 -0
  378. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
  379. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
  380. pytron/platforms/android/shell/gradle.properties +2 -0
  381. pytron/platforms/android/shell/gradlew.bat +85 -0
  382. pytron/platforms/android/shell/settings.gradle +16 -0
  383. pytron/platforms/darwin.py +82 -0
  384. pytron/platforms/darwin_ops/libs.py +31 -0
  385. pytron/platforms/darwin_ops/system.py +182 -0
  386. pytron/platforms/darwin_ops/utils.py +85 -0
  387. pytron/platforms/darwin_ops/webview.py +5 -0
  388. pytron/platforms/darwin_ops/window.py +102 -0
  389. pytron/platforms/interface.py +152 -0
  390. pytron/platforms/linux.py +82 -0
  391. pytron/platforms/linux_ops/libs.py +49 -0
  392. pytron/platforms/linux_ops/system.py +316 -0
  393. pytron/platforms/linux_ops/utils.py +19 -0
  394. pytron/platforms/linux_ops/webview.py +5 -0
  395. pytron/platforms/linux_ops/window.py +115 -0
  396. pytron/platforms/windows.py +136 -0
  397. pytron/platforms/windows_ops/__init__.py +0 -0
  398. pytron/platforms/windows_ops/constants.py +126 -0
  399. pytron/platforms/windows_ops/system.py +518 -0
  400. pytron/platforms/windows_ops/utils.py +3 -0
  401. pytron/platforms/windows_ops/webview.py +5 -0
  402. pytron/platforms/windows_ops/window.py +361 -0
  403. pytron/plugin.py +467 -0
  404. pytron/rcedit-x64.exe +0 -0
  405. pytron/router.py +146 -0
  406. pytron/serializer.py +240 -0
  407. pytron/shortcuts.py +279 -0
  408. pytron/state.py +76 -0
  409. pytron/tray.py +399 -0
  410. pytron/updater.py +181 -0
  411. pytron/utf8_hook.py +112 -0
  412. pytron/utils.py +44 -0
  413. pytron/webview.py +722 -0
  414. pytron_kit-0.3.12.dist-info/METADATA +131 -0
  415. pytron_kit-0.3.12.dist-info/RECORD +419 -0
  416. pytron_kit-0.3.12.dist-info/WHEEL +5 -0
  417. pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
  418. pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
  419. pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
pytron/commands/run.py ADDED
@@ -0,0 +1,312 @@
1
+ import argparse
2
+ import sys
3
+ import shutil
4
+ import subprocess
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+ from ..console import log, console
9
+ from rich.text import Text
10
+ from .helpers import (
11
+ locate_frontend_dir,
12
+ run_frontend_build,
13
+ get_python_executable,
14
+ ensure_next_config,
15
+ get_config,
16
+ )
17
+
18
+ try:
19
+ from watchfiles import DefaultFilter
20
+ except ImportError:
21
+ DefaultFilter = object
22
+
23
+
24
+ class PytronFilter(DefaultFilter):
25
+ def __init__(self, frontend_dir: Path = None, **kwargs):
26
+ self.frontend_dir = frontend_dir.resolve() if frontend_dir else None
27
+ self.ignore_dirs = {
28
+ ".git",
29
+ "__pycache__",
30
+ "node_modules",
31
+ "dist",
32
+ "build",
33
+ ".next",
34
+ ".output",
35
+ "coverage",
36
+ "env",
37
+ "venv",
38
+ }
39
+ super().__init__(**kwargs)
40
+
41
+ def __call__(self, change, path):
42
+ path_obj = Path(path).resolve()
43
+
44
+ # 1. Ignore common heavy or build directories
45
+ if any(part in self.ignore_dirs for part in path_obj.parts):
46
+ return False
47
+
48
+ # 2. Frontend specific ignores
49
+ if self.frontend_dir:
50
+ try:
51
+ if (
52
+ self.frontend_dir in path_obj.parents
53
+ or self.frontend_dir == path_obj
54
+ ):
55
+ rel = path_obj.relative_to(self.frontend_dir)
56
+ # Ignore source and assets to let HMR handle it
57
+ if any(
58
+ str(rel).startswith(p)
59
+ for p in ["src", "public", "assets", "node_modules"]
60
+ ):
61
+ return False
62
+ except ValueError:
63
+ pass
64
+
65
+ # 3. Default filter (ignores binary files, etc.)
66
+ return super().__call__(change, path)
67
+
68
+
69
+ def run_dev_mode(script: Path, extra_args: list[str], engine: str = None) -> int:
70
+ try:
71
+ from watchfiles import watch
72
+ except ImportError:
73
+ log(
74
+ "watchfiles is required for --dev mode. Install it with: pip install watchfiles",
75
+ style="error",
76
+ )
77
+ return 1
78
+
79
+ frontend_dir = locate_frontend_dir(Path("."))
80
+ watcher_filter = PytronFilter(frontend_dir=frontend_dir)
81
+
82
+ npm_proc = None
83
+ dev_server_url = None
84
+
85
+ if frontend_dir:
86
+ config = get_config()
87
+ provider = config.get("frontend_provider", "npm")
88
+ provider_bin = shutil.which(provider)
89
+
90
+ if provider_bin:
91
+ pkg_path = frontend_dir / "package.json"
92
+ pkg_data = json.loads(pkg_path.read_text())
93
+ scripts = pkg_data.get("scripts", {})
94
+
95
+ if "dev" in scripts:
96
+ log(
97
+ f"Found 'dev' script. Starting development server using {provider}...",
98
+ style="success",
99
+ )
100
+
101
+ # Setup Environment
102
+ proc_env = os.environ.copy()
103
+ dev_port = config.get("dev_port")
104
+ if dev_port:
105
+ proc_env["PORT"] = str(dev_port)
106
+ # Force color for nicer output
107
+ proc_env["FORCE_COLOR"] = "1"
108
+
109
+ # We need to capture output to find the port, so PIPE it.
110
+ # But we also want the user to see it.
111
+ # We'll use a thread to read stdout and look for the URL.
112
+ npm_proc = subprocess.Popen(
113
+ [provider_bin, "run", "dev"],
114
+ cwd=str(frontend_dir),
115
+ shell=False,
116
+ stdout=subprocess.PIPE,
117
+ stderr=subprocess.STDOUT,
118
+ env=proc_env,
119
+ text=True,
120
+ bufsize=1,
121
+ ) # nosec B603
122
+
123
+ # Scan for URL in a background thread
124
+ import threading
125
+ import re
126
+
127
+ url_found_event = threading.Event()
128
+
129
+ def scan_output():
130
+ nonlocal dev_server_url
131
+ # Regex for Local: http://localhost:PORT
132
+ url_regex = re.compile(r"http://localhost:\d+")
133
+ # Regex to strip ANSI codes (colors)
134
+ ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
135
+
136
+ while npm_proc and npm_proc.poll() is None:
137
+ try:
138
+ line = npm_proc.stdout.readline()
139
+ if not line:
140
+ break
141
+ # Use Text.from_ansi to handle colors correctly
142
+ prefix = Text(f"[{provider}] ", style="dim")
143
+ content = Text.from_ansi(line.strip())
144
+ console.print(prefix + content)
145
+
146
+ if not dev_server_url:
147
+ # Strip ANSI codes to ensure clean matching
148
+ clean_line = ansi_escape.sub("", line)
149
+ match = url_regex.search(clean_line)
150
+ if match:
151
+ dev_server_url = match.group(0)
152
+ log(
153
+ f"Detected Dev Server URL: {dev_server_url}",
154
+ style="success",
155
+ )
156
+ url_found_event.set()
157
+ except Exception as e:
158
+ log(f"Error reading {provider} output: {e}", style="error")
159
+ break
160
+
161
+ t = threading.Thread(target=scan_output, daemon=True)
162
+ t.start()
163
+
164
+ # Wait for a bit to find the URL
165
+ print(f"[Pytron] Waiting for {provider} dev server to start...")
166
+ url_found_event.wait(timeout=30)
167
+
168
+ if not dev_server_url:
169
+ log(
170
+ "Warning: Could not detect dev server URL. Python app might load old build.",
171
+ style="warning",
172
+ )
173
+
174
+ else:
175
+ # Fallback to old behavior (build --watch)
176
+ # Check for watch script
177
+ try:
178
+ if "next" in pkg_data.get(
179
+ "dependencies", {}
180
+ ) or "next" in pkg_data.get("devDependencies", {}):
181
+ ensure_next_config(frontend_dir)
182
+ except Exception:
183
+ pass
184
+ args = ["run", "build"]
185
+
186
+ if "watch" in scripts:
187
+ log("Found 'watch' script, using it.", style="success")
188
+ args = ["run", "watch"]
189
+ else:
190
+ # We'll try to append --watch to build if it's vite
191
+ cmd_str = scripts.get("build", "")
192
+ if "vite" in cmd_str and "--watch" not in cmd_str:
193
+ log("Adding --watch to build command.")
194
+ args = ["run", "build", "--", "--watch"]
195
+ else:
196
+ log(
197
+ "No 'watch' script found, running build once.",
198
+ style="warning",
199
+ )
200
+
201
+ log(
202
+ f"Starting frontend watcher: {provider} {' '.join(args)}",
203
+ style="dim",
204
+ )
205
+ # Use shell=True for Windows compatibility
206
+ npm_proc = subprocess.Popen(
207
+ [provider_bin] + args,
208
+ cwd=str(frontend_dir),
209
+ shell=False,
210
+ ) # nosec B603
211
+ else:
212
+ log(f"{provider} not found, skipping frontend watch.", style="warning")
213
+
214
+ app_proc = None
215
+
216
+ def kill_app():
217
+ nonlocal app_proc
218
+ if app_proc:
219
+ if sys.platform == "win32":
220
+ # Force kill process tree on Windows to ensure no lingering windows
221
+ subprocess.run(
222
+ ["taskkill", "/F", "/T", "/PID", str(app_proc.pid)],
223
+ capture_output=True,
224
+ )
225
+ else:
226
+ app_proc.terminate()
227
+ try:
228
+ app_proc.wait(timeout=1)
229
+ except subprocess.TimeoutExpired:
230
+ app_proc.kill()
231
+ app_proc = None
232
+
233
+ def start_app():
234
+ nonlocal app_proc
235
+ kill_app()
236
+ log("Starting app...", style="info")
237
+ # Start as a subprocess we control
238
+ python_exe = get_python_executable()
239
+
240
+ env = os.environ.copy()
241
+ if dev_server_url:
242
+ env["PYTRON_DEV_URL"] = dev_server_url
243
+ if engine:
244
+ env["PYTRON_ENGINE"] = engine
245
+
246
+ app_proc = subprocess.Popen([python_exe, str(script)] + extra_args, env=env)
247
+
248
+ try:
249
+ start_app()
250
+ log(f"Watching for changes in {Path.cwd()}...", style="success")
251
+ for changes in watch(str(Path.cwd()), watch_filter=watcher_filter):
252
+ log(f"Detected changes: {changes}", style="dim")
253
+ # Filter out non-code changes manually if needed, but DevWatcher handles most
254
+ start_app()
255
+
256
+ except KeyboardInterrupt:
257
+ pass
258
+ except Exception as e:
259
+ log(f"Error in dev loop: {e}", style="error")
260
+ finally:
261
+ kill_app()
262
+ if npm_proc:
263
+ log("Stopping frontend watcher...", style="dim")
264
+ if sys.platform == "win32":
265
+ # Force kill the process tree to avoid "Terminate batch job (Y/N)?"
266
+ subprocess.run(
267
+ ["taskkill", "/F", "/T", "/PID", str(npm_proc.pid)],
268
+ stdout=subprocess.DEVNULL,
269
+ stderr=subprocess.DEVNULL,
270
+ )
271
+ else:
272
+ try:
273
+ npm_proc.terminate()
274
+ npm_proc.wait(timeout=2)
275
+ except Exception:
276
+ npm_proc.kill()
277
+
278
+ return 0
279
+
280
+
281
+ def cmd_run(args: argparse.Namespace) -> int:
282
+ script_path = args.script
283
+ if not script_path:
284
+ # Default to app.py in current directory
285
+ script_path = "app.py"
286
+
287
+ path = Path(script_path)
288
+ if not path.exists():
289
+ log(f"Script not found: {path}", style="error")
290
+ return 1
291
+
292
+ if not args.dev and not getattr(args, "no_build", False):
293
+ frontend_dir = locate_frontend_dir(path.parent)
294
+ if frontend_dir:
295
+ result = run_frontend_build(frontend_dir)
296
+ if result is False:
297
+ return 1
298
+
299
+ if args.dev:
300
+ engine = "chrome" if getattr(args, "chrome", False) else args.engine
301
+ return run_dev_mode(path, args.extra_args, engine=engine)
302
+
303
+ python_exe = get_python_executable()
304
+ env = os.environ.copy()
305
+ if getattr(args, "chrome", False):
306
+ env["PYTRON_ENGINE"] = "chrome"
307
+ elif args.engine:
308
+ env["PYTRON_ENGINE"] = args.engine
309
+
310
+ cmd = [python_exe, str(path)] + (args.extra_args or [])
311
+ log(f"Running: {' '.join(cmd)}", style="dim")
312
+ return subprocess.call(cmd, env=env)
@@ -0,0 +1,210 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from ..console import console, log, Rule
4
+ from ..pack.graph import GraphBuilder, DependencyOracle
5
+
6
+
7
+ def cmd_scan(args: argparse.Namespace) -> int:
8
+ """
9
+ Runs the 'Oracle Scan' on a target project.
10
+ Visualizes insights without building.
11
+ """
12
+ target = args.target if args.target else "."
13
+ project_path = Path(target).resolve()
14
+
15
+ if not project_path.exists():
16
+ log(f"Path not found: {project_path}", style="error")
17
+ return 1
18
+
19
+ console.print(Rule("[bold magenta]Pytron Dependency Oracle"))
20
+ console.print(f"Scanning target: [cyan]{project_path}[/cyan]")
21
+
22
+ # 1. Build Graph
23
+ try:
24
+ builder = GraphBuilder(project_path)
25
+ graph = builder.scan_project()
26
+ except Exception as e:
27
+ log(f"Scan failed: {e}", style="error")
28
+ return 1
29
+
30
+ console.print(f" Nodes: [bold]{len(graph.nodes)}[/bold]")
31
+ console.print(f" Edges: [bold]{len(graph.edges)}[/bold]")
32
+ console.print(
33
+ f" Uncertainty Zones: [bold red]{len(graph._uncertainty_zones)}[/bold red]"
34
+ )
35
+
36
+ # 2. Run Oracle
37
+ console.print(Rule("[bold yellow]Connecting to Brain..."))
38
+ oracle = DependencyOracle(graph)
39
+ oracle.predict()
40
+
41
+ # 3. Report Results
42
+ predictions = [e for e in graph.edges if e.type == "predicted"]
43
+
44
+ if predictions:
45
+ console.print(
46
+ f"Oracle made [bold green]{len(predictions)}[/bold green] inference(s):"
47
+ )
48
+ for pred in predictions:
49
+ confidence_style = "green" if pred.confidence > 0.8 else "yellow"
50
+ console.print(
51
+ f" Ref: [cyan]{pred.source}[/cyan] -> [bold {confidence_style}]{pred.target}[/bold {confidence_style}]"
52
+ )
53
+ console.print(f" Reason: [dim]{pred.reason}[/dim]")
54
+ console.print("")
55
+ else:
56
+ console.print(
57
+ "[dim]No dynamic anomalies detected. Standard build should suffice.[/dim]"
58
+ )
59
+
60
+ # 4. Show Uncertainty Zones (if unpredicted)
61
+ # Filter zones that didn't result in a prediction?
62
+ # For now, just show them all
63
+ if args.verbose and graph._uncertainty_zones:
64
+ console.print(Rule("[bold red]Uncertainty Zones"))
65
+ for zone in graph._uncertainty_zones:
66
+ console.print(f"[red]![/red] {zone['source']}:{zone['lineno']}")
67
+ console.print(f" Code: `{zone['code']}`")
68
+ console.print(f" Type: {zone['heuristic']}")
69
+ console.print("")
70
+
71
+ # 5. Export
72
+ if args.json:
73
+ out_file = project_path / "scan_report.json"
74
+ out_file.write_text(graph.to_json(), encoding="utf-8")
75
+ log(f"Report saved to {out_file}", style="success")
76
+
77
+ if getattr(args, "html", False):
78
+ html_path = project_path / "scan_graph.html"
79
+ generate_interactive_graph(graph, html_path)
80
+ log(f"Visual Graph saved to {html_path}", style="success")
81
+
82
+ return 0
83
+
84
+
85
+ def generate_interactive_graph(graph, out_path: Path):
86
+ """Generates a standalone HTML D3.js graph."""
87
+ import json
88
+
89
+ data = json.loads(graph.to_json())
90
+
91
+ # Simple D3 Template
92
+ html = """
93
+ <!DOCTYPE html>
94
+ <html>
95
+ <head>
96
+ <style>
97
+ body { margin: 0; background: #111; color: #eee; font-family: sans-serif; overflow: hidden; }
98
+ #graph { width: 100vw; height: 100vh; }
99
+ .node { stroke: #fff; stroke-width: 1.5px; }
100
+ .link { stroke: #555; stroke-opacity: 0.6; }
101
+ text { font-size: 10px; fill: #ccc; pointer-events: none; }
102
+ .tooltip { position: absolute; background: #333; padding: 5px; border: 1px solid #777; border-radius: 4px; display: none; }
103
+ </style>
104
+ <script src="https://d3js.org/d3.v7.min.js"></script>
105
+ </head>
106
+ <body>
107
+ <div id="graph"></div>
108
+ <div class="tooltip" id="tooltip"></div>
109
+ <script>
110
+ const data = __GRAPH_DATA__;
111
+
112
+ const width = window.innerWidth;
113
+ const height = window.innerHeight;
114
+
115
+ // Convert map to array
116
+ const nodes = Object.values(data.nodes).map(n => ({id: n.name, type: n.type}));
117
+ const links = data.edges.map(e => ({source: e.source, target: e.target, type: e.type, conf: e.confidence}));
118
+
119
+ const svg = d3.select("#graph").append("svg")
120
+ .attr("width", width)
121
+ .attr("height", height)
122
+ .call(d3.zoom().on("zoom", (event) => {
123
+ g.attr("transform", event.transform);
124
+ }));
125
+
126
+ const g = svg.append("g");
127
+
128
+ const simulation = d3.forceSimulation(nodes)
129
+ .force("link", d3.forceLink(links).id(d => d.id).distance(100))
130
+ .force("charge", d3.forceManyBody().strength(-300))
131
+ .force("center", d3.forceCenter(width / 2, height / 2));
132
+
133
+ const link = g.append("g")
134
+ .attr("class", "links")
135
+ .selectAll("line")
136
+ .data(links)
137
+ .enter().append("line")
138
+ .attr("class", "link")
139
+ .attr("stroke", d => d.type === "predicted" ? "#0f0" : "#555")
140
+ .attr("stroke-dasharray", d => d.type === "predicted" ? "5,5" : "0")
141
+ .attr("stroke-width", d => Math.max(1, d.conf * 3));
142
+
143
+ const node = g.append("g")
144
+ .attr("class", "nodes")
145
+ .selectAll("circle")
146
+ .data(nodes)
147
+ .enter().append("circle")
148
+ .attr("r", 5)
149
+ .attr("fill", d => d.type === "package" ? "#f00" : "#00f")
150
+ .call(d3.drag()
151
+ .on("start", dragstarted)
152
+ .on("drag", dragged)
153
+ .on("end", dragended));
154
+
155
+ const label = g.append("g")
156
+ .selectAll("text")
157
+ .data(nodes)
158
+ .enter().append("text")
159
+ .attr("dy", -10)
160
+ .text(d => d.id);
161
+
162
+ node.on("mouseover", (event, d) => {
163
+ d3.select("#tooltip")
164
+ .style("display", "block")
165
+ .style("left", (event.pageX + 10) + "px")
166
+ .style("top", (event.pageY - 10) + "px")
167
+ .html(`<strong>${d.id}</strong><br>${d.type}`);
168
+ }).on("mouseout", () => {
169
+ d3.select("#tooltip").style("display", "none");
170
+ });
171
+
172
+ simulation.on("tick", () => {
173
+ link
174
+ .attr("x1", d => d.source.x)
175
+ .attr("y1", d => d.source.y)
176
+ .attr("x2", d => d.target.x)
177
+ .attr("y2", d => d.target.y);
178
+
179
+ node
180
+ .attr("cx", d => d.x)
181
+ .attr("cy", d => d.y);
182
+
183
+ label
184
+ .attr("x", d => d.x)
185
+ .attr("y", d => d.y);
186
+ });
187
+
188
+ function dragstarted(event, d) {
189
+ if (!event.active) simulation.alphaTarget(0.3).restart();
190
+ d.fx = d.x;
191
+ d.fy = d.y;
192
+ }
193
+
194
+ function dragged(event, d) {
195
+ d.fx = event.x;
196
+ d.fy = event.y;
197
+ }
198
+
199
+ function dragended(event, d) {
200
+ if (!event.active) simulation.alphaTarget(0);
201
+ d.fx = null;
202
+ d.fy = null;
203
+ }
204
+ </script>
205
+ </body>
206
+ </html>
207
+ """
208
+
209
+ html = html.replace("__GRAPH_DATA__", json.dumps(data))
210
+ out_path.write_text(html, encoding="utf-8")
@@ -0,0 +1,23 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from .helpers import get_venv_python_path
4
+ from ..console import log, run_command_with_output
5
+
6
+
7
+ def cmd_show(args: argparse.Namespace) -> int:
8
+ """
9
+ Shows list of installed packages in the virtual environment.
10
+ """
11
+ venv_dir = Path("env")
12
+ venv_python = get_venv_python_path(venv_dir)
13
+
14
+ if not venv_python.exists():
15
+ log(
16
+ f"Virtual environment not found at {venv_dir}. Run 'pytron install' first.",
17
+ style="error",
18
+ )
19
+ return 1
20
+
21
+ log(f"Installed packages in {venv_dir}:")
22
+ ret = run_command_with_output([str(venv_python), "-m", "pip", "list"])
23
+ return ret
@@ -0,0 +1,150 @@
1
+ import re
2
+ import subprocess
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ from ..console import log, get_progress, run_command_with_output
7
+ from .helpers import get_venv_python_path
8
+
9
+ REQUIREMENTS_JSON = Path("requirements.json")
10
+
11
+
12
+ def load_requirements():
13
+ if REQUIREMENTS_JSON.exists():
14
+ try:
15
+ return json.loads(REQUIREMENTS_JSON.read_text())
16
+ except Exception:
17
+ return {"dependencies": []}
18
+ return {"dependencies": []}
19
+
20
+
21
+ def save_requirements(data):
22
+ REQUIREMENTS_JSON.write_text(json.dumps(data, indent=4))
23
+
24
+
25
+ def get_installed_packages(venv_python) -> dict[str, str]:
26
+ """Returns a dict of {package_name: version} for all installed packages."""
27
+ try:
28
+ cmd = [str(venv_python), "-m", "pip", "list", "--format=json"]
29
+ output = subprocess.check_output(
30
+ cmd, text=True, stderr=subprocess.DEVNULL
31
+ ).strip()
32
+ data = json.loads(output)
33
+ return {item["name"].lower(): item["version"] for item in data}
34
+ except Exception:
35
+ return {}
36
+
37
+
38
+ def get_package_name_from_source(path: Path) -> str | None:
39
+ """Attempts to read package name from pyproject.toml."""
40
+ try:
41
+ pyproject = path / "pyproject.toml"
42
+ if pyproject.exists():
43
+ content = pyproject.read_text(encoding="utf-8")
44
+ match = re.search(r'(?m)^name\s*=\s*["\']([^"\']+)["\']', content)
45
+ if match:
46
+ return match.group(1).lower()
47
+ except Exception:
48
+ pass
49
+ return None
50
+
51
+
52
+ def cmd_uninstall(args: argparse.Namespace) -> int:
53
+ """
54
+ Uninstalls dependencies from the project environment and updates requirements.json.
55
+ """
56
+ packages_to_uninstall = args.packages
57
+ if not packages_to_uninstall:
58
+ log("No packages specified to uninstall.", style="warning")
59
+ return 0
60
+
61
+ venv_dir = Path("env")
62
+ venv_python = get_venv_python_path(venv_dir)
63
+
64
+ # Resolve names for requirements.json removal
65
+ resolved_names = []
66
+ for pkg in packages_to_uninstall:
67
+ name = pkg.lower()
68
+ if Path(pkg).exists():
69
+ source_name = get_package_name_from_source(Path(pkg))
70
+ if source_name:
71
+ name = source_name
72
+ else:
73
+ # Last ditch: check if it's the current pytron-kit folder itself
74
+ name = Path(pkg).name.lower()
75
+ resolved_names.append(name)
76
+
77
+ if not venv_python.exists():
78
+ log(
79
+ f"Virtual environment not found at {venv_dir}. Only updating {REQUIREMENTS_JSON}.",
80
+ style="warning",
81
+ )
82
+ else:
83
+ log(f"Uninstalling: {', '.join(packages_to_uninstall)}")
84
+
85
+ progress = get_progress()
86
+ progress.start()
87
+ progress.add_task("Uninstalling...", total=None)
88
+
89
+ # -y for non-interactive uninstall
90
+ # We pass original args to pip because pip handles paths if it knows the package name is installed from it
91
+ # but usually it prefers the name.
92
+ pip_args = []
93
+ for pkg in packages_to_uninstall:
94
+ if Path(pkg).exists():
95
+ # If user passed a path, we try to use the resolved name for pip uninstall
96
+ # because pip uninstall <path> usually doesn't work (it wants the DIST name)
97
+ name = get_package_name_from_source(Path(pkg)) or Path(pkg).name.lower()
98
+ pip_args.append(name)
99
+ else:
100
+ pip_args.append(pkg)
101
+
102
+ cmd = [str(venv_python), "-m", "pip", "uninstall", "-y"] + pip_args
103
+ ret = run_command_with_output(cmd, style="dim")
104
+
105
+ progress.stop()
106
+
107
+ if ret == 0:
108
+ log("Packages uninstalled from environment successfully.", style="success")
109
+ else:
110
+ log("Some packages failed to uninstall or were not found.", style="warning")
111
+
112
+ # Update requirements.json
113
+ req_data = load_requirements()
114
+ current_deps = req_data.get("dependencies", [])
115
+
116
+ updated_deps = []
117
+ removed_count = 0
118
+
119
+ for dep in current_deps:
120
+ base_name = (
121
+ dep.split("==")[0]
122
+ .split(">=")[0]
123
+ .split("<=")[0]
124
+ .split("<")[0]
125
+ .split(">")[0]
126
+ .strip()
127
+ .lower()
128
+ )
129
+
130
+ should_remove = False
131
+ for name in resolved_names:
132
+ if name == base_name:
133
+ should_remove = True
134
+ break
135
+
136
+ if should_remove:
137
+ removed_count += 1
138
+ else:
139
+ updated_deps.append(dep)
140
+
141
+ if removed_count > 0:
142
+ req_data["dependencies"] = updated_deps
143
+ save_requirements(req_data)
144
+ log(f"Removed {removed_count} packages from {REQUIREMENTS_JSON}", style="info")
145
+ else:
146
+ log(f"No changes made to {REQUIREMENTS_JSON}", style="dim")
147
+
148
+ return 0
149
+
150
+ return 0