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
@@ -0,0 +1,294 @@
1
+ import argparse
2
+ import subprocess
3
+ import venv
4
+ import json
5
+ import re
6
+ from pathlib import Path
7
+ from ..console import (
8
+ log,
9
+ get_progress,
10
+ run_command_with_output,
11
+ )
12
+ import shutil
13
+
14
+ from .helpers import get_venv_python_path
15
+ from .plugin import perform_plugin_install
16
+
17
+ REQUIREMENTS_JSON = Path("requirements.json")
18
+
19
+
20
+ def load_requirements() -> dict:
21
+ if REQUIREMENTS_JSON.exists():
22
+ try:
23
+ data = json.loads(REQUIREMENTS_JSON.read_text())
24
+ if "plugins" not in data:
25
+ data["plugins"] = []
26
+ return data
27
+ except json.JSONDecodeError:
28
+ log(
29
+ f"Warning: {REQUIREMENTS_JSON} is invalid JSON. Using empty defaults.",
30
+ style="warning",
31
+ )
32
+ return {"dependencies": [], "plugins": []}
33
+
34
+
35
+ def save_requirements(data: dict):
36
+ REQUIREMENTS_JSON.write_text(json.dumps(data, indent=4))
37
+
38
+
39
+ def get_installed_packages(venv_python) -> dict[str, str]:
40
+ """Returns a dict of {package_name: version} for all installed packages."""
41
+ try:
42
+ cmd = [str(venv_python), "-m", "pip", "list", "--format=json"]
43
+ output = subprocess.check_output(cmd, text=True).strip()
44
+ data = json.loads(output)
45
+ return {item["name"].lower(): item["version"] for item in data}
46
+ except (subprocess.CalledProcessError, json.JSONDecodeError):
47
+ return {}
48
+
49
+
50
+ def get_package_name_from_source(path: Path) -> str | None:
51
+ """Attempts to read package name from pyproject.toml."""
52
+ try:
53
+ pyproject = path / "pyproject.toml"
54
+ if pyproject.exists():
55
+ content = pyproject.read_text(encoding="utf-8")
56
+ # Rudimentary TOML parsing for [project] name = "..."
57
+ match = re.search(r'(?m)^name\s*=\s*["\']([^"\']+)["\']', content)
58
+ if match:
59
+ return match.group(1).lower()
60
+ except Exception:
61
+ pass
62
+ return None
63
+
64
+
65
+ def cmd_install(args: argparse.Namespace) -> int:
66
+ """
67
+ Creates a virtual environment (if not exists) and installs dependencies.
68
+ If packages are provided, installs them and adds to requirements.json.
69
+ If no packages provided, installs from requirements.json.
70
+ """
71
+ venv_dir = Path("env")
72
+
73
+ # 1. Create virtual environment if it doesn't exist
74
+ if not venv_dir.exists():
75
+ log(f"Creating virtual environment in {venv_dir}...", style="info")
76
+ venv.create(venv_dir, with_pip=True)
77
+ else:
78
+ # Only print if we are doing a full install or explicit install to reassure user
79
+ pass
80
+
81
+ venv_python = get_venv_python_path(venv_dir)
82
+ if not venv_python.exists():
83
+ log(f"Error: Python executable not found at {venv_python}", style="error")
84
+ return 1
85
+
86
+ packages_to_install = args.packages
87
+ req_data = load_requirements()
88
+ current_deps = req_data.get("dependencies", [])
89
+ current_plugins = req_data.get("plugins", [])
90
+
91
+ if packages_to_install:
92
+ if getattr(args, "plugin", False):
93
+ # Handle Plugin Installation
94
+ for plugin_id in packages_to_install:
95
+ ret = perform_plugin_install(plugin_id)
96
+ if ret == 0:
97
+ if plugin_id not in current_plugins:
98
+ current_plugins.append(plugin_id)
99
+ else:
100
+ return 1
101
+
102
+ req_data["plugins"] = sorted(list(set(current_plugins)))
103
+ save_requirements(req_data)
104
+ log(f"Added plugins to {REQUIREMENTS_JSON}", style="success")
105
+ return 0
106
+
107
+ # Warn about versionless packages
108
+ for pkg in packages_to_install:
109
+ # Check if it's a local path
110
+ if Path(pkg).exists():
111
+ pass # Local path
112
+ elif not any(op in pkg for op in ["==", ">=", "<=", "<", ">", "@"]):
113
+ log(
114
+ f"Warning: No version specified for '{pkg}'. Installing latest version.",
115
+ style="warning",
116
+ )
117
+
118
+ log(f"Installing: {', '.join(packages_to_install)}")
119
+
120
+ # Snapshot before
121
+ before_state = get_installed_packages(venv_python)
122
+
123
+ try:
124
+ # Install packages
125
+ progress = get_progress()
126
+ progress.start()
127
+ task = progress.add_task("Installing...", total=None)
128
+
129
+ # Use run_command_with_output to stream logs cleanly above the progress bar
130
+ ret = run_command_with_output(
131
+ [str(venv_python), "-m", "pip", "install", "--no-build-isolation"]
132
+ + packages_to_install
133
+ )
134
+
135
+ progress.stop()
136
+ if ret != 0:
137
+ log("pip install failed", style="error")
138
+ return 1
139
+
140
+ # Snapshot after
141
+ after_state = get_installed_packages(venv_python)
142
+
143
+ updated = False
144
+
145
+ for pkg_arg in packages_to_install:
146
+ # Resolve package name
147
+ resolved_name = None
148
+
149
+ # Case 1: Local Path (e.g., D:\lib or ./lib)
150
+ if Path(pkg_arg).exists():
151
+ # Strategy A: Try to read name from source (pyproject.toml)
152
+ resolved_name = get_package_name_from_source(Path(pkg_arg))
153
+
154
+ if not resolved_name:
155
+ # Strategy B: Heuristic from pip list diff
156
+ candidates = []
157
+ for name, ver in after_state.items():
158
+ if name not in before_state:
159
+ candidates.append(name)
160
+ elif before_state.get(name) != ver:
161
+ candidates.append(name)
162
+
163
+ if len(candidates) == 1:
164
+ resolved_name = candidates[0]
165
+ elif len(candidates) > 1:
166
+ # Fuzzy match guess
167
+ guess = (
168
+ Path(pkg_arg)
169
+ .name.replace("-", "_")
170
+ .split(".")[0]
171
+ .lower()
172
+ )
173
+ for cand in candidates:
174
+ if guess in cand or cand in guess:
175
+ resolved_name = cand
176
+ break
177
+
178
+ # Strategy C: Check folder name against installed packages
179
+ if not resolved_name:
180
+ folder_name = Path(pkg_arg).name.lower()
181
+ if folder_name in after_state:
182
+ resolved_name = folder_name
183
+ else:
184
+ norm_folder = folder_name.replace("-", "_")
185
+ if norm_folder in after_state:
186
+ resolved_name = norm_folder
187
+
188
+ # Case 2: Package Name (e.g., "requests")
189
+ else:
190
+ match = re.split(r"[=<>@]", pkg_arg)
191
+ resolved_name = match[0].strip().lower()
192
+
193
+ # Get Version & Update Config
194
+ if resolved_name and resolved_name in after_state:
195
+ resolved_version = after_state[resolved_name]
196
+ entry = f"{resolved_name}=={resolved_version}"
197
+
198
+ # Remove old entry if exists (replacement logic)
199
+ new_deps = []
200
+ replaced = False
201
+ for dep in current_deps:
202
+ dep_name = re.split(r"[=<>@]", dep)[0].strip().lower()
203
+ if dep_name == resolved_name:
204
+ new_deps.append(entry)
205
+ replaced = True
206
+ else:
207
+ new_deps.append(dep)
208
+
209
+ if not replaced:
210
+ new_deps.append(entry)
211
+
212
+ current_deps = new_deps
213
+ updated = True
214
+ else:
215
+ log(
216
+ f"Warning: Could not resolve installed version for '{pkg_arg}'. Skipping requirement update.",
217
+ style="warning",
218
+ )
219
+
220
+ if updated:
221
+ req_data["dependencies"] = sorted(list(set(current_deps)))
222
+ save_requirements(req_data)
223
+ log(f"Added to {REQUIREMENTS_JSON}", style="success")
224
+
225
+ except subprocess.CalledProcessError as e:
226
+ log(f"Error installing packages: {e}", style="error")
227
+ return 1
228
+ else:
229
+ # Install from requirements.json
230
+ current_plugins = req_data.get("plugins", [])
231
+
232
+ if not current_deps and not current_plugins:
233
+ log(
234
+ f"No dependencies or plugins found in {REQUIREMENTS_JSON}.",
235
+ style="warning",
236
+ )
237
+ return 0
238
+
239
+ if current_deps:
240
+ log(f"Installing dependencies from {REQUIREMENTS_JSON}...")
241
+ try:
242
+ progress = get_progress()
243
+ progress.start()
244
+ task = progress.add_task("Syncing Dependencies...", total=None)
245
+
246
+ ret = run_command_with_output(
247
+ [str(venv_python), "-m", "pip", "install", "--no-build-isolation"]
248
+ + current_deps
249
+ )
250
+
251
+ progress.stop()
252
+ if ret == 0:
253
+ log("Dependencies installed successfully.", style="success")
254
+ else:
255
+ log("Failed to install dependencies.", style="error")
256
+ return 1
257
+ except Exception as e:
258
+ if "progress" in locals():
259
+ progress.stop()
260
+ log(f"Error installing dependencies: {e}", style="error")
261
+ return 1
262
+
263
+ if current_plugins:
264
+ log(f"Installing plugins from {REQUIREMENTS_JSON}...")
265
+ for plugin_id in current_plugins:
266
+ ret = perform_plugin_install(plugin_id)
267
+ if ret != 0:
268
+ log(f"Failed to install plugin: {plugin_id}", style="error")
269
+ return 1
270
+
271
+ # 3. Frontend Dependencies (NPM/Yarn/Bun)
272
+ frontend_dir = Path("frontend")
273
+ if frontend_dir.exists() and (frontend_dir / "package.json").exists():
274
+ log(f"Detected frontend in {frontend_dir}. Syncing NPM dependencies...")
275
+ provider = req_data.get("provider", "npm")
276
+ provider_bin = shutil.which(provider)
277
+
278
+ if provider_bin:
279
+ try:
280
+ # Run install in the frontend directory
281
+ subprocess.check_call([provider_bin, "install"], cwd=frontend_dir)
282
+ log(
283
+ "Frontend dependencies installed successfully.", style="success"
284
+ )
285
+ except subprocess.CalledProcessError as e:
286
+ log(f"Failed to install frontend dependencies: {e}", style="error")
287
+ return 1
288
+ else:
289
+ log(
290
+ f"Warning: '{provider}' not found. Please install '{provider}' to sync frontend dependencies.",
291
+ style="warning",
292
+ )
293
+
294
+ return 0
@@ -0,0 +1,130 @@
1
+ import argparse
2
+ import keyring
3
+ import time
4
+ import webbrowser
5
+ import requests
6
+ from ..console import log
7
+
8
+ SERVICE_NAME = "pytron-kit"
9
+ ACCOUNT_NAME = "github-token"
10
+ # NOTE: Replace this with the actual Client ID from your GitHub OAuth App
11
+ CLIENT_ID = "Ov23linvJ7QhMWN2tOth"
12
+
13
+
14
+ def cmd_login(args: argparse.Namespace) -> int:
15
+ log("GitHub Device Login", style="info")
16
+
17
+ # 1. Ask GitHub for a "Device Code"
18
+ try:
19
+ response = requests.post(
20
+ "https://github.com/login/device/code",
21
+ headers={"Accept": "application/json"},
22
+ data={"client_id": CLIENT_ID, "scope": "read:user"},
23
+ timeout=10,
24
+ )
25
+ data = response.json()
26
+
27
+ if "error" in data:
28
+ log(
29
+ f"GitHub Error: {data.get('error_description', data['error'])}",
30
+ style="error",
31
+ )
32
+ log(
33
+ "Make sure the Client ID is correct and Device Flow is enabled in GitHub settings.",
34
+ style="info",
35
+ )
36
+ return 1
37
+
38
+ device_code = data["device_code"]
39
+ user_code = data["user_code"] # e.g., "WDJB-VJTW"
40
+ verification_uri = data["verification_uri"] # github.com/login/device
41
+ interval = data["interval"] # How often to check
42
+
43
+ # 2. Show the user what to do
44
+ log(f"1. Copy your one-time code: [bold green]{user_code}[/bold green]")
45
+ log(f"2. Visit: {verification_uri}")
46
+
47
+ print("")
48
+ input("Press Enter to open the browser and authorize...")
49
+ webbrowser.open(verification_uri)
50
+
51
+ log("Waiting for authorization...", style="info")
52
+
53
+ # 3. Poll GitHub until the user clicks "Approve"
54
+ while True:
55
+ time.sleep(interval)
56
+
57
+ check_resp = requests.post(
58
+ "https://github.com/login/oauth/access_token",
59
+ headers={"Accept": "application/json"},
60
+ data={
61
+ "client_id": CLIENT_ID,
62
+ "device_code": device_code,
63
+ "grant_type": "urn:ietf:params:oauth:grant-type:device_code",
64
+ },
65
+ timeout=10,
66
+ )
67
+ token_data = check_resp.json()
68
+
69
+ if "access_token" in token_data:
70
+ token = token_data["access_token"]
71
+
72
+ # Success! Let's get the username for the welcome message
73
+ user_res = requests.get(
74
+ "https://api.github.com/user",
75
+ headers={"Authorization": f"token {token}"},
76
+ timeout=5,
77
+ )
78
+ username = (
79
+ user_res.json().get("login", "User")
80
+ if user_res.status_code == 200
81
+ else "User"
82
+ )
83
+
84
+ keyring.set_password(SERVICE_NAME, ACCOUNT_NAME, token)
85
+ log(f"Successfully logged in as @{username}!", style="success")
86
+ return 0
87
+
88
+ if "error" in token_data:
89
+ error = token_data["error"]
90
+ if error == "authorization_pending":
91
+ continue # Keep polling
92
+ elif error == "slow_down":
93
+ interval += 5 # GitHub is telling us to chill
94
+ elif error == "expired_token":
95
+ log("Code expired. Please run 'pytron login' again.", style="error")
96
+ return 1
97
+ else:
98
+ log(f"Authorization failed: {error}", style="error")
99
+ return 1
100
+ except Exception as e:
101
+ log(f"Login failed: {e}", style="error")
102
+ return 1
103
+
104
+
105
+ def cmd_logout(args: argparse.Namespace) -> int:
106
+ try:
107
+ keyring.delete_password(SERVICE_NAME, ACCOUNT_NAME)
108
+ log("Logged out. GitHub token removed from keyring.", style="success")
109
+ return 0
110
+ except keyring.errors.PasswordDeleteError:
111
+ log("Already logged out.", style="warning")
112
+ return 0
113
+ except Exception as e:
114
+ log(f"Logout failed: {e}", style="error")
115
+ return 1
116
+
117
+
118
+ def get_github_token() -> str | None:
119
+ import os
120
+
121
+ # Priority 1: Environment Variable (highest priority/override)
122
+ env_token = os.environ.get("PYTRON_GITHUB_TOKEN")
123
+ if env_token:
124
+ return env_token
125
+
126
+ # Priority 2: Keyring
127
+ try:
128
+ return keyring.get_password(SERVICE_NAME, ACCOUNT_NAME)
129
+ except Exception:
130
+ return None
@@ -0,0 +1,228 @@
1
+ import argparse
2
+ import json
3
+ import os
4
+ from pathlib import Path
5
+ from ..console import (
6
+ console,
7
+ log,
8
+ get_progress,
9
+ run_command_with_output,
10
+ Rule,
11
+ )
12
+ from .harvest import generate_nuclear_hooks
13
+ from .helpers import (
14
+ get_python_executable,
15
+ get_venv_site_packages,
16
+ )
17
+ from .utils import resolve_package_metadata
18
+ from ..pack.assets import get_smart_assets
19
+ from ..pack.installers import build_installer
20
+ from ..pack.utils import cleanup_dist
21
+ from ..pack.nuitka import run_nuitka_build
22
+ from ..pack.pyinstaller import run_pyinstaller_build
23
+ from ..pack.secure import run_secure_build
24
+
25
+
26
+ def cmd_package(args: argparse.Namespace) -> int:
27
+ script_path = args.script
28
+ if not script_path:
29
+ script_path = "app.py"
30
+
31
+ script = Path(script_path)
32
+ # Resolve script path early for reliable relative lookups
33
+ script = script.resolve()
34
+ if not script.exists():
35
+ log(f"Script not found: {script}", style="error")
36
+ return 1
37
+
38
+ console.print(Rule("[bold cyan]Pytron Builder"))
39
+
40
+ progress = get_progress()
41
+ task = progress.add_task("Starting...", total=100)
42
+ progress.start()
43
+
44
+ # If the user provided a .spec file, use it directly
45
+ if script.suffix == ".spec":
46
+ log(f"Packaging using spec file: {script}")
47
+ progress.update(task, description="Building from Spec...", completed=10)
48
+ # When using a spec file, most other arguments are ignored by PyInstaller
49
+ # as the spec file contains the configuration.
50
+ # Prepare and optionally generate hooks from the current venv so PyInstaller
51
+ # includes missing dynamic imports/binaries. Only generate hooks if user
52
+ # requested via CLI flags (`--collect-all` or `--force-hooks`).
53
+ temp_hooks_dir = None
54
+ env = None
55
+ try:
56
+ if getattr(args, "collect_all", False) or getattr(
57
+ args, "force_hooks", False
58
+ ):
59
+ temp_hooks_dir = script.parent / "build" / "nuclear_hooks"
60
+ collect_mode = getattr(args, "collect_all", False)
61
+
62
+ # Get venv site-packages to ensure we harvest the correct environment
63
+ python_exe = get_python_executable()
64
+ site_packages = get_venv_site_packages(python_exe)
65
+
66
+ generate_nuclear_hooks(
67
+ temp_hooks_dir,
68
+ collect_all_mode=collect_mode,
69
+ search_path=site_packages,
70
+ )
71
+ except Exception as e:
72
+ log(f"Warning: failed to generate nuclear hooks: {e}", style="warning")
73
+
74
+ cmd = [get_python_executable(), "-m", "PyInstaller"]
75
+ cmd.append(str(script))
76
+ cmd.append("--noconfirm")
77
+
78
+ log(f"Running: {' '.join(cmd)}", style="dim")
79
+
80
+ if env is not None:
81
+ ret_code = run_command_with_output(cmd, env=env, style="dim")
82
+ else:
83
+ ret_code = run_command_with_output(cmd, style="dim")
84
+
85
+ # Cleanup
86
+ if ret_code == 0:
87
+ out_name = args.name or script.stem
88
+ cleanup_dist(Path("dist") / out_name)
89
+
90
+ # If installer was requested, we still try to build it
91
+ if ret_code == 0 and args.installer:
92
+ progress.update(task, description="Building Installer...", completed=80)
93
+ out_name = args.name or script.stem
94
+ ret_code = build_installer(out_name, script.parent, args.icon)
95
+
96
+ progress.update(task, description="Done!", completed=100)
97
+ progress.stop()
98
+ if ret_code == 0:
99
+ console.print(Rule("[bold green]Success"))
100
+ log(f"App packaged successfully: dist/{out_name}", style="bold green")
101
+ return ret_code
102
+
103
+ # Resolve output name and load settings
104
+ out_name, settings = resolve_package_metadata(script, args.name)
105
+
106
+ # --- Modular Build Pipeline ---
107
+ from ..pack.pipeline import BuildContext, Pipeline
108
+ from ..pack.modules import (
109
+ AssetModule,
110
+ EngineModule,
111
+ MetadataModule,
112
+ InstallerModule,
113
+ PluginModule,
114
+ HookModule,
115
+ IconModule,
116
+ )
117
+
118
+ # Initialize Context
119
+ ctx = BuildContext(
120
+ script=script,
121
+ out_name=out_name,
122
+ app_icon=args.icon,
123
+ settings=settings,
124
+ engine=args.engine or ("chrome" if args.chrome else None),
125
+ is_secure=args.secure,
126
+ is_nuitka=args.nuitka,
127
+ is_onefile=args.one_file,
128
+ progress=progress,
129
+ task_id=task,
130
+ )
131
+
132
+ # Pass through some CLI flags to context for module use
133
+ ctx.smart_assets = args.smart_assets
134
+ ctx.build_installer = args.installer
135
+ ctx.bundled = args.bundled
136
+ ctx.collect_all = getattr(args, "collect_all", False)
137
+ ctx.force_hooks = getattr(args, "force_hooks", False)
138
+ ctx.add_data = args.add_data or []
139
+
140
+ # --- Crystal Integrity Check ---
141
+ if getattr(args, "crystal", False):
142
+ from ..pack.crystal import AppAuditor
143
+
144
+ auditor = AppAuditor(script)
145
+ log(f"Running Crystal Integrity Check on {script}...", style="cyan")
146
+
147
+ # Run the audit (this generates requirements.lock.json)
148
+ manifest = auditor.run_audit()
149
+
150
+ if manifest:
151
+ # Inject discovered modules as hidden imports for the builder
152
+ discovered_modules = manifest.get("modules", [])
153
+ log(
154
+ f"Crystal detected {len(discovered_modules)} hidden dependencies.",
155
+ style="green",
156
+ )
157
+
158
+ current_hidden = settings.get("hidden_imports", [])
159
+ # Merge unique items
160
+ settings["hidden_imports"] = list(set(current_hidden + discovered_modules))
161
+
162
+ # Also ensure data files are tracked if needed (future expansion)
163
+ # data_files = manifest.get("files", [])
164
+
165
+ # Initialize Pipeline
166
+ pipeline = Pipeline(ctx)
167
+
168
+ # Add Modules
169
+ pipeline.add_module(IconModule())
170
+ pipeline.add_module(AssetModule())
171
+ pipeline.add_module(HookModule())
172
+ pipeline.add_module(EngineModule())
173
+ pipeline.add_module(
174
+ PluginModule()
175
+ ) # Important: Plugin module handles custom add_data
176
+
177
+ if args.secure and ctx.engine != "rust":
178
+ from ..pack.secure import SecurityModule
179
+
180
+ pipeline.add_module(SecurityModule())
181
+
182
+ if args.fortress:
183
+ try:
184
+ from fortress import FortressModule
185
+
186
+ pipeline.add_module(
187
+ FortressModule(
188
+ use_cython=not args.no_cython,
189
+ use_optimization=not args.no_shake,
190
+ patch_from=args.patch_from,
191
+ )
192
+ )
193
+ log("Fortress Architecture enabled.", style="cyan")
194
+ except ImportError:
195
+ log(
196
+ "Error: 'pytron-fortress' package not found. Run 'pip install -e pytron-suite/fortress' to use this feature.",
197
+ style="error",
198
+ )
199
+ return 1
200
+
201
+ pipeline.add_module(MetadataModule())
202
+ pipeline.add_module(InstallerModule())
203
+
204
+ # Run Pipeline with Core Compiler
205
+ if ctx.engine == "rust":
206
+ from ..pack.rust_engine import RustEngine
207
+
208
+ rust_engine = RustEngine()
209
+ # Rust Engine handles the entire build process natively
210
+ ret_code = pipeline.run(rust_engine.build)
211
+
212
+ elif args.nuitka:
213
+ from ..pack.nuitka import run_nuitka_build
214
+
215
+ # TODO: Refactor Nuitka to use BuildContext too for full parity
216
+ # For now, we'll call it with a compatible shim if possible or just original args
217
+ # But let's prioritize PyInstaller for this refactor
218
+ ret_code = pipeline.run(run_nuitka_build)
219
+ else:
220
+ from ..pack.pyinstaller import run_pyinstaller_build
221
+
222
+ ret_code = pipeline.run(run_pyinstaller_build)
223
+
224
+ progress.stop()
225
+ if ret_code == 0:
226
+ console.print(Rule("[bold green]Success"))
227
+ log(f"App packaged successfully: dist/{ctx.out_name}", style="bold green")
228
+ return ret_code