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.
- pytron/__init__.py +112 -0
- pytron/application.py +562 -0
- pytron/apputils/__init__.py +0 -0
- pytron/apputils/chrome_ipc.py +203 -0
- pytron/apputils/codegen.py +261 -0
- pytron/apputils/config.py +303 -0
- pytron/apputils/deadmansswitch.py +47 -0
- pytron/apputils/extras.py +76 -0
- pytron/apputils/native.py +148 -0
- pytron/apputils/shell.py +73 -0
- pytron/apputils/windows.py +286 -0
- pytron/cli.py +384 -0
- pytron/commands/__init__.py +0 -0
- pytron/commands/android.py +28 -0
- pytron/commands/build.py +26 -0
- pytron/commands/doctor.py +221 -0
- pytron/commands/engine.py +23 -0
- pytron/commands/frontend.py +60 -0
- pytron/commands/harvest.py +112 -0
- pytron/commands/helpers.py +239 -0
- pytron/commands/info.py +50 -0
- pytron/commands/init.py +521 -0
- pytron/commands/install.py +294 -0
- pytron/commands/login.py +130 -0
- pytron/commands/package.py +228 -0
- pytron/commands/plugin.py +442 -0
- pytron/commands/run.py +312 -0
- pytron/commands/scan.py +210 -0
- pytron/commands/show.py +23 -0
- pytron/commands/uninstall.py +150 -0
- pytron/commands/utils.py +42 -0
- pytron/commands/workflow.py +95 -0
- pytron/console.py +133 -0
- pytron/core.py +18 -0
- pytron/dependencies/WebView2Loader.dll +0 -0
- pytron/dependencies/__init__.py +1 -0
- pytron/dependencies/pytron_native.so +0 -0
- pytron/engines/chrome/adapter.py +445 -0
- pytron/engines/chrome/engine.py +576 -0
- pytron/engines/chrome/forge.py +147 -0
- pytron/engines/chrome/shell/package.json +8 -0
- pytron/engines/chrome/shell/preload.js +12 -0
- pytron/engines/chrome/shell/shell.js +534 -0
- pytron/exceptions.py +36 -0
- pytron/inspector.py +201 -0
- pytron/inspector_ui.py +512 -0
- pytron/installer/Installation.nsi +236 -0
- pytron/installer/header.bmp +0 -0
- pytron/installer/pytron.ico +0 -0
- pytron/installer/sidebar.bmp +0 -0
- pytron/llms.md +98 -0
- pytron/manifests/README.md +29 -0
- pytron/manifests/windows-utf8.manifest +44 -0
- pytron/menu.py +128 -0
- pytron/nsis-setup.exe +0 -0
- pytron/pack/__init__.py +0 -0
- pytron/pack/assets.py +131 -0
- pytron/pack/compilers.py +289 -0
- pytron/pack/crystal.py +297 -0
- pytron/pack/graph.py +377 -0
- pytron/pack/inference.py +157 -0
- pytron/pack/installers.py +402 -0
- pytron/pack/introspect.py +357 -0
- pytron/pack/metadata.py +213 -0
- pytron/pack/modules.py +618 -0
- pytron/pack/nuitka.py +108 -0
- pytron/pack/pipeline.py +107 -0
- pytron/pack/pyinstaller.py +176 -0
- pytron/pack/rust_engine.py +273 -0
- pytron/pack/secure.py +309 -0
- pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
- pytron/pack/secure_loader/icon.ico +0 -0
- pytron/pack/utils.py +110 -0
- pytron/pack/virtual_root.py +124 -0
- pytron/platforms/__init__.py +0 -0
- pytron/platforms/android/__init__.py +3 -0
- pytron/platforms/android/android.py +103 -0
- pytron/platforms/android/builder.py +736 -0
- pytron/platforms/android/ops/build.py +79 -0
- pytron/platforms/android/ops/init.py +63 -0
- pytron/platforms/android/ops/run.py +79 -0
- pytron/platforms/android/ops/sync.py +770 -0
- pytron/platforms/android/ops/utils.py +8 -0
- pytron/platforms/android/shell/README.md +30 -0
- pytron/platforms/android/shell/app/build.gradle +64 -0
- pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
- pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
- pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
- pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
- pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- pytron/platforms/android/shell/build.gradle +11 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
- pytron/platforms/android/shell/gradle.properties +2 -0
- pytron/platforms/android/shell/gradlew.bat +85 -0
- pytron/platforms/android/shell/settings.gradle +16 -0
- pytron/platforms/darwin.py +82 -0
- pytron/platforms/darwin_ops/libs.py +31 -0
- pytron/platforms/darwin_ops/system.py +182 -0
- pytron/platforms/darwin_ops/utils.py +85 -0
- pytron/platforms/darwin_ops/webview.py +5 -0
- pytron/platforms/darwin_ops/window.py +102 -0
- pytron/platforms/interface.py +152 -0
- pytron/platforms/linux.py +82 -0
- pytron/platforms/linux_ops/libs.py +49 -0
- pytron/platforms/linux_ops/system.py +316 -0
- pytron/platforms/linux_ops/utils.py +19 -0
- pytron/platforms/linux_ops/webview.py +5 -0
- pytron/platforms/linux_ops/window.py +115 -0
- pytron/platforms/windows.py +136 -0
- pytron/platforms/windows_ops/__init__.py +0 -0
- pytron/platforms/windows_ops/constants.py +126 -0
- pytron/platforms/windows_ops/system.py +518 -0
- pytron/platforms/windows_ops/utils.py +3 -0
- pytron/platforms/windows_ops/webview.py +5 -0
- pytron/platforms/windows_ops/window.py +361 -0
- pytron/plugin.py +467 -0
- pytron/rcedit-x64.exe +0 -0
- pytron/router.py +146 -0
- pytron/serializer.py +240 -0
- pytron/shortcuts.py +279 -0
- pytron/state.py +76 -0
- pytron/tray.py +399 -0
- pytron/updater.py +181 -0
- pytron/utf8_hook.py +112 -0
- pytron/utils.py +44 -0
- pytron/webview.py +722 -0
- pytron_kit-0.3.12.dist-info/METADATA +131 -0
- pytron_kit-0.3.12.dist-info/RECORD +419 -0
- pytron_kit-0.3.12.dist-info/WHEEL +5 -0
- pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
- pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
- pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
pytron/pack/compilers.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import platform
|
|
6
|
+
import re
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from ..console import log
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_python_executable():
|
|
12
|
+
"""Returns the path to the current python executable."""
|
|
13
|
+
return sys.executable
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def ensure_cython(python_exe):
|
|
17
|
+
"""Ensures Cython is installed/available."""
|
|
18
|
+
try:
|
|
19
|
+
subprocess.run(
|
|
20
|
+
[python_exe, "-c", "import Cython"], check=True, capture_output=True
|
|
21
|
+
)
|
|
22
|
+
except subprocess.CalledProcessError:
|
|
23
|
+
log("Cython missing in build environment. Installing...", style="info")
|
|
24
|
+
try:
|
|
25
|
+
subprocess.run([python_exe, "-m", "pip", "install", "Cython"], check=True)
|
|
26
|
+
except subprocess.CalledProcessError:
|
|
27
|
+
log(
|
|
28
|
+
"Failed to install Cython automatically. Please install it manually in your venv.",
|
|
29
|
+
style="error",
|
|
30
|
+
)
|
|
31
|
+
return False
|
|
32
|
+
return True
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def find_zig():
|
|
36
|
+
"""Locates the Zig compiler binary."""
|
|
37
|
+
zig_bin = shutil.which("zig")
|
|
38
|
+
if not zig_bin:
|
|
39
|
+
# Check if ziglang package is installed and use its binary
|
|
40
|
+
try:
|
|
41
|
+
import ziglang
|
|
42
|
+
|
|
43
|
+
zig_bin = os.path.join(os.path.dirname(ziglang.__file__), "bin", "zig")
|
|
44
|
+
if sys.platform == "win32":
|
|
45
|
+
zig_bin += ".exe"
|
|
46
|
+
if not os.path.exists(zig_bin):
|
|
47
|
+
# Try sibling bin directory for some installations
|
|
48
|
+
zig_bin = os.path.join(
|
|
49
|
+
os.path.dirname(os.path.dirname(ziglang.__file__)), "bin", "zig"
|
|
50
|
+
)
|
|
51
|
+
if sys.platform == "win32":
|
|
52
|
+
zig_bin += ".exe"
|
|
53
|
+
|
|
54
|
+
if not os.path.exists(zig_bin):
|
|
55
|
+
zig_bin = None
|
|
56
|
+
except ImportError:
|
|
57
|
+
zig_bin = None
|
|
58
|
+
|
|
59
|
+
if not zig_bin:
|
|
60
|
+
log(
|
|
61
|
+
"Zig compiler ('zig') not found. Falling back to default C compiler...",
|
|
62
|
+
style="warning",
|
|
63
|
+
)
|
|
64
|
+
else:
|
|
65
|
+
log(f"Using Zig compiler at: {zig_bin}", style="dim")
|
|
66
|
+
|
|
67
|
+
return zig_bin
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def cython_gen_c(script_path: Path, build_dir: Path, python_exe: str):
|
|
71
|
+
"""Generates a C file from a Python script using Cython."""
|
|
72
|
+
# 0. PRE-PROCESS: Force the 'main' block to execute when imported as a module
|
|
73
|
+
try:
|
|
74
|
+
content = script_path.read_text(encoding="utf-8", errors="ignore")
|
|
75
|
+
pattern = r'if\s+__name__\s*==\s*[\'"]__main__[\'"]\s*:'
|
|
76
|
+
if re.search(pattern, content):
|
|
77
|
+
log(" + Patching entry point for native execution...", style="dim")
|
|
78
|
+
content = re.sub(pattern, "if True: # Shield Redirect", content)
|
|
79
|
+
|
|
80
|
+
target_script = build_dir / "app.py"
|
|
81
|
+
target_script.write_text(content, encoding="utf-8")
|
|
82
|
+
except Exception as e:
|
|
83
|
+
log(f"Warning: Failed to pre-process script: {e}", style="warning")
|
|
84
|
+
target_script = script_path
|
|
85
|
+
|
|
86
|
+
c_file = build_dir / "app.c"
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
log(" + Generating C source with Cython...", style="dim")
|
|
90
|
+
process = subprocess.run(
|
|
91
|
+
[
|
|
92
|
+
python_exe,
|
|
93
|
+
"-m",
|
|
94
|
+
"cython",
|
|
95
|
+
"-3",
|
|
96
|
+
"--fast-fail",
|
|
97
|
+
str(target_script),
|
|
98
|
+
"-o",
|
|
99
|
+
str(c_file),
|
|
100
|
+
],
|
|
101
|
+
capture_output=True,
|
|
102
|
+
text=True,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if process.returncode != 0:
|
|
106
|
+
log(f"Cython generation failed: {process.stderr}", style="error")
|
|
107
|
+
return None
|
|
108
|
+
except Exception as e:
|
|
109
|
+
log(f"Cythonization error: {e}", style="error")
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
if not c_file.exists():
|
|
113
|
+
log("Cython failed to generate C source.", style="error")
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
return c_file
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def compile_c_to_binary(c_file: Path, build_dir: Path, zig_bin: str, python_exe: str):
|
|
120
|
+
"""Compiles C source to a .pyd/.so using Zig."""
|
|
121
|
+
ext = ".pyd" if sys.platform == "win32" else ".so"
|
|
122
|
+
output_bin = build_dir / f"app{ext}"
|
|
123
|
+
|
|
124
|
+
# Get Python build constants
|
|
125
|
+
res_include = subprocess.run(
|
|
126
|
+
[python_exe, "-c", "import sysconfig; print(sysconfig.get_path('include'))"],
|
|
127
|
+
capture_output=True,
|
|
128
|
+
text=True,
|
|
129
|
+
)
|
|
130
|
+
py_include = res_include.stdout.strip()
|
|
131
|
+
|
|
132
|
+
res_ver = subprocess.run(
|
|
133
|
+
[
|
|
134
|
+
python_exe,
|
|
135
|
+
"-c",
|
|
136
|
+
"import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')",
|
|
137
|
+
],
|
|
138
|
+
capture_output=True,
|
|
139
|
+
text=True,
|
|
140
|
+
)
|
|
141
|
+
py_ver_str = (
|
|
142
|
+
res_ver.stdout.strip() or f"{sys.version_info.major}{sys.version_info.minor}"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
res_prefix = subprocess.run(
|
|
146
|
+
[python_exe, "-c", "import sys; print(sys.base_prefix)"],
|
|
147
|
+
capture_output=True,
|
|
148
|
+
text=True,
|
|
149
|
+
)
|
|
150
|
+
base_prefix = res_prefix.stdout.strip() or sys.base_prefix
|
|
151
|
+
|
|
152
|
+
if sys.platform == "win32":
|
|
153
|
+
py_lib_dir = os.path.join(base_prefix, "libs")
|
|
154
|
+
else:
|
|
155
|
+
res_libdir = subprocess.run(
|
|
156
|
+
[
|
|
157
|
+
python_exe,
|
|
158
|
+
"-c",
|
|
159
|
+
"import sysconfig; print(sysconfig.get_config_var('LIBDIR') or '')",
|
|
160
|
+
],
|
|
161
|
+
capture_output=True,
|
|
162
|
+
text=True,
|
|
163
|
+
)
|
|
164
|
+
py_lib_dir = res_libdir.stdout.strip() or os.path.join(base_prefix, "lib")
|
|
165
|
+
|
|
166
|
+
if zig_bin:
|
|
167
|
+
# Determine target architecture
|
|
168
|
+
machine = platform.machine().lower()
|
|
169
|
+
if machine in ["amd64", "x86_64"]:
|
|
170
|
+
arch = "x86_64"
|
|
171
|
+
elif machine in ["arm64", "aarch64"]:
|
|
172
|
+
arch = "aarch64"
|
|
173
|
+
else:
|
|
174
|
+
arch = "x86"
|
|
175
|
+
|
|
176
|
+
target = (
|
|
177
|
+
f"{arch}-windows" if sys.platform == "win32" else f"{arch}-{sys.platform}"
|
|
178
|
+
)
|
|
179
|
+
if sys.platform == "linux":
|
|
180
|
+
target += "-gnu"
|
|
181
|
+
|
|
182
|
+
log(
|
|
183
|
+
f" + Compiling {output_bin.name} with Zig CC (Target: {target})...",
|
|
184
|
+
style="dim",
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
compile_cmd = [
|
|
188
|
+
zig_bin,
|
|
189
|
+
"cc",
|
|
190
|
+
"-target",
|
|
191
|
+
target,
|
|
192
|
+
"-O3",
|
|
193
|
+
"-shared",
|
|
194
|
+
"-o",
|
|
195
|
+
str(output_bin),
|
|
196
|
+
str(c_file),
|
|
197
|
+
f"-I{py_include}",
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
if sys.platform == "win32":
|
|
201
|
+
compile_cmd.append(f"-L{py_lib_dir}")
|
|
202
|
+
lib_name = f"python{py_ver_str}"
|
|
203
|
+
compile_cmd.append(f"-l{lib_name}")
|
|
204
|
+
else:
|
|
205
|
+
compile_cmd.append("-fPIC")
|
|
206
|
+
if py_lib_dir:
|
|
207
|
+
compile_cmd.append(f"-L{py_lib_dir}")
|
|
208
|
+
|
|
209
|
+
try:
|
|
210
|
+
res = subprocess.run(compile_cmd, capture_output=True, text=True)
|
|
211
|
+
if res.returncode != 0:
|
|
212
|
+
log(f"Zig compilation failed: {res.stderr}", style="error")
|
|
213
|
+
return None
|
|
214
|
+
except Exception as e:
|
|
215
|
+
log(f"Zig encountered an error: {e}", style="error")
|
|
216
|
+
return None
|
|
217
|
+
|
|
218
|
+
if output_bin.exists():
|
|
219
|
+
log(
|
|
220
|
+
f"Successfully compiled to {output_bin.name} using Zig", style="success"
|
|
221
|
+
)
|
|
222
|
+
return output_bin
|
|
223
|
+
|
|
224
|
+
return None
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def fallback_compile(script_path: Path, build_dir: Path, python_exe: str):
|
|
228
|
+
"""Fallback using standard setuptools/MSVC."""
|
|
229
|
+
log("Using standard Python build tools...", style="dim")
|
|
230
|
+
setup_path = build_dir / "setup_compile.py"
|
|
231
|
+
setup_content = f"""
|
|
232
|
+
from setuptools import setup
|
|
233
|
+
from Cython.Build import cythonize
|
|
234
|
+
import sys
|
|
235
|
+
|
|
236
|
+
setup(
|
|
237
|
+
ext_modules = cythonize("{script_path.as_posix()}",
|
|
238
|
+
compiler_directives={{'language_level': "3"}},
|
|
239
|
+
quiet=True),
|
|
240
|
+
)
|
|
241
|
+
"""
|
|
242
|
+
setup_path.write_text(setup_content)
|
|
243
|
+
cmd = [python_exe, "setup_compile.py", "build_ext", "--inplace"]
|
|
244
|
+
|
|
245
|
+
try:
|
|
246
|
+
subprocess.run(
|
|
247
|
+
cmd, cwd=str(build_dir), capture_output=True, text=True, check=True
|
|
248
|
+
)
|
|
249
|
+
except Exception as e:
|
|
250
|
+
log(f"Standard compilation failed: {e}", style="error")
|
|
251
|
+
return None
|
|
252
|
+
|
|
253
|
+
ext = ".pyd" if sys.platform == "win32" else ".so"
|
|
254
|
+
compiled_files = list(build_dir.glob(f"*{ext}"))
|
|
255
|
+
if not compiled_files:
|
|
256
|
+
compiled_files = list(build_dir.glob(f"build/lib*/{script_path.stem}*{ext}"))
|
|
257
|
+
|
|
258
|
+
if compiled_files:
|
|
259
|
+
pyd_path = compiled_files[0]
|
|
260
|
+
final_pyd = build_dir / f"app{ext}"
|
|
261
|
+
if final_pyd.exists():
|
|
262
|
+
os.remove(final_pyd)
|
|
263
|
+
shutil.move(str(pyd_path), str(final_pyd))
|
|
264
|
+
return final_pyd
|
|
265
|
+
return None
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def compile_script(script_path: Path, build_dir: Path):
|
|
269
|
+
"""Orchestrates the full compilation pipeline."""
|
|
270
|
+
python_exe = get_python_executable()
|
|
271
|
+
|
|
272
|
+
if not ensure_cython(python_exe):
|
|
273
|
+
return None
|
|
274
|
+
|
|
275
|
+
zig_bin = find_zig()
|
|
276
|
+
|
|
277
|
+
c_file = cython_gen_c(script_path, build_dir, python_exe)
|
|
278
|
+
if not c_file:
|
|
279
|
+
return None
|
|
280
|
+
|
|
281
|
+
# Try Zig
|
|
282
|
+
if zig_bin:
|
|
283
|
+
result = compile_c_to_binary(c_file, build_dir, zig_bin, python_exe)
|
|
284
|
+
if result:
|
|
285
|
+
return result
|
|
286
|
+
|
|
287
|
+
# Fallback
|
|
288
|
+
log("Zig compliation not possible, falling back...", style="warning")
|
|
289
|
+
return fallback_compile(script_path, build_dir, python_exe)
|
pytron/pack/crystal.py
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import json
|
|
3
|
+
import subprocess
|
|
4
|
+
import time
|
|
5
|
+
import os
|
|
6
|
+
import signal
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Set, Dict, List, Optional
|
|
9
|
+
from ..console import log
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AppAuditor:
|
|
13
|
+
"""
|
|
14
|
+
The 'Crystal' Runtime Auditor.
|
|
15
|
+
Executes the application under PEP 578 surveillance to capture the 'Live Code' universe.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, script_path: Path, timeout: int = 10):
|
|
19
|
+
self.script_path = script_path
|
|
20
|
+
self.timeout = timeout
|
|
21
|
+
self.manifest_path = script_path.parent / "requirements.lock.json"
|
|
22
|
+
|
|
23
|
+
def _generate_surveillance_runner(self) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Generates the Python code that acts as the audit harness.
|
|
26
|
+
"""
|
|
27
|
+
# We need to robustly handle the user script execution
|
|
28
|
+
escaped_script = (
|
|
29
|
+
str(self.script_path.resolve()).replace("\\", "\\\\").replace('"', '\\"')
|
|
30
|
+
)
|
|
31
|
+
escaped_manifest = (
|
|
32
|
+
str(self.manifest_path.resolve()).replace("\\", "\\\\").replace('"', '\\"')
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return f"""
|
|
36
|
+
import sys
|
|
37
|
+
import json
|
|
38
|
+
import time
|
|
39
|
+
import threading
|
|
40
|
+
import os
|
|
41
|
+
import builtins
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
import dis
|
|
44
|
+
|
|
45
|
+
# --- SURVEILLANCE SYSTEM ---
|
|
46
|
+
live_modules = set()
|
|
47
|
+
live_files = set()
|
|
48
|
+
|
|
49
|
+
def audit_hook(event, args):
|
|
50
|
+
try:
|
|
51
|
+
if event == "import":
|
|
52
|
+
module, filename, sys_path, sys_meta_path, sys_path_hooks = args
|
|
53
|
+
live_modules.add(module)
|
|
54
|
+
if filename:
|
|
55
|
+
live_files.add(str(filename))
|
|
56
|
+
elif event == "open" and len(args) > 0:
|
|
57
|
+
# Heuristic: file opens might be data assets
|
|
58
|
+
path = args[0]
|
|
59
|
+
if isinstance(path, (str, bytes, os.PathLike)):
|
|
60
|
+
live_files.add(str(path))
|
|
61
|
+
except Exception:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
# --- RECURSIVE ANALYSIS SYSTEM ---
|
|
65
|
+
import inspect
|
|
66
|
+
visited_functions = set()
|
|
67
|
+
|
|
68
|
+
def recursive_inspect(func, depth=0):
|
|
69
|
+
if depth > 5: return # Anti-recursion depth limit
|
|
70
|
+
if func in visited_functions: return
|
|
71
|
+
try:
|
|
72
|
+
visited_functions.add(func)
|
|
73
|
+
except:
|
|
74
|
+
return
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
# Helper to trigger standard audit event so our hook captures it
|
|
78
|
+
def _report(name, file=None):
|
|
79
|
+
if name:
|
|
80
|
+
# Mimic the standard import event arguments: (module, filename, sys.path, sys.meta_path, sys.path_hooks)
|
|
81
|
+
sys.audit("import", name, file, None, None, None)
|
|
82
|
+
|
|
83
|
+
# 1. Handle Classes/Instances
|
|
84
|
+
if inspect.isclass(func) or (not callable(func) and hasattr(func, "__dict__")):
|
|
85
|
+
if hasattr(func, "__module__") and func.__module__:
|
|
86
|
+
_report(func.__module__)
|
|
87
|
+
for attr_name in dir(func):
|
|
88
|
+
if attr_name.startswith("_"): continue
|
|
89
|
+
try:
|
|
90
|
+
val = getattr(func, attr_name)
|
|
91
|
+
if inspect.isfunction(val) or inspect.ismethod(val):
|
|
92
|
+
recursive_inspect(val, depth+1)
|
|
93
|
+
except: pass
|
|
94
|
+
return
|
|
95
|
+
|
|
96
|
+
if hasattr(func, "__module__") and func.__module__:
|
|
97
|
+
_report(func.__module__)
|
|
98
|
+
|
|
99
|
+
# 2. Inspect closures and globals
|
|
100
|
+
closures = inspect.getclosurevars(func)
|
|
101
|
+
|
|
102
|
+
for name, value in closures.globals.items():
|
|
103
|
+
if inspect.ismodule(value):
|
|
104
|
+
_report(value.__name__, getattr(value, "__file__", None))
|
|
105
|
+
elif hasattr(value, "__module__") and value.__module__:
|
|
106
|
+
_report(value.__module__)
|
|
107
|
+
if inspect.isfunction(value) or inspect.isclass(value):
|
|
108
|
+
recursive_inspect(value, depth+1)
|
|
109
|
+
|
|
110
|
+
for name, value in closures.nonlocals.items():
|
|
111
|
+
if hasattr(value, "__module__") and value.__module__:
|
|
112
|
+
_report(value.__module__)
|
|
113
|
+
if inspect.isfunction(value):
|
|
114
|
+
recursive_inspect(value, depth+1)
|
|
115
|
+
|
|
116
|
+
# 3. Bytecode Analysis
|
|
117
|
+
if hasattr(func, "__code__"):
|
|
118
|
+
for instr in dis.get_instructions(func):
|
|
119
|
+
if instr.opname == "IMPORT_NAME":
|
|
120
|
+
_report(instr.argval)
|
|
121
|
+
|
|
122
|
+
except Exception:
|
|
123
|
+
pass
|
|
124
|
+
|
|
125
|
+
# --- AUDIT SYSTEM REGISTRATION ---
|
|
126
|
+
# CRITICAL: Register the hook defined above
|
|
127
|
+
sys.addaudithook(audit_hook)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# --- MANIFEST DUMPER ---
|
|
131
|
+
# --- MANIFEST DUMPER ---
|
|
132
|
+
def dump_manifest():
|
|
133
|
+
# 1. Trigger App Heuristics (find hidden deps)
|
|
134
|
+
try:
|
|
135
|
+
import gc
|
|
136
|
+
import pytron
|
|
137
|
+
# Look for App in memory
|
|
138
|
+
for obj in gc.get_objects():
|
|
139
|
+
if isinstance(obj, pytron.App):
|
|
140
|
+
print("[Crystal] Triggering App.audit_dependencies()...")
|
|
141
|
+
if hasattr(obj, "audit_dependencies"):
|
|
142
|
+
obj.audit_dependencies()
|
|
143
|
+
break
|
|
144
|
+
except: pass
|
|
145
|
+
|
|
146
|
+
# 2. Load existing lock file to merge
|
|
147
|
+
existing_data = {{"modules": [], "files": []}}
|
|
148
|
+
if os.path.exists(f"{escaped_manifest}"):
|
|
149
|
+
try:
|
|
150
|
+
with open(f"{escaped_manifest}", "r") as f:
|
|
151
|
+
existing_data = json.load(f)
|
|
152
|
+
except: pass
|
|
153
|
+
|
|
154
|
+
# 3. Merge
|
|
155
|
+
final_modules = sorted(list(set(existing_data.get("modules", []) + list(live_modules))))
|
|
156
|
+
final_files = sorted(list(set(existing_data.get("files", []) + list(live_files))))
|
|
157
|
+
|
|
158
|
+
data = {{
|
|
159
|
+
"modules": final_modules,
|
|
160
|
+
"files": final_files
|
|
161
|
+
}}
|
|
162
|
+
try:
|
|
163
|
+
with open(f"{escaped_manifest}", "w") as f:
|
|
164
|
+
json.dump(data, f, indent=4)
|
|
165
|
+
print(f"[Crystal] Lock File Updated: {{len(final_modules)}} modules, {{len(final_files)}} files.")
|
|
166
|
+
except Exception as e:
|
|
167
|
+
print(f"[Crystal] Failed to dump manifest: {{e}}")
|
|
168
|
+
|
|
169
|
+
# Register exit handler to ensure we dump data even if app crashes or exits
|
|
170
|
+
import atexit
|
|
171
|
+
atexit.register(dump_manifest)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# --- MONKEY PATCHING PYTRON ---
|
|
175
|
+
# We want to intercept app.expose calls
|
|
176
|
+
def patch_pytron_app():
|
|
177
|
+
try:
|
|
178
|
+
# We try to import pytron from the sys.path (which includes target dir)
|
|
179
|
+
import pytron
|
|
180
|
+
OriginalApp = pytron.App
|
|
181
|
+
|
|
182
|
+
class AuditedApp(OriginalApp):
|
|
183
|
+
def expose(self, func=None, name=None, secure=False, run_in_thread=True):
|
|
184
|
+
# Trigger analysis immediately if we have a function
|
|
185
|
+
if func is not None:
|
|
186
|
+
try:
|
|
187
|
+
n = getattr(func, "__name__", str(func))
|
|
188
|
+
print(f"[Crystal] Analyzing exposed: {{n}}")
|
|
189
|
+
recursive_inspect(func)
|
|
190
|
+
except: pass
|
|
191
|
+
|
|
192
|
+
# IMPORTANT: Support default args/kwargs to avoid breaking complex @expose usages
|
|
193
|
+
return super().expose(func, name=name, secure=secure, run_in_thread=run_in_thread)
|
|
194
|
+
|
|
195
|
+
pytron.App = AuditedApp
|
|
196
|
+
print("[Crystal] 'pytron.App.expose' patched successfully.")
|
|
197
|
+
except Exception:
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
# Apply patch before running script
|
|
201
|
+
patch_pytron_app()
|
|
202
|
+
|
|
203
|
+
print("[Crystal] Surveillance Active. Launching Target...")
|
|
204
|
+
|
|
205
|
+
# --- TARGET LAUNCH ---
|
|
206
|
+
target_script = "{escaped_script}"
|
|
207
|
+
target_dir = os.path.dirname(target_script)
|
|
208
|
+
|
|
209
|
+
# Set cwd to target script dir to mimic real execution
|
|
210
|
+
os.chdir(target_dir)
|
|
211
|
+
sys.path.insert(0, target_dir)
|
|
212
|
+
|
|
213
|
+
try:
|
|
214
|
+
# We use runpy or exec to run the script in this process
|
|
215
|
+
with open(target_script, "r", encoding="utf-8") as f:
|
|
216
|
+
code = compile(f.read(), target_script, "exec")
|
|
217
|
+
exec(code, {{'__name__': '__main__', '__file__': target_script}})
|
|
218
|
+
except SystemExit:
|
|
219
|
+
pass
|
|
220
|
+
except Exception as e:
|
|
221
|
+
# App usage errors are expected if arguments are missing, but imports should have happened
|
|
222
|
+
print(f"[Crystal] Target Execution Interrupted: {{e}}")
|
|
223
|
+
|
|
224
|
+
# Dump one last time
|
|
225
|
+
dump_manifest()
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
def run_audit(self) -> Optional[Dict]:
|
|
229
|
+
"""
|
|
230
|
+
Spawns the surveillance subprocess and monitors it.
|
|
231
|
+
Returns the loaded manifest data.
|
|
232
|
+
"""
|
|
233
|
+
log("Initializing Crystal Surveillance (PEP 578 Audit)...", style="cyan")
|
|
234
|
+
log("Running imports please terminate if not needed", style="yellow")
|
|
235
|
+
runner_code = self._generate_surveillance_runner()
|
|
236
|
+
runner_path = self.script_path.parent / "crystal_runner.py"
|
|
237
|
+
runner_path.write_text(runner_code, encoding="utf-8")
|
|
238
|
+
|
|
239
|
+
python_exe = sys.executable
|
|
240
|
+
|
|
241
|
+
p = None
|
|
242
|
+
try:
|
|
243
|
+
# Run the audit process
|
|
244
|
+
# We don't want to capture output, we want the user to see it if the app prints stuff
|
|
245
|
+
# But we also don't want it to block forever.
|
|
246
|
+
log(
|
|
247
|
+
f" + Launching {self.script_path.name} in audit mode (Timeout: {self.timeout}s)...",
|
|
248
|
+
style="dim",
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
p = subprocess.Popen(
|
|
252
|
+
[python_exe, str(runner_path)],
|
|
253
|
+
cwd=str(self.script_path.parent),
|
|
254
|
+
stdout=subprocess.PIPE,
|
|
255
|
+
stderr=subprocess.PIPE,
|
|
256
|
+
text=True,
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
# Wait for timeout or completion
|
|
260
|
+
try:
|
|
261
|
+
# We give it some time to initialize imports and settle
|
|
262
|
+
stdout, stderr = p.communicate(timeout=self.timeout)
|
|
263
|
+
except subprocess.TimeoutExpired:
|
|
264
|
+
log(
|
|
265
|
+
" + Timeout reached. Terminating application to harvest data...",
|
|
266
|
+
style="dim",
|
|
267
|
+
)
|
|
268
|
+
p.terminate()
|
|
269
|
+
try:
|
|
270
|
+
p.wait(timeout=2)
|
|
271
|
+
except subprocess.TimeoutExpired:
|
|
272
|
+
p.kill()
|
|
273
|
+
|
|
274
|
+
if self.manifest_path.exists():
|
|
275
|
+
try:
|
|
276
|
+
data = json.loads(self.manifest_path.read_text())
|
|
277
|
+
log(
|
|
278
|
+
f"Crystal Audit Complete. Captured {len(data.get('modules', []))} live modules.",
|
|
279
|
+
style="success",
|
|
280
|
+
)
|
|
281
|
+
return data
|
|
282
|
+
except Exception as e:
|
|
283
|
+
log(f"Failed to parse Crystal manifest: {e}", style="error")
|
|
284
|
+
else:
|
|
285
|
+
log("Crystal Audit failed to produce a manifest.", style="error")
|
|
286
|
+
if p and p.stderr:
|
|
287
|
+
log(f"Stderr: {p.stderr.read()}", style="dim")
|
|
288
|
+
|
|
289
|
+
except Exception as e:
|
|
290
|
+
log(f"Crystal Surveillance Error: {e}", style="error")
|
|
291
|
+
finally:
|
|
292
|
+
# Cleanup
|
|
293
|
+
if runner_path.exists():
|
|
294
|
+
os.remove(runner_path)
|
|
295
|
+
# We keep the manifest for inspection/reference
|
|
296
|
+
|
|
297
|
+
return None
|