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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import ast
|
|
4
|
+
import shutil
|
|
5
|
+
import json
|
|
6
|
+
import importlib.metadata
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import List, Set, Dict, Any, Optional
|
|
9
|
+
from ..console import log
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DependencyIntrospector:
|
|
13
|
+
"""
|
|
14
|
+
The 'Site-Package Surveyor' that performs deep analysis of installed packages
|
|
15
|
+
to determine the optimal packaging strategy.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, script_dir: Path):
|
|
19
|
+
self.script_dir = script_dir
|
|
20
|
+
self.venv_site_packages = self._detect_site_packages()
|
|
21
|
+
self.analyzed = set()
|
|
22
|
+
|
|
23
|
+
def _detect_site_packages(self) -> Path:
|
|
24
|
+
# Priority 1: Local venv in project directory
|
|
25
|
+
# Pytron standardized environment name is "env"
|
|
26
|
+
venv_name = "env"
|
|
27
|
+
venv_path = self.script_dir / venv_name
|
|
28
|
+
|
|
29
|
+
if venv_path.exists():
|
|
30
|
+
if sys.platform == "win32":
|
|
31
|
+
sp = venv_path / "Lib" / "site-packages"
|
|
32
|
+
if sp.exists():
|
|
33
|
+
log(f" [Introspect] Locked to project venv: {sp}", style="dim")
|
|
34
|
+
return sp
|
|
35
|
+
else:
|
|
36
|
+
# Unix: lib/pythonX.Y/site-packages
|
|
37
|
+
lib = venv_path / "lib"
|
|
38
|
+
if lib.exists():
|
|
39
|
+
for child in lib.iterdir():
|
|
40
|
+
if (
|
|
41
|
+
child.name.startswith("python")
|
|
42
|
+
and (child / "site-packages").exists()
|
|
43
|
+
):
|
|
44
|
+
sp = child / "site-packages"
|
|
45
|
+
log(
|
|
46
|
+
f" [Introspect] Locked to project venv: {sp}",
|
|
47
|
+
style="dim",
|
|
48
|
+
)
|
|
49
|
+
return sp
|
|
50
|
+
|
|
51
|
+
# Priority 2: Current environment (sys.path)
|
|
52
|
+
paths = sys.path
|
|
53
|
+
for p in paths:
|
|
54
|
+
if "site-packages" in p and os.path.exists(p):
|
|
55
|
+
return Path(p)
|
|
56
|
+
return Path(sys.prefix) / "lib" / "site-packages"
|
|
57
|
+
|
|
58
|
+
def resolve_package_path(self, package_name: str) -> Optional[Path]:
|
|
59
|
+
"""Locates the physical installation directory of a package."""
|
|
60
|
+
# 1. Strict Venv Lookup
|
|
61
|
+
candidates = [
|
|
62
|
+
self.venv_site_packages / package_name,
|
|
63
|
+
self.venv_site_packages / (package_name + ".py"),
|
|
64
|
+
self.venv_site_packages / package_name.replace("-", "_"),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
for c in candidates:
|
|
68
|
+
if c.exists():
|
|
69
|
+
return c
|
|
70
|
+
|
|
71
|
+
# 2. Try importlib metadata lookup (constrained to venv if possible)
|
|
72
|
+
try:
|
|
73
|
+
# We explicitly search only in our determined site-packages to avoid global leakage
|
|
74
|
+
dists = importlib.metadata.distributions(
|
|
75
|
+
path=[str(self.venv_site_packages)]
|
|
76
|
+
)
|
|
77
|
+
for dist in dists:
|
|
78
|
+
if dist.metadata["Name"] == package_name or dist.name == package_name:
|
|
79
|
+
files = dist.files
|
|
80
|
+
if files:
|
|
81
|
+
p = files[0].locate()
|
|
82
|
+
path = Path(p)
|
|
83
|
+
# Ensure it's within our venv (safety check)
|
|
84
|
+
if str(self.venv_site_packages) in str(path):
|
|
85
|
+
return path.parent
|
|
86
|
+
except Exception:
|
|
87
|
+
# Fallback to default lookup if strict lookup fails (e.g. egg-info weirdness)
|
|
88
|
+
try:
|
|
89
|
+
files = importlib.metadata.files(package_name)
|
|
90
|
+
if files:
|
|
91
|
+
p = files[0].locate()
|
|
92
|
+
return Path(p).parent
|
|
93
|
+
except Exception:
|
|
94
|
+
pass
|
|
95
|
+
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
def get_recursive_dependencies(self, seeds: List[str]) -> Set[str]:
|
|
99
|
+
"""
|
|
100
|
+
Level 1: Recursive DNS
|
|
101
|
+
Builds a full list of dependencies starting from seeds.
|
|
102
|
+
"""
|
|
103
|
+
universe = set()
|
|
104
|
+
queue = list(seeds)
|
|
105
|
+
|
|
106
|
+
while queue:
|
|
107
|
+
pkg = queue.pop(0)
|
|
108
|
+
clean_pkg = pkg.split("==")[0].split(">")[0].split("<")[0].strip().lower()
|
|
109
|
+
|
|
110
|
+
if clean_pkg in universe:
|
|
111
|
+
continue
|
|
112
|
+
|
|
113
|
+
universe.add(clean_pkg)
|
|
114
|
+
|
|
115
|
+
# Lookup requirements
|
|
116
|
+
try:
|
|
117
|
+
requires = importlib.metadata.requires(clean_pkg)
|
|
118
|
+
if requires:
|
|
119
|
+
for req in requires:
|
|
120
|
+
# Extract name from "requests (>=2.0)"
|
|
121
|
+
req_name = req.split(" ")[0].split(";")[0].strip()
|
|
122
|
+
if req_name and req_name.lower() not in universe:
|
|
123
|
+
queue.append(req_name)
|
|
124
|
+
except importlib.metadata.PackageNotFoundError:
|
|
125
|
+
# Might be a stdlib or uninstalled package
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
return universe
|
|
129
|
+
|
|
130
|
+
def analyze_package(self, package_name: str) -> str:
|
|
131
|
+
"""
|
|
132
|
+
Level 2: Deep Scan
|
|
133
|
+
Returns a strategy: 'STANDARD' or 'COLLECT_ALL'
|
|
134
|
+
"""
|
|
135
|
+
path = self.resolve_package_path(package_name)
|
|
136
|
+
if not path or not path.is_dir():
|
|
137
|
+
return "STANDARD"
|
|
138
|
+
|
|
139
|
+
# Heuristic 1: Stub Detection (.pyi)
|
|
140
|
+
# REMOVED: Too noisy. Many modern packages (numpy, pillow, torch) ship stubs
|
|
141
|
+
# but don't require them at runtime unless lazy_loader is involved.
|
|
142
|
+
# We now rely on Heuristic 3/3.5 to detect lazy_loader usage specifically.
|
|
143
|
+
|
|
144
|
+
# Heuristic 2: Mixed Native Extensions
|
|
145
|
+
# If we see .pyd/.so files mixed deeply, strict collection is safer
|
|
146
|
+
# Count them
|
|
147
|
+
native_count = len(list(path.rglob("*.pyd"))) + len(list(path.rglob("*.so")))
|
|
148
|
+
# Increased threshold to 15 to allow standard libs like numpy/torch (which have hooks) to pass
|
|
149
|
+
if native_count > 15:
|
|
150
|
+
# Arbitrary threshold for "complex native package"
|
|
151
|
+
log(
|
|
152
|
+
f" [Introspect] {package_name}: High native complexity ({native_count} exts) -> COLLECT_ALL",
|
|
153
|
+
style="dim",
|
|
154
|
+
)
|
|
155
|
+
return "COLLECT_ALL"
|
|
156
|
+
|
|
157
|
+
# Heuristic 3: Source Code Triggers (AST/Text)
|
|
158
|
+
# Quick scan of top-level __init__.py
|
|
159
|
+
init_py = path / "__init__.py"
|
|
160
|
+
if init_py.exists():
|
|
161
|
+
try:
|
|
162
|
+
content = init_py.read_text(errors="ignore")
|
|
163
|
+
|
|
164
|
+
# Strict check for lazy_loader (The root cause of the user's issue)
|
|
165
|
+
# We apply this globally to any package using lazy_loader, as it universally requires stubs/data
|
|
166
|
+
if "lazy_loader" in content:
|
|
167
|
+
log(
|
|
168
|
+
f" [Introspect] {package_name}: Detects lazy_loader -> COLLECT_ALL",
|
|
169
|
+
style="dim",
|
|
170
|
+
)
|
|
171
|
+
return "COLLECT_ALL"
|
|
172
|
+
|
|
173
|
+
# REFINED: Only flag suspicious dynamic imports if not a well-known package
|
|
174
|
+
well_known_safe = {
|
|
175
|
+
"numpy",
|
|
176
|
+
"torch",
|
|
177
|
+
"pandas",
|
|
178
|
+
"matplotlib",
|
|
179
|
+
"setuptools",
|
|
180
|
+
"pkg_resources",
|
|
181
|
+
}
|
|
182
|
+
if package_name.lower() not in well_known_safe:
|
|
183
|
+
if "importlib.import_module" in content or "__import__" in content:
|
|
184
|
+
log(
|
|
185
|
+
f" [Introspect] {package_name}: Detects dynamic imports -> COLLECT_ALL",
|
|
186
|
+
style="dim",
|
|
187
|
+
)
|
|
188
|
+
return "COLLECT_ALL"
|
|
189
|
+
except Exception:
|
|
190
|
+
pass
|
|
191
|
+
|
|
192
|
+
# Heuristic 3.5: Bytecode Analysis (IMPORT_NAME / CALL_FUNCTION check)
|
|
193
|
+
# Scan __init__.pyc if available or compile source to check for import calls
|
|
194
|
+
if init_py.exists():
|
|
195
|
+
try:
|
|
196
|
+
import dis
|
|
197
|
+
|
|
198
|
+
with open(init_py, "r", encoding="utf-8", errors="ignore") as f:
|
|
199
|
+
source_code = f.read()
|
|
200
|
+
code_obj = compile(source_code, str(init_py), "exec")
|
|
201
|
+
|
|
202
|
+
found_sus = False
|
|
203
|
+
for instr in dis.get_instructions(code_obj):
|
|
204
|
+
# Only trigger specifically on lazy_loader for now to be safe
|
|
205
|
+
if (
|
|
206
|
+
instr.opname == "LOAD_GLOBAL"
|
|
207
|
+
and instr.argval == "lazy_loader"
|
|
208
|
+
):
|
|
209
|
+
found_sus = True
|
|
210
|
+
|
|
211
|
+
if found_sus:
|
|
212
|
+
log(
|
|
213
|
+
f" [Introspect] {package_name}: Bytecode reveals lazy_loader usage -> COLLECT_ALL",
|
|
214
|
+
style="dim",
|
|
215
|
+
)
|
|
216
|
+
return "COLLECT_ALL"
|
|
217
|
+
except Exception:
|
|
218
|
+
pass
|
|
219
|
+
|
|
220
|
+
# Heuristic 4: C-Transpilation Analysis (The "X-Ray")
|
|
221
|
+
# If still unsure, and we want to be paranoid (nuclear mode), we can check explicitly.
|
|
222
|
+
# This is expensive, so maybe we only do it if explicitly requested or for known complex packages?
|
|
223
|
+
# For now, let's keep it as a reserve tool or if we see certain red flags.
|
|
224
|
+
|
|
225
|
+
return "STANDARD"
|
|
226
|
+
|
|
227
|
+
def _transpile_and_scan(self, module_path: Path) -> List[str]:
|
|
228
|
+
"""
|
|
229
|
+
Uses Cython to transpile a module to C, then regex-scans the C code
|
|
230
|
+
for PyImport calls. This reveals 'true' imports that might be obfuscated.
|
|
231
|
+
"""
|
|
232
|
+
try:
|
|
233
|
+
import subprocess
|
|
234
|
+
|
|
235
|
+
# Check for Cython
|
|
236
|
+
python_exe = sys.executable
|
|
237
|
+
# Create temp C file
|
|
238
|
+
c_file = module_path.with_suffix(".c")
|
|
239
|
+
|
|
240
|
+
cmd = [
|
|
241
|
+
python_exe,
|
|
242
|
+
"-m",
|
|
243
|
+
"cython",
|
|
244
|
+
"-3",
|
|
245
|
+
str(module_path),
|
|
246
|
+
"-o",
|
|
247
|
+
str(c_file),
|
|
248
|
+
]
|
|
249
|
+
|
|
250
|
+
# Run Cython (silent)
|
|
251
|
+
subprocess.run(cmd, capture_output=True, check=True)
|
|
252
|
+
|
|
253
|
+
if not c_file.exists():
|
|
254
|
+
return []
|
|
255
|
+
|
|
256
|
+
content = c_file.read_text(errors="ignore")
|
|
257
|
+
|
|
258
|
+
# Cleanup
|
|
259
|
+
try:
|
|
260
|
+
os.remove(c_file)
|
|
261
|
+
except:
|
|
262
|
+
pass
|
|
263
|
+
|
|
264
|
+
# Scan for standard C-API import calls
|
|
265
|
+
# PyImport_ImportModule("name")
|
|
266
|
+
# __Pyx_Import(name_obj, ...)
|
|
267
|
+
|
|
268
|
+
found_imports = []
|
|
269
|
+
|
|
270
|
+
# Regex for PyImport_ImportModule("string_literal")
|
|
271
|
+
import re
|
|
272
|
+
|
|
273
|
+
matches = re.findall(r'PyImport_ImportModule\(\s*"([^"]+)"\s*\)', content)
|
|
274
|
+
found_imports.extend(matches)
|
|
275
|
+
|
|
276
|
+
return found_imports
|
|
277
|
+
|
|
278
|
+
except Exception as e:
|
|
279
|
+
# log(f"Transpilation failed: {e}", style="dim")
|
|
280
|
+
return []
|
|
281
|
+
|
|
282
|
+
def determine_packaging_strategy(self, requirements_file: Path) -> List[str]:
|
|
283
|
+
"""
|
|
284
|
+
Main Entry Point.
|
|
285
|
+
Reads requirements.json -> Returns list of --collect-all flags.
|
|
286
|
+
"""
|
|
287
|
+
collect_all_targets = []
|
|
288
|
+
|
|
289
|
+
if not requirements_file.exists():
|
|
290
|
+
return []
|
|
291
|
+
|
|
292
|
+
try:
|
|
293
|
+
data = json.loads(requirements_file.read_text())
|
|
294
|
+
seeds = data.get("dependencies", [])
|
|
295
|
+
|
|
296
|
+
# Clean seeds
|
|
297
|
+
clean_seeds = []
|
|
298
|
+
for s in seeds:
|
|
299
|
+
c = s.split("==")[0].split(">")[0].split("<")[0].strip()
|
|
300
|
+
if "/" not in c and "\\" not in c:
|
|
301
|
+
clean_seeds.append(c)
|
|
302
|
+
|
|
303
|
+
log(f"Introspecting {len(clean_seeds)} seed packages...", style="info")
|
|
304
|
+
|
|
305
|
+
# Level 1: Expand
|
|
306
|
+
universe = self.get_recursive_dependencies(clean_seeds)
|
|
307
|
+
log(
|
|
308
|
+
f" Dependency Universe Expanded: {len(universe)} packages", style="dim"
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
# Level 2: Scan & Strategy Determination
|
|
312
|
+
lock_data = {
|
|
313
|
+
"source": "pytron-smart-harvest",
|
|
314
|
+
"seeds": clean_seeds,
|
|
315
|
+
"universe": list(universe),
|
|
316
|
+
"packages": {},
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
# CRITICAL: We must scan the ENTIRE universe, not just seeds.
|
|
320
|
+
# InsightFace depends on skimage, so skimage is in universe but not seeds.
|
|
321
|
+
# Skimage uses lazy_loader -> needs collect-all.
|
|
322
|
+
|
|
323
|
+
for pkg in universe:
|
|
324
|
+
strategy = self.analyze_package(pkg)
|
|
325
|
+
|
|
326
|
+
resolved_path = self.resolve_package_path(pkg)
|
|
327
|
+
|
|
328
|
+
# Store analysis in lock file
|
|
329
|
+
lock_data["packages"][pkg] = {
|
|
330
|
+
"strategy": strategy,
|
|
331
|
+
"path": str(resolved_path or "unknown"),
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if strategy == "COLLECT_ALL":
|
|
335
|
+
# KEY FIX: We must use the IMPORT NAME (directory name), not the distribution name
|
|
336
|
+
# e.g. 'scikit-image' (dist) -> 'skimage' (import)
|
|
337
|
+
# If we pass 'scikit-image' to PyInstaller/collect_all, it fails to find the module.
|
|
338
|
+
if resolved_path:
|
|
339
|
+
import_name = resolved_path.name
|
|
340
|
+
collect_all_targets.append(f"--collect-all={import_name}")
|
|
341
|
+
else:
|
|
342
|
+
# Fallback if path lookup failed but we still want to try
|
|
343
|
+
collect_all_targets.append(f"--collect-all={pkg}")
|
|
344
|
+
|
|
345
|
+
# Write Lock File
|
|
346
|
+
lock_file = requirements_file.parent / "requirements.lock.json"
|
|
347
|
+
try:
|
|
348
|
+
lock_file.write_text(json.dumps(lock_data, indent=4))
|
|
349
|
+
log(f"Locked dependency state written to {lock_file.name}", style="dim")
|
|
350
|
+
except Exception as e:
|
|
351
|
+
log(f"Warning: Could not write lock file: {e}", style="warning")
|
|
352
|
+
|
|
353
|
+
except Exception as e:
|
|
354
|
+
log(f"Introspection failed: {e}", style="warning")
|
|
355
|
+
return []
|
|
356
|
+
|
|
357
|
+
return collect_all_targets
|
pytron/pack/metadata.py
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from ..console import log, run_command_with_output
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MetadataEditor:
|
|
10
|
+
"""Universal Metadata Editor for Pytron binaries using rcedit on Windows."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, package_dir=None):
|
|
13
|
+
if package_dir:
|
|
14
|
+
self.package_dir = Path(package_dir)
|
|
15
|
+
else:
|
|
16
|
+
import pytron
|
|
17
|
+
|
|
18
|
+
self.package_dir = Path(pytron.__file__).resolve().parent.parent
|
|
19
|
+
|
|
20
|
+
self.rcedit = self.package_dir / "pytron" / "rcedit-x64.exe"
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
import metaedit
|
|
24
|
+
|
|
25
|
+
self.has_metaedit = True
|
|
26
|
+
except ImportError:
|
|
27
|
+
self.has_metaedit = False
|
|
28
|
+
|
|
29
|
+
def update(self, binary_path, icon_path, settings, dist_dir=None):
|
|
30
|
+
binary_path = Path(binary_path)
|
|
31
|
+
|
|
32
|
+
if self.has_metaedit:
|
|
33
|
+
log(f"Applying metadata to {binary_path.name} using metaedit", style="info")
|
|
34
|
+
try:
|
|
35
|
+
import metaedit
|
|
36
|
+
|
|
37
|
+
author = settings.get("author", "Pytron User")
|
|
38
|
+
title = settings.get("title", binary_path.stem)
|
|
39
|
+
|
|
40
|
+
meta = {
|
|
41
|
+
"icon": (
|
|
42
|
+
str(icon_path)
|
|
43
|
+
if icon_path and os.path.exists(icon_path)
|
|
44
|
+
else None
|
|
45
|
+
),
|
|
46
|
+
"version": str(settings.get("version", "1.0.0")),
|
|
47
|
+
"CompanyName": author,
|
|
48
|
+
"FileDescription": settings.get("description", "Pytron App"),
|
|
49
|
+
"LegalCopyright": settings.get(
|
|
50
|
+
"copyright", f"Copyright © {author}"
|
|
51
|
+
),
|
|
52
|
+
"ProductName": title,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Filter out None values
|
|
56
|
+
meta = {k: v for k, v in meta.items() if v is not None}
|
|
57
|
+
|
|
58
|
+
# Windows-specific surgery
|
|
59
|
+
if sys.platform == "win32":
|
|
60
|
+
meta["InternalName"] = binary_path.stem
|
|
61
|
+
meta["OriginalFilename"] = f"{binary_path.stem}.exe"
|
|
62
|
+
|
|
63
|
+
metaedit.update(str(binary_path), **meta)
|
|
64
|
+
log(f"Metadata Applied via metaedit on {sys.platform}", style="success")
|
|
65
|
+
|
|
66
|
+
# If macOS, we still need to return the bundled binary path if metaedit moved it
|
|
67
|
+
if sys.platform == "darwin":
|
|
68
|
+
app_bundle = binary_path.parent / f"{title}.app"
|
|
69
|
+
bundled_bin = app_bundle / "Contents" / "MacOS" / binary_path.name
|
|
70
|
+
if bundled_bin.exists():
|
|
71
|
+
return bundled_bin
|
|
72
|
+
|
|
73
|
+
return binary_path
|
|
74
|
+
except Exception as e:
|
|
75
|
+
log(
|
|
76
|
+
f"metaedit failed: {e}. Falling back to legacy methods...",
|
|
77
|
+
style="warning",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
if sys.platform == "win32":
|
|
81
|
+
return self._update_windows(binary_path, icon_path, settings)
|
|
82
|
+
elif sys.platform == "darwin":
|
|
83
|
+
return self._update_macos(binary_path, icon_path, settings, dist_dir)
|
|
84
|
+
elif sys.platform == "linux":
|
|
85
|
+
return self._update_linux(binary_path, icon_path, settings, dist_dir)
|
|
86
|
+
return binary_path
|
|
87
|
+
|
|
88
|
+
def _update_windows(self, binary_path, icon_path, settings):
|
|
89
|
+
"""Windows Fallback: Uses rcedit."""
|
|
90
|
+
if not self.rcedit.exists():
|
|
91
|
+
log(
|
|
92
|
+
f"Warning: rcedit not found at {self.rcedit}. Skipping metadata update.",
|
|
93
|
+
style="warning",
|
|
94
|
+
)
|
|
95
|
+
return binary_path
|
|
96
|
+
|
|
97
|
+
log(
|
|
98
|
+
f"Applying Windows metadata to {binary_path.name} using rcedit",
|
|
99
|
+
style="info",
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# 1. Update Icon
|
|
103
|
+
if icon_path and os.path.exists(icon_path):
|
|
104
|
+
try:
|
|
105
|
+
cmd = [str(self.rcedit), str(binary_path), "--set-icon", str(icon_path)]
|
|
106
|
+
run_command_with_output(cmd, style="dim")
|
|
107
|
+
except Exception as e:
|
|
108
|
+
log(f"Icon update failed: {e}", style="warning")
|
|
109
|
+
|
|
110
|
+
# 2. Update Version
|
|
111
|
+
version = str(settings.get("version", "1.0.0"))
|
|
112
|
+
try:
|
|
113
|
+
cmd = [
|
|
114
|
+
str(self.rcedit),
|
|
115
|
+
str(binary_path),
|
|
116
|
+
"--set-file-version",
|
|
117
|
+
version,
|
|
118
|
+
"--set-product-version",
|
|
119
|
+
version,
|
|
120
|
+
]
|
|
121
|
+
run_command_with_output(cmd, style="dim")
|
|
122
|
+
except Exception as e:
|
|
123
|
+
log(f"Version update failed: {e}", style="warning")
|
|
124
|
+
|
|
125
|
+
# 3. Update Strings
|
|
126
|
+
author = settings.get("author", "Pytron User")
|
|
127
|
+
patch_map = {
|
|
128
|
+
"CompanyName": author,
|
|
129
|
+
"FileDescription": settings.get("description", "Pytron App"),
|
|
130
|
+
"LegalCopyright": settings.get("copyright", f"Copyright © {author}"),
|
|
131
|
+
"ProductName": settings.get("title", binary_path.stem),
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
cmd = [str(self.rcedit), str(binary_path)]
|
|
136
|
+
for key, value in patch_map.items():
|
|
137
|
+
cmd.extend(["--set-version-string", key, str(value)])
|
|
138
|
+
run_command_with_output(cmd, style="dim")
|
|
139
|
+
except Exception as e:
|
|
140
|
+
log(f"Metadata update failed: {e}", style="warning")
|
|
141
|
+
|
|
142
|
+
return binary_path
|
|
143
|
+
|
|
144
|
+
def _update_macos(self, binary_path, icon_path, settings, dist_dir):
|
|
145
|
+
"""macOS Fallback: Manual Bundle Synthesis."""
|
|
146
|
+
import plistlib
|
|
147
|
+
|
|
148
|
+
out_name = binary_path.stem
|
|
149
|
+
app_name = settings.get("title", out_name)
|
|
150
|
+
app_bundle = dist_dir / f"{app_name}.app"
|
|
151
|
+
contents_dir = app_bundle / "Contents"
|
|
152
|
+
macos_dir = contents_dir / "MacOS"
|
|
153
|
+
resources_dir = contents_dir / "Resources"
|
|
154
|
+
|
|
155
|
+
for d in [macos_dir, resources_dir]:
|
|
156
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
157
|
+
|
|
158
|
+
bundled_binary = macos_dir / out_name
|
|
159
|
+
if binary_path.exists():
|
|
160
|
+
shutil.move(str(binary_path), str(bundled_binary))
|
|
161
|
+
|
|
162
|
+
version = str(settings.get("version", "1.0.0"))
|
|
163
|
+
author = settings.get("author", "Pytron User")
|
|
164
|
+
bundle_id = settings.get(
|
|
165
|
+
"bundle_id", f"com.{author.replace(' ', '').lower()}.{out_name.lower()}"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
info_plist = {
|
|
169
|
+
"CFBundleExecutable": out_name,
|
|
170
|
+
"CFBundleIconFile": "app.icns",
|
|
171
|
+
"CFBundleIdentifier": bundle_id,
|
|
172
|
+
"CFBundleName": app_name,
|
|
173
|
+
"CFBundlePackageType": "APPL",
|
|
174
|
+
"CFBundleShortVersionString": version,
|
|
175
|
+
"CFBundleVersion": version,
|
|
176
|
+
"NSHighResolutionCapable": True,
|
|
177
|
+
"NSHumanReadableCopyright": settings.get(
|
|
178
|
+
"copyright", f"Copyright © {author}"
|
|
179
|
+
),
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
# Merge user custom plist settings
|
|
183
|
+
custom_plist = settings.get("macos_plist")
|
|
184
|
+
if custom_plist and isinstance(custom_plist, dict):
|
|
185
|
+
info_plist.update(custom_plist)
|
|
186
|
+
log(f"Merged {len(custom_plist)} custom Info.plist overrides", style="dim")
|
|
187
|
+
|
|
188
|
+
plist_path = contents_dir / "Info.plist"
|
|
189
|
+
with open(plist_path, "wb") as f:
|
|
190
|
+
plistlib.dump(info_plist, f)
|
|
191
|
+
|
|
192
|
+
if icon_path and os.path.exists(icon_path):
|
|
193
|
+
if str(icon_path).endswith(".icns"):
|
|
194
|
+
shutil.copy(icon_path, resources_dir / "app.icns")
|
|
195
|
+
|
|
196
|
+
return bundled_binary
|
|
197
|
+
|
|
198
|
+
def _update_linux(self, binary_path, icon_path, settings, dist_dir):
|
|
199
|
+
"""Linux Fallback: Manual .desktop entry."""
|
|
200
|
+
out_name = binary_path.stem
|
|
201
|
+
app_name = settings.get("title", out_name)
|
|
202
|
+
|
|
203
|
+
desktop_content = f"""[Desktop Entry]
|
|
204
|
+
Type=Application
|
|
205
|
+
Name={app_name}
|
|
206
|
+
Exec=./{out_name}
|
|
207
|
+
Icon=./icon.png
|
|
208
|
+
Terminal=false
|
|
209
|
+
"""
|
|
210
|
+
(dist_dir / f"{out_name}.desktop").write_text(desktop_content)
|
|
211
|
+
if icon_path and os.path.exists(icon_path):
|
|
212
|
+
shutil.copy(icon_path, dist_dir / "icon.png")
|
|
213
|
+
return binary_path
|