neutralino-python 0.1.0rc1__py3-none-any.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.
- neutralino/__init__.py +88 -0
- neutralino/_catalog.py +297 -0
- neutralino/_data/LICENSE.neutralino-js-client +21 -0
- neutralino/_data/LICENSE.neutralinojs +1066 -0
- neutralino/_data/docs/cli.md +315 -0
- neutralino/_data/docs/custom-components.md +107 -0
- neutralino/_data/docs/custom-frontends.md +80 -0
- neutralino/_data/docs/desktop-helpers.md +296 -0
- neutralino/_data/docs/guide.md +131 -0
- neutralino/_data/docs/llms-full.txt +3921 -0
- neutralino/_data/docs/llms.txt +43 -0
- neutralino/_data/docs/manifests/components.json +20128 -0
- neutralino/_data/docs/manifests/examples.json +52 -0
- neutralino/_data/docs/manifests/native.json +3024 -0
- neutralino/_data/docs/manifests/schema.json +43 -0
- neutralino/_data/docs/manual-checklist.md +189 -0
- neutralino/_data/docs/packaging.md +252 -0
- neutralino/_data/docs/performance.md +15 -0
- neutralino/_data/docs/platforms.md +15 -0
- neutralino/_data/docs/reference/components.md +1685 -0
- neutralino/_data/docs/reference/native.md +148 -0
- neutralino/_data/docs/security.md +60 -0
- neutralino/_data/docs/ui.md +249 -0
- neutralino/_data/docs/updates.md +366 -0
- neutralino/_data/examples/README.md +6 -0
- neutralino/_data/examples/crud/README.md +36 -0
- neutralino/_data/examples/crud/app.py +243 -0
- neutralino/_data/examples/dashboard/README.md +36 -0
- neutralino/_data/examples/dashboard/app.py +367 -0
- neutralino/_data/examples/editor/README.md +35 -0
- neutralino/_data/examples/editor/app.py +190 -0
- neutralino/_data/examples/file-manager/README.md +40 -0
- neutralino/_data/examples/file-manager/app.py +120 -0
- neutralino/_data/examples/file-manager/frontend/index.html +20 -0
- neutralino/_data/examples/file-manager/frontend/main.js +55 -0
- neutralino/_data/examples/file-manager/frontend/neutralino.js +1 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/file-manager/frontend/style.css +4 -0
- neutralino/_data/examples/hybrid/README.md +48 -0
- neutralino/_data/examples/hybrid/app.py +80 -0
- neutralino/_data/examples/hybrid/components/counter.mjs +37 -0
- neutralino/_data/examples/hybrid/components/widget.mjs +23 -0
- neutralino/_data/examples/hybrid/styles.css +21 -0
- neutralino/_data/examples/hybrid/widget/package.json +20 -0
- neutralino/_data/examples/hybrid/widget/src/Widget.jsx +25 -0
- neutralino/_data/examples/hybrid/widget/vite.config.mjs +19 -0
- neutralino/_data/examples/monitor/README.md +36 -0
- neutralino/_data/examples/monitor/app.py +375 -0
- neutralino/_data/examples/react/README.md +90 -0
- neutralino/_data/examples/react/app.py +68 -0
- neutralino/_data/examples/react/frontend/.gitignore +5 -0
- neutralino/_data/examples/react/frontend/index.html +17 -0
- neutralino/_data/examples/react/frontend/package-lock.json +1232 -0
- neutralino/_data/examples/react/frontend/package.json +25 -0
- neutralino/_data/examples/react/frontend/scripts/prepare-bridge.mjs +49 -0
- neutralino/_data/examples/react/frontend/src/App.tsx +157 -0
- neutralino/_data/examples/react/frontend/src/backend.ts +21 -0
- neutralino/_data/examples/react/frontend/src/calls.test.ts +206 -0
- neutralino/_data/examples/react/frontend/src/calls.ts +306 -0
- neutralino/_data/examples/react/frontend/src/globals.d.ts +14 -0
- neutralino/_data/examples/react/frontend/src/hooks.ts +45 -0
- neutralino/_data/examples/react/frontend/src/main.tsx +13 -0
- neutralino/_data/examples/react/frontend/src/styles.css +11 -0
- neutralino/_data/examples/react/frontend/tsconfig.json +18 -0
- neutralino/_data/examples/react/frontend/vite.config.ts +9 -0
- neutralino/_data/examples/settings/README.md +38 -0
- neutralino/_data/examples/settings/app.py +440 -0
- neutralino/_data/examples/updater/.gitignore +2 -0
- neutralino/_data/examples/updater/README.md +82 -0
- neutralino/_data/examples/updater/app.py +160 -0
- neutralino/_data/examples/updater/app.toml +21 -0
- neutralino/_data/examples/updater/demo.py +107 -0
- neutralino/_data/examples/updater/requirements.txt +2 -0
- neutralino/_data/examples/updater/sources/github-private.toml +21 -0
- neutralino/_data/examples/updater/sources/github-public.toml +21 -0
- neutralino/_data/examples/vanilla/README.md +35 -0
- neutralino/_data/examples/vanilla/app.py +46 -0
- neutralino/_data/examples/vanilla/frontend/index.html +17 -0
- neutralino/_data/examples/vanilla/frontend/main.js +29 -0
- neutralino/_data/examples/vanilla/frontend/neutralino.js +1 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/vanilla/frontend/style.css +4 -0
- neutralino/_data/explorer/app.py +1328 -0
- neutralino/_data/explorer/catalogue.json +48179 -0
- neutralino/_data/explorer/explorer_previews.py +247 -0
- neutralino/_data/explorer/sources/native/always_on_top.py +55 -0
- neutralino/_data/explorer/sources/native/binary.py +125 -0
- neutralino/_data/explorer/sources/native/borderless.py +99 -0
- neutralino/_data/explorer/sources/native/broadcast.py +90 -0
- neutralino/_data/explorer/sources/native/config.py +78 -0
- neutralino/_data/explorer/sources/native/controls.py +140 -0
- neutralino/_data/explorer/sources/native/directory.py +163 -0
- neutralino/_data/explorer/sources/native/displays.py +75 -0
- neutralino/_data/explorer/sources/native/env.py +98 -0
- neutralino/_data/explorer/sources/native/events.py +124 -0
- neutralino/_data/explorer/sources/native/exec_command.py +79 -0
- neutralino/_data/explorer/sources/native/folder.py +70 -0
- neutralino/_data/explorer/sources/native/icon_badge.py +101 -0
- neutralino/_data/explorer/sources/native/image.py +119 -0
- neutralino/_data/explorer/sources/native/lifecycle.py +99 -0
- neutralino/_data/explorer/sources/native/locale.py +70 -0
- neutralino/_data/explorer/sources/native/main_menu.py +103 -0
- neutralino/_data/explorer/sources/native/message_box.py +101 -0
- neutralino/_data/explorer/sources/native/mouse.py +70 -0
- neutralino/_data/explorer/sources/native/multi_window.py +134 -0
- neutralino/_data/explorer/sources/native/notification.py +74 -0
- neutralino/_data/explorer/sources/native/open_external.py +81 -0
- neutralino/_data/explorer/sources/native/open_file.py +102 -0
- neutralino/_data/explorer/sources/native/paths.py +77 -0
- neutralino/_data/explorer/sources/native/print_snapshot.py +84 -0
- neutralino/_data/explorer/sources/native/read_write.py +192 -0
- neutralino/_data/explorer/sources/native/resources.py +110 -0
- neutralino/_data/explorer/sources/native/save_file.py +101 -0
- neutralino/_data/explorer/sources/native/server_mount.py +106 -0
- neutralino/_data/explorer/sources/native/sound.py +84 -0
- neutralino/_data/explorer/sources/native/spawn_process.py +128 -0
- neutralino/_data/explorer/sources/native/states.py +122 -0
- neutralino/_data/explorer/sources/native/stats_permissions.py +147 -0
- neutralino/_data/explorer/sources/native/storage.py +108 -0
- neutralino/_data/explorer/sources/native/system_info.py +115 -0
- neutralino/_data/explorer/sources/native/text.py +133 -0
- neutralino/_data/explorer/sources/native/trash.py +98 -0
- neutralino/_data/explorer/sources/native/tray.py +109 -0
- neutralino/_data/explorer/sources/native/watcher.py +167 -0
- neutralino/_data/explorer/sources/patterns/content_blocks.py +119 -0
- neutralino/_data/explorer/sources/patterns/dynamic_dashboard.py +121 -0
- neutralino/_data/explorer/sources/patterns/dynamic_form.py +120 -0
- neutralino/_data/explorer/sources/patterns/dynamic_table.py +109 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.mjs +24 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.py +124 -0
- neutralino/_data/explorer/sources/patterns/errors_timeouts.py +108 -0
- neutralino/_data/explorer/sources/patterns/feature_flags.py +99 -0
- neutralino/_data/explorer/sources/patterns/file_drop.py +126 -0
- neutralino/_data/explorer/sources/patterns/http_from_python.py +152 -0
- neutralino/_data/explorer/sources/patterns/keyboard_shortcuts.py +153 -0
- neutralino/_data/explorer/sources/patterns/live_config_reload.py +160 -0
- neutralino/_data/explorer/sources/patterns/logging.py +184 -0
- neutralino/_data/explorer/sources/patterns/long_tasks.py +121 -0
- neutralino/_data/explorer/sources/patterns/multi_window_sync.py +68 -0
- neutralino/_data/explorer/sources/patterns/navigation_from_backend.py +109 -0
- neutralino/_data/explorer/sources/patterns/onboarding.py +123 -0
- neutralino/_data/explorer/sources/patterns/optimistic_updates.py +89 -0
- neutralino/_data/explorer/sources/patterns/persistence.py +114 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.mjs +10 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.py +64 -0
- neutralino/_data/explorer/sources/patterns/python_push.py +84 -0
- neutralino/_data/explorer/sources/patterns/recurring_events.py +114 -0
- neutralino/_data/explorer/sources/patterns/roles_permissions.py +104 -0
- neutralino/_data/explorer/sources/patterns/scheduled_jobs.py +194 -0
- neutralino/_data/explorer/sources/patterns/settings_page.py +165 -0
- neutralino/_data/explorer/sources/patterns/sqlite.py +181 -0
- neutralino/_data/explorer/sources/patterns/streaming.py +102 -0
- neutralino/_data/explorer/sources/patterns/texts_i18n.py +81 -0
- neutralino/_data/explorer/sources/patterns/theme_from_backend.py +86 -0
- neutralino/_data/explorer/sources/patterns/updater.py +232 -0
- neutralino/_data/explorer/sources/workspace/calendar/app.py +547 -0
- neutralino/_data/explorer/sources/workspace/customers/app.py +467 -0
- neutralino/_data/explorer/sources/workspace/dashboard/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/dashboard/app.py +367 -0
- neutralino/_data/explorer/sources/workspace/documents/app.py +511 -0
- neutralino/_data/explorer/sources/workspace/inbox/app.py +439 -0
- neutralino/_data/explorer/sources/workspace/orders/app.py +491 -0
- neutralino/_data/explorer/sources/workspace/reports/app.py +386 -0
- neutralino/_data/explorer/sources/workspace/settings/README.md +38 -0
- neutralino/_data/explorer/sources/workspace/settings/app.py +440 -0
- neutralino/_data/explorer/sources/workspace/system/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/system/app.py +375 -0
- neutralino/_data/explorer/sources/workspace/tasks/app.py +462 -0
- neutralino/_data/renderer/LICENSES/@babel__runtime@7.29.17/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/@codemirror__autocomplete@6.20.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__commands@6.11.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-css@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-html@6.4.12/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-javascript@6.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-json@6.0.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-markdown@6.5.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-python@6.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-sql@6.10.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-yaml@6.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__language@6.13.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__search@6.7.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__state@6.7.6/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__view@6.44.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__accessibility@3.1.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__core@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__sortable@10.0.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__utilities@3.2.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@emoji-mart__data@1.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__core@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__dom@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react-dom@2.1.9/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react@0.27.20/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__utils@0.2.12/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@lezer__common@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__css@1.3.9/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__highlight@1.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__html@1.3.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__javascript@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__json@1.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__lr@1.4.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__markdown@1.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__python@1.1.21/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__yaml@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__carousel@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__charts@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__code-highlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__core@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dates@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dropzone@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__emoji@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__hooks@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__lightbox@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__notifications@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__nprogress@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__schedule@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__spotlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__store@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__tiptap@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@marijn__find-cluster-break@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@reduxjs__toolkit@2.16.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tabler__icons-react@3.55.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__react-virtual@3.14.32/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__virtual-core@3.19.17/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__core@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-blockquote@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-bold@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code-block@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-document@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-hard-break@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-heading@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-horizontal-rule@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-italic@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-link@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-list@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-paragraph@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-strike@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-text@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-underline@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extensions@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__react@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__starter-kit@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/attr-accept@4.0.1/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/clsx@2.1.1/license +9 -0
- neutralino/_data/renderer/LICENSES/crelt@1.0.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/d3-array@3.2.5/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-color@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-format@3.1.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-interpolate@3.0.2/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-path@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-scale@4.0.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-shape@3.2.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time-format@4.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/dayjs@1.11.23/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/decimal.js-light@2.5.1/LICENCE.md +23 -0
- neutralino/_data/renderer/LICENSES/diff@9.0.0/LICENSE +29 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE +202 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE-MPL +373 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-react@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-reactive-utils@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/NOTICE +39 -0
- neutralino/_data/renderer/LICENSES/eventemitter3@5.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/fast-equals@5.4.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/file-selector@5.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/get-nonce@1.0.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/immer@11.2.14/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/linkifyjs@4.4.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/marked@18.4.0/LICENSE +44 -0
- neutralino/_data/renderer/LICENSES/neutralino.js@6.11.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/orderedmap@2.1.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/packages.json +1838 -0
- neutralino/_data/renderer/LICENSES/prosemirror-commands@1.7.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-dropcursor@1.8.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-gapcursor@1.4.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-history@1.5.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-keymap@1.2.3/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-model@1.25.13/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-schema-list@1.6.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-state@1.4.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-transform@1.12.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-view@1.44.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/react-dom@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-dropzone@20.1.4/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/react-is@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-number-format@5.4.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-redux@9.3.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll-bar@2.3.8/MIT-react-remove-scroll-bar.txt +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll@2.7.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-style-singleton@2.2.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-transition-group@4.4.5/LICENSE +30 -0
- neutralino/_data/renderer/LICENSES/react@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/recharts@3.11.3/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/redux-thunk@3.1.0/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/redux@5.0.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/reselect@5.2.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/rolldown@1.3.4/LICENSE +25 -0
- neutralino/_data/renderer/LICENSES/rope-sequence@1.3.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/rrule@2.8.1/LICENCE +65 -0
- neutralino/_data/renderer/LICENSES/scheduler@0.28.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/style-mod@4.1.5/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/tiny-invariant@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/tslib@2.9.1/LICENSE.txt +12 -0
- neutralino/_data/renderer/LICENSES/use-callback-ref@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sidecar@1.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sync-external-store@1.7.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/victory-vendor@38.1.1/LICENSE.txt +150 -0
- neutralino/_data/renderer/LICENSES/vite@8.4.1/LICENSE.md +2320 -0
- neutralino/_data/renderer/LICENSES/w3c-keyname@2.2.8/LICENSE +19 -0
- neutralino/_data/renderer/assets/IconGripVertical-C2NUKJAE.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DHnOKa8c.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-CLVygP7p.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CXJaU0yv.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-DX0MbxKq.js +2 -0
- neutralino/_data/renderer/assets/css-BotC7byr.js +1 -0
- neutralino/_data/renderer/assets/dist-3kB5bJpS.js +23 -0
- neutralino/_data/renderer/assets/dist-6zrr4MrK.js +1 -0
- neutralino/_data/renderer/assets/dist-Beotrn8G.js +1 -0
- neutralino/_data/renderer/assets/dist-CCJHv8n0.js +11 -0
- neutralino/_data/renderer/assets/dist-CdYA9or5.js +1 -0
- neutralino/_data/renderer/assets/dist-D2p_6o_g.js +1 -0
- neutralino/_data/renderer/assets/dnd-DkNumIKC.js +5 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/dropzone-agrigkXv.js +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-_ztrE73N.js +1 -0
- neutralino/_data/renderer/assets/emoji-Cj3VQHg8.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-DbOmMyz5.js +82 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/highlight-LH6Cyuz6.js +3 -0
- neutralino/_data/renderer/assets/html-CpATC083.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-C-4QDF6w.js +1 -0
- neutralino/_data/renderer/assets/index-CqHW60Dy.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-D2QSKlDI.js +1 -0
- neutralino/_data/renderer/assets/json-D8zfYii3.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BijRfmPy.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-Cpthnhzg.js +77 -0
- neutralino/_data/renderer/assets/markdown-CsS2tf5C.js +5 -0
- neutralino/_data/renderer/assets/python-B477ud9A.js +9 -0
- neutralino/_data/renderer/assets/richtext-BwtgvH7-.js +137 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Db1pwUWd.js +1 -0
- neutralino/_data/renderer/assets/sql-DbpHRl6F.js +2 -0
- neutralino/_data/renderer/assets/with-selector-CUfuSYau.js +1 -0
- neutralino/_data/renderer/assets/yaml-BPsr1O3S.js +1 -0
- neutralino/_data/renderer/index.html +22 -0
- neutralino/_data/renderer/manifest.json +202 -0
- neutralino/_data/renderer/neutralino.js +1 -0
- neutralino/_data/renderer/shared/mantine-core.mjs +5 -0
- neutralino/_data/renderer/shared/mantine-hooks.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom-client.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom.mjs +6 -0
- neutralino/_data/renderer/shared/react-jsx-runtime.mjs +5 -0
- neutralino/_data/renderer/shared/react.mjs +6 -0
- neutralino/_data/skills/README.md +6 -0
- neutralino/_data/skills/neutralino-app-patterns/SKILL.md +101 -0
- neutralino/_data/skills/neutralino-app-patterns/references/dashboards-and-background-work.md +55 -0
- neutralino/_data/skills/neutralino-app-patterns/references/storage-and-settings.md +57 -0
- neutralino/_data/skills/neutralino-app-patterns/references/tables-and-crud.md +81 -0
- neutralino/_data/skills/neutralino-frontend/SKILL.md +121 -0
- neutralino/_data/skills/neutralino-frontend/references/bridge.md +63 -0
- neutralino/_data/skills/neutralino-frontend/references/custom-components.md +84 -0
- neutralino/_data/skills/neutralino-frontend/references/frameworks.md +61 -0
- neutralino/_data/skills/neutralino-maintenance/SKILL.md +85 -0
- neutralino/_data/skills/neutralino-maintenance/references/platforms-and-gates.md +35 -0
- neutralino/_data/skills/neutralino-maintenance/references/records.md +38 -0
- neutralino/_data/skills/neutralino-maintenance/references/review-process.md +36 -0
- neutralino/_data/skills/neutralino-native/SKILL.md +107 -0
- neutralino/_data/skills/neutralino-native/references/api-conventions.md +72 -0
- neutralino/_data/skills/neutralino-native/references/desktop-helpers.md +53 -0
- neutralino/_data/skills/neutralino-native/references/permissions-windows.md +53 -0
- neutralino/_data/skills/neutralino-packaging/SKILL.md +99 -0
- neutralino/_data/skills/neutralino-packaging/references/build-layout.md +51 -0
- neutralino/_data/skills/neutralino-packaging/references/managed-install.md +59 -0
- neutralino/_data/skills/neutralino-packaging/references/templates-and-config.md +63 -0
- neutralino/_data/skills/neutralino-python/SKILL.md +109 -0
- neutralino/_data/skills/neutralino-python/references/architecture.md +53 -0
- neutralino/_data/skills/neutralino-python/references/cli.md +60 -0
- neutralino/_data/skills/neutralino-python/references/platforms-security.md +44 -0
- neutralino/_data/skills/neutralino-rpc/SKILL.md +114 -0
- neutralino/_data/skills/neutralino-rpc/references/errors-and-limits.md +44 -0
- neutralino/_data/skills/neutralino-rpc/references/expose-and-context.md +74 -0
- neutralino/_data/skills/neutralino-rpc/references/streams-and-cancellation.md +53 -0
- neutralino/_data/skills/neutralino-ui/SKILL.md +115 -0
- neutralino/_data/skills/neutralino-ui/references/components-and-tree.md +74 -0
- neutralino/_data/skills/neutralino-ui/references/state-forms-events.md +85 -0
- neutralino/_data/skills/neutralino-ui/references/themes-profiles-assets.md +105 -0
- neutralino/_data/skills/neutralino-updates/SKILL.md +94 -0
- neutralino/_data/skills/neutralino-updates/references/config-and-api.md +80 -0
- neutralino/_data/skills/neutralino-updates/references/releases-and-install.md +77 -0
- neutralino/_data/skills/neutralino-updates/references/security-rollback.md +48 -0
- neutralino/_data/ui/contracts.json +32927 -0
- neutralino/_data/ui/emoji.json +1 -0
- neutralino/_data/upstream-lock.json +97 -0
- neutralino/_managed.py +1099 -0
- neutralino/_paths.py +220 -0
- neutralino/_platform.py +150 -0
- neutralino/_scaffold.py +344 -0
- neutralino/api/_base.py +99 -0
- neutralino/api/_custom.py +1350 -0
- neutralino/api/_dec.py +21 -0
- neutralino/api/_enc.py +80 -0
- neutralino/api/app.py +119 -0
- neutralino/api/clipboard.py +101 -0
- neutralino/api/computer.py +261 -0
- neutralino/api/custom.py +36 -0
- neutralino/api/debug.py +41 -0
- neutralino/api/extensions.py +57 -0
- neutralino/api/filesystem.py +633 -0
- neutralino/api/net.py +22 -0
- neutralino/api/os.py +508 -0
- neutralino/api/resources.py +124 -0
- neutralino/api/server.py +66 -0
- neutralino/api/storage.py +98 -0
- neutralino/api/types.py +342 -0
- neutralino/api/updater.py +22 -0
- neutralino/api/window.py +397 -0
- neutralino/application.py +1261 -0
- neutralino/bundle.py +187 -0
- neutralino/cli.py +629 -0
- neutralino/client.py +496 -0
- neutralino/config.py +671 -0
- neutralino/devtools.py +1973 -0
- neutralino/errors.py +142 -0
- neutralino/events.py +579 -0
- neutralino/execution.py +293 -0
- neutralino/extension.py +134 -0
- neutralino/frontend/python-bridge.d.ts +207 -0
- neutralino/frontend/python-bridge.mjs +854 -0
- neutralino/protocol.py +456 -0
- neutralino/py.typed +0 -0
- neutralino/rpc.py +1625 -0
- neutralino/runtime.py +591 -0
- neutralino/supervisor.py +866 -0
- neutralino/sync_client.py +376 -0
- neutralino/templates/default/app.py +32 -0
- neutralino/templates/default/frontend/app.js +28 -0
- neutralino/templates/default/frontend/index.html +26 -0
- neutralino/templates/default/frontend/neutralino.js +1 -0
- neutralino/templates/default/frontend/styles.css +8 -0
- neutralino/templates/default/gitignore.txt +3 -0
- neutralino/templates/default/neutralino.config.json +25 -0
- neutralino/templates/hybrid/README.md +17 -0
- neutralino/templates/hybrid/app.py +49 -0
- neutralino/templates/hybrid/components/counter.mjs +37 -0
- neutralino/templates/hybrid/styles.css +21 -0
- neutralino/templates/python-ui/README.md +15 -0
- neutralino/templates/python-ui/app.py +44 -0
- neutralino/templates/python-ui/gitignore.txt +3 -0
- neutralino/templates/python-ui/requirements.txt +4 -0
- neutralino/templates/react/README.md +28 -0
- neutralino/templates/react/app.py +52 -0
- neutralino/templates/react/components/widget.mjs +23 -0
- neutralino/templates/react/widget/package.json +20 -0
- neutralino/templates/react/widget/src/Widget.jsx +25 -0
- neutralino/templates/react/widget/vite.config.mjs +19 -0
- neutralino/transport.py +661 -0
- neutralino/types.py +93 -0
- neutralino/ui/__init__.py +139 -0
- neutralino/ui/_app.py +1529 -0
- neutralino/ui/_assets.py +407 -0
- neutralino/ui/_bases.py +1210 -0
- neutralino/ui/_behaviours.py +1066 -0
- neutralino/ui/_charts.py +732 -0
- neutralino/ui/_component.py +882 -0
- neutralino/ui/_dates.py +168 -0
- neutralino/ui/_desktop.py +879 -0
- neutralino/ui/_events.py +192 -0
- neutralino/ui/_filters.py +427 -0
- neutralino/ui/_forms.py +282 -0
- neutralino/ui/_protocol.py +201 -0
- neutralino/ui/_schedule.py +543 -0
- neutralino/ui/_security.py +106 -0
- neutralino/ui/_session.py +969 -0
- neutralino/ui/_state.py +199 -0
- neutralino/ui/_tables.py +256 -0
- neutralino/ui/_theme.py +154 -0
- neutralino/ui/blocks/__init__.py +19 -0
- neutralino/ui/blocks/_data.py +2239 -0
- neutralino/ui/blocks/_interactive.py +622 -0
- neutralino/ui/blocks/_layout.py +2967 -0
- neutralino/ui/components/__init__.py +81 -0
- neutralino/ui/components/_dates.py +879 -0
- neutralino/ui/components/_editors.py +217 -0
- neutralino/ui/components/_extensions.py +790 -0
- neutralino/ui/components/_extras.py +303 -0
- neutralino/ui/components/_generated.py +30565 -0
- neutralino/ui/components/_types.py +17 -0
- neutralino/ui/schema.py +824 -0
- neutralino/ui/validators.py +362 -0
- neutralino/updates/__init__.py +96 -0
- neutralino/updates/_http.py +320 -0
- neutralino/updates/_layout.py +762 -0
- neutralino/updates/archive.py +216 -0
- neutralino/updates/config.py +256 -0
- neutralino/updates/errors.py +97 -0
- neutralino/updates/install.sh.in +201 -0
- neutralino/updates/launcher.py +18 -0
- neutralino/updates/manager.py +808 -0
- neutralino/updates/manifest.py +196 -0
- neutralino/updates/release.py +314 -0
- neutralino/updates/semver.py +84 -0
- neutralino/updates/sources.py +392 -0
- neutralino/windows.py +316 -0
- neutralino_python-0.1.0rc1.dist-info/METADATA +117 -0
- neutralino_python-0.1.0rc1.dist-info/RECORD +521 -0
- neutralino_python-0.1.0rc1.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0rc1.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
"""Application-facing update API: check, download + stage, confirm, background checks."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
import enum
|
|
7
|
+
import hashlib
|
|
8
|
+
import http.client
|
|
9
|
+
import json
|
|
10
|
+
import logging
|
|
11
|
+
import os
|
|
12
|
+
import re
|
|
13
|
+
import shutil
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
import threading
|
|
17
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Any, cast
|
|
21
|
+
|
|
22
|
+
from .._paths import AppPaths
|
|
23
|
+
from . import _layout
|
|
24
|
+
from ._http import HttpCache, HttpClient
|
|
25
|
+
from ._layout import ENV_ROOT, ENV_VERSION, LAUNCHER, Layout, LayoutError
|
|
26
|
+
from .archive import ArchiveLimits, extract_archive
|
|
27
|
+
from .config import AppConfig, github_api_base, load_config
|
|
28
|
+
from .errors import (
|
|
29
|
+
IntegrityError,
|
|
30
|
+
InvalidManifestError,
|
|
31
|
+
LockedError,
|
|
32
|
+
NetworkError,
|
|
33
|
+
NotFoundError,
|
|
34
|
+
UnauthorizedError,
|
|
35
|
+
UnsafeArchiveError,
|
|
36
|
+
UpdateError,
|
|
37
|
+
WrongApplicationError,
|
|
38
|
+
)
|
|
39
|
+
from .manifest import Asset, Manifest, current_platform
|
|
40
|
+
from .semver import parse_version
|
|
41
|
+
from .sources import GitHubSource, Source, UrlSource
|
|
42
|
+
|
|
43
|
+
log = logging.getLogger("neutralino.updates")
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"BackgroundChecker",
|
|
47
|
+
"InstallPaths",
|
|
48
|
+
"UpdateManager",
|
|
49
|
+
"UpdateResult",
|
|
50
|
+
"UpdateStatus",
|
|
51
|
+
"confirm_healthy",
|
|
52
|
+
"start_background_checks",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
RELEASE_INFO = "release.json"
|
|
56
|
+
BUILD_MANIFEST = "manifest.json" # neutralino build's manifest inside a release archive
|
|
57
|
+
_CHUNK = 1 << 16
|
|
58
|
+
VENV_TIMEOUT = 900.0
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass(frozen=True)
|
|
62
|
+
class InstallPaths:
|
|
63
|
+
"""Where an application's versions live and where the updater caches."""
|
|
64
|
+
|
|
65
|
+
root: Path
|
|
66
|
+
cache_dir: Path | None = None
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def for_app(cls, app_id: str, *, env: Mapping[str, str] | None = None) -> InstallPaths:
|
|
70
|
+
"""The per-app data dir (``versions/``, ``current.json``, ``install.lock``,
|
|
71
|
+
as the managed installer lays them out) and ``<cache dir>/updates``;
|
|
72
|
+
the root the launcher exported (``NEUTRALINO_UPDATE_ROOT``) wins."""
|
|
73
|
+
environ = os.environ if env is None else env
|
|
74
|
+
paths = AppPaths(app_id, env=environ)
|
|
75
|
+
root = environ.get(ENV_ROOT)
|
|
76
|
+
return cls(
|
|
77
|
+
Path(root) if root else paths.location("data"),
|
|
78
|
+
paths.location("cache") / "updates",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_app_paths(cls, paths: AppPaths) -> InstallPaths:
|
|
83
|
+
return cls(paths.location("data"), paths.location("cache") / "updates")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class UpdateStatus(enum.Enum):
|
|
87
|
+
DISABLED = "disabled"
|
|
88
|
+
NO_UPDATE = "no-update"
|
|
89
|
+
AVAILABLE = "available"
|
|
90
|
+
STAGED = "staged"
|
|
91
|
+
QUARANTINED = "quarantined"
|
|
92
|
+
ERROR = "error"
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@dataclass(frozen=True)
|
|
96
|
+
class UpdateResult:
|
|
97
|
+
status: UpdateStatus
|
|
98
|
+
current_version: str
|
|
99
|
+
latest_version: str | None = None
|
|
100
|
+
manifest: Manifest | None = None
|
|
101
|
+
asset: Asset | None = None
|
|
102
|
+
error: UpdateError | None = None
|
|
103
|
+
detail: str = ""
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def available(self) -> bool:
|
|
107
|
+
return self.status is UpdateStatus.AVAILABLE
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def message(self) -> str:
|
|
111
|
+
if self.status is UpdateStatus.ERROR and self.error is not None:
|
|
112
|
+
return f"update check failed: {self.error}"
|
|
113
|
+
if self.status is UpdateStatus.AVAILABLE:
|
|
114
|
+
return f"version {self.latest_version} is available (running {self.current_version})"
|
|
115
|
+
if self.status is UpdateStatus.STAGED:
|
|
116
|
+
return f"version {self.latest_version} is ready and starts at the next launch"
|
|
117
|
+
if self.status is UpdateStatus.QUARANTINED:
|
|
118
|
+
return f"version {self.latest_version} failed to start before and is skipped"
|
|
119
|
+
if self.status is UpdateStatus.DISABLED:
|
|
120
|
+
return "updates are disabled in app.toml"
|
|
121
|
+
return f"{self.current_version} is up to date" + (
|
|
122
|
+
f" ({self.detail})" if self.detail else ""
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class UpdateManager:
|
|
127
|
+
"""Check, download, verify and stage updates of one application.
|
|
128
|
+
|
|
129
|
+
``config`` is the application's ``app.toml``; ``paths`` defaults to
|
|
130
|
+
:meth:`InstallPaths.for_app`. Nothing is activated while the app runs: a
|
|
131
|
+
staged version starts at the next launch (``activation = "next-start"``)
|
|
132
|
+
or after :meth:`activate_staged` (``"prompt"``).
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
def __init__(
|
|
136
|
+
self,
|
|
137
|
+
config: AppConfig,
|
|
138
|
+
paths: InstallPaths | AppPaths | None = None,
|
|
139
|
+
*,
|
|
140
|
+
source: Source | None = None,
|
|
141
|
+
platform: str | None = None,
|
|
142
|
+
running_version: str | None = None,
|
|
143
|
+
http: HttpClient | None = None,
|
|
144
|
+
env: Mapping[str, str] | None = None,
|
|
145
|
+
archive_limits: ArchiveLimits | None = None,
|
|
146
|
+
) -> None:
|
|
147
|
+
self.config = config
|
|
148
|
+
self._env = dict(os.environ if env is None else env)
|
|
149
|
+
if paths is None:
|
|
150
|
+
paths = InstallPaths.for_app(config.app.id, env=self._env)
|
|
151
|
+
elif isinstance(paths, AppPaths):
|
|
152
|
+
paths = InstallPaths.from_app_paths(paths)
|
|
153
|
+
self.paths = paths
|
|
154
|
+
self.layout = Layout(paths.root)
|
|
155
|
+
self.running_version = running_version or config.app.version
|
|
156
|
+
parse_version(self.running_version)
|
|
157
|
+
self._platform = platform
|
|
158
|
+
self.http = http or HttpClient()
|
|
159
|
+
self.cache = HttpCache(paths.cache_dir / "http-cache.json" if paths.cache_dir else None)
|
|
160
|
+
self.archive_limits = archive_limits or ArchiveLimits()
|
|
161
|
+
self._source = source
|
|
162
|
+
|
|
163
|
+
@classmethod
|
|
164
|
+
def from_environment(
|
|
165
|
+
cls, config_path: str | os.PathLike[str] | None = None, **kw: Any
|
|
166
|
+
) -> UpdateManager:
|
|
167
|
+
"""Load ``app.toml`` (given, else next to the entry script, else the cwd)."""
|
|
168
|
+
if config_path is None:
|
|
169
|
+
candidates = [Path(sys.argv[0]).resolve().parent / "app.toml", Path.cwd() / "app.toml"]
|
|
170
|
+
config_path = next((c for c in candidates if c.is_file()), candidates[-1])
|
|
171
|
+
return cls(load_config(config_path), **kw)
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def platform(self) -> str:
|
|
175
|
+
if self._platform is None:
|
|
176
|
+
self._platform = current_platform()
|
|
177
|
+
return self._platform
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def enabled(self) -> bool:
|
|
181
|
+
return self.config.updates.enabled
|
|
182
|
+
|
|
183
|
+
@property
|
|
184
|
+
def source(self) -> Source:
|
|
185
|
+
if self._source is None:
|
|
186
|
+
u = self.config.updates
|
|
187
|
+
if u.provider == "github":
|
|
188
|
+
assert u.repository is not None
|
|
189
|
+
self._source = GitHubSource(
|
|
190
|
+
u.repository,
|
|
191
|
+
application_id=self.config.app.id,
|
|
192
|
+
auth=u.auth,
|
|
193
|
+
api=github_api_base(u.github_url),
|
|
194
|
+
http=self.http,
|
|
195
|
+
cache=self.cache,
|
|
196
|
+
env=self._env,
|
|
197
|
+
)
|
|
198
|
+
else:
|
|
199
|
+
assert u.url is not None
|
|
200
|
+
self._source = UrlSource(
|
|
201
|
+
u.url, application_id=self.config.app.id, http=self.http, cache=self.cache
|
|
202
|
+
)
|
|
203
|
+
return self._source
|
|
204
|
+
|
|
205
|
+
# ----------------------------------------------------------------- check
|
|
206
|
+
def _pointer(self) -> _layout.Pointer:
|
|
207
|
+
try:
|
|
208
|
+
return self.layout.read_pointer()
|
|
209
|
+
except (LayoutError, OSError):
|
|
210
|
+
return _layout.Pointer()
|
|
211
|
+
|
|
212
|
+
def check(self) -> UpdateResult:
|
|
213
|
+
"""Ask the source for the latest release. Raises :class:`UpdateError`
|
|
214
|
+
subclasses on failure (each with an actionable message)."""
|
|
215
|
+
if not self.enabled:
|
|
216
|
+
return UpdateResult(UpdateStatus.DISABLED, self.running_version)
|
|
217
|
+
manifest = self.source.fetch_manifest(
|
|
218
|
+
prerelease=self.config.updates.channel == "prerelease"
|
|
219
|
+
)
|
|
220
|
+
latest = manifest.parsed_version
|
|
221
|
+
current = parse_version(self.running_version)
|
|
222
|
+
if latest.is_prerelease and self.config.updates.channel != "prerelease":
|
|
223
|
+
return UpdateResult(
|
|
224
|
+
UpdateStatus.NO_UPDATE, self.running_version, manifest.version, manifest,
|
|
225
|
+
detail="latest is a prerelease and the channel is stable",
|
|
226
|
+
) # fmt: skip
|
|
227
|
+
if not latest > current:
|
|
228
|
+
detail = "" if latest == current else f"never downgrading to {manifest.version}"
|
|
229
|
+
return UpdateResult(
|
|
230
|
+
UpdateStatus.NO_UPDATE,
|
|
231
|
+
self.running_version,
|
|
232
|
+
manifest.version,
|
|
233
|
+
manifest,
|
|
234
|
+
detail=detail,
|
|
235
|
+
)
|
|
236
|
+
asset = manifest.asset_for(self.platform)
|
|
237
|
+
p = self._pointer()
|
|
238
|
+
if manifest.version in p.quarantined:
|
|
239
|
+
return UpdateResult(
|
|
240
|
+
UpdateStatus.QUARANTINED, self.running_version, manifest.version, manifest, asset
|
|
241
|
+
)
|
|
242
|
+
if manifest.version in (p.pending, p.staged) and self.layout.usable(manifest.version):
|
|
243
|
+
return UpdateResult(
|
|
244
|
+
UpdateStatus.STAGED, self.running_version, manifest.version, manifest, asset,
|
|
245
|
+
detail="already staged",
|
|
246
|
+
) # fmt: skip
|
|
247
|
+
return UpdateResult(
|
|
248
|
+
UpdateStatus.AVAILABLE, self.running_version, manifest.version, manifest, asset
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
def check_quietly(self) -> UpdateResult:
|
|
252
|
+
""":meth:`check` that returns failures as ``UpdateStatus.ERROR`` results."""
|
|
253
|
+
try:
|
|
254
|
+
return self.check()
|
|
255
|
+
except UpdateError as e:
|
|
256
|
+
return UpdateResult(UpdateStatus.ERROR, self.running_version, error=e)
|
|
257
|
+
except Exception as e: # an update problem must never take the app down
|
|
258
|
+
err = UpdateError(f"unexpected {type(e).__name__}")
|
|
259
|
+
return UpdateResult(UpdateStatus.ERROR, self.running_version, error=err)
|
|
260
|
+
|
|
261
|
+
# -------------------------------------------------------------- download
|
|
262
|
+
def _download(self, manifest: Manifest, asset: Asset, _restarted: bool = False) -> Path:
|
|
263
|
+
staging = self.layout.staging
|
|
264
|
+
staging.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
265
|
+
ext = ".zip" if asset.archive_format == "zip" else ".tar.gz"
|
|
266
|
+
final = staging / f"{asset.sha256}{ext}"
|
|
267
|
+
if final.is_file() and _digest(final) == (asset.sha256, asset.size):
|
|
268
|
+
return final
|
|
269
|
+
final.unlink(missing_ok=True)
|
|
270
|
+
part = staging / f"{asset.sha256}{ext}.part" # same name after an interruption: resumable
|
|
271
|
+
offset = part.stat().st_size if part.is_file() else 0
|
|
272
|
+
if offset > asset.size:
|
|
273
|
+
part.unlink()
|
|
274
|
+
offset = 0
|
|
275
|
+
if offset == asset.size:
|
|
276
|
+
# The app exited between the last fsync and the rename: a range request
|
|
277
|
+
# at the end of the file is answered 416 by real hosts, so decide locally.
|
|
278
|
+
if _digest(part) == (asset.sha256, asset.size):
|
|
279
|
+
part.replace(final)
|
|
280
|
+
return final
|
|
281
|
+
part.unlink()
|
|
282
|
+
offset = 0
|
|
283
|
+
h = hashlib.sha256()
|
|
284
|
+
if offset:
|
|
285
|
+
with part.open("rb") as f:
|
|
286
|
+
while chunk := f.read(_CHUNK):
|
|
287
|
+
h.update(chunk)
|
|
288
|
+
with self.source.open_asset(manifest, asset, range_start=offset) as (
|
|
289
|
+
status,
|
|
290
|
+
headers,
|
|
291
|
+
body,
|
|
292
|
+
_,
|
|
293
|
+
):
|
|
294
|
+
if (
|
|
295
|
+
status == 206
|
|
296
|
+
and offset
|
|
297
|
+
and headers.get("content-range", "").startswith(f"bytes {offset}-")
|
|
298
|
+
):
|
|
299
|
+
mode = "ab"
|
|
300
|
+
log.debug("resuming download of %s at %d bytes", asset.name, offset)
|
|
301
|
+
elif status == 200:
|
|
302
|
+
mode, offset, h = "wb", 0, hashlib.sha256()
|
|
303
|
+
elif status == 416 and offset and not _restarted:
|
|
304
|
+
part.unlink(missing_ok=True) # the host rejects the range: start over once
|
|
305
|
+
return self._download(manifest, asset, _restarted=True)
|
|
306
|
+
elif status == 404:
|
|
307
|
+
raise NotFoundError(f"release asset {asset.name} not found")
|
|
308
|
+
elif status in (401, 403):
|
|
309
|
+
raise UnauthorizedError(f"download of {asset.name} refused (HTTP {status})")
|
|
310
|
+
else:
|
|
311
|
+
raise NetworkError(f"download of {asset.name} answered HTTP {status}")
|
|
312
|
+
total = offset
|
|
313
|
+
with part.open(mode) as out:
|
|
314
|
+
try:
|
|
315
|
+
while chunk := body.read(_CHUNK):
|
|
316
|
+
total += len(chunk)
|
|
317
|
+
if total > asset.size:
|
|
318
|
+
break
|
|
319
|
+
h.update(chunk)
|
|
320
|
+
out.write(chunk)
|
|
321
|
+
except (OSError, ValueError, http.client.HTTPException) as e:
|
|
322
|
+
out.flush()
|
|
323
|
+
raise NetworkError(
|
|
324
|
+
f"download of {asset.name} interrupted at {total} bytes "
|
|
325
|
+
f"({type(e).__name__}); "
|
|
326
|
+
"it resumes at the next attempt"
|
|
327
|
+
) from None
|
|
328
|
+
out.flush()
|
|
329
|
+
os.fsync(out.fileno())
|
|
330
|
+
if total > asset.size:
|
|
331
|
+
part.unlink(missing_ok=True)
|
|
332
|
+
raise IntegrityError(f"{asset.name} is larger than the manifest's {asset.size} bytes")
|
|
333
|
+
if total < asset.size:
|
|
334
|
+
raise NetworkError(
|
|
335
|
+
f"download of {asset.name} ended at {total} of {asset.size} bytes; "
|
|
336
|
+
"it resumes at the next attempt"
|
|
337
|
+
)
|
|
338
|
+
if h.hexdigest() != asset.sha256:
|
|
339
|
+
part.unlink(missing_ok=True)
|
|
340
|
+
raise IntegrityError(f"SHA-256 of {asset.name} does not match the manifest")
|
|
341
|
+
part.replace(final)
|
|
342
|
+
return final
|
|
343
|
+
|
|
344
|
+
def _verify_release(self, tree: Path, manifest: Manifest) -> None:
|
|
345
|
+
info_path = tree / RELEASE_INFO
|
|
346
|
+
try:
|
|
347
|
+
info = json.loads(info_path.read_bytes()[: 64 * 1024])
|
|
348
|
+
except (OSError, ValueError):
|
|
349
|
+
raise InvalidManifestError(f"the archive has no valid {RELEASE_INFO}") from None
|
|
350
|
+
if not isinstance(info, dict):
|
|
351
|
+
raise InvalidManifestError(f"{RELEASE_INFO} must be an object")
|
|
352
|
+
rel: dict[str, Any] = info # pyright: ignore[reportUnknownVariableType]
|
|
353
|
+
if rel.get("applicationId") != self.config.app.id:
|
|
354
|
+
raise WrongApplicationError("the archive belongs to another application")
|
|
355
|
+
if rel.get("version") != manifest.version:
|
|
356
|
+
raise InvalidManifestError("the archive's version differs from the manifest's")
|
|
357
|
+
if rel.get("platform") != self.platform:
|
|
358
|
+
raise InvalidManifestError("the archive is built for another platform")
|
|
359
|
+
if not (tree / "boot.py").is_file():
|
|
360
|
+
raise InvalidManifestError("the archive has no boot.py launcher entry")
|
|
361
|
+
running = self._env.get(ENV_VERSION) or self.running_version
|
|
362
|
+
installed_managed = (self.layout.versions / running / "venv").is_dir()
|
|
363
|
+
if installed_managed and managed_build(tree) is None:
|
|
364
|
+
raise InvalidManifestError(
|
|
365
|
+
f"release {manifest.version} has no wheelhouse, but this installation is "
|
|
366
|
+
"managed (its dependencies live in a venv per version)",
|
|
367
|
+
hint="publish the release with neutralino release --mode managed",
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
def download_and_stage(self, result: UpdateResult | None = None) -> UpdateResult:
|
|
371
|
+
"""Download, verify (size + SHA-256), extract and stage the newer version.
|
|
372
|
+
|
|
373
|
+
Returns the (possibly unchanged) result: ``STAGED`` on success. The
|
|
374
|
+
running version's files are never touched; with ``activation =
|
|
375
|
+
"next-start"`` the launcher activates the version at the next start.
|
|
376
|
+
"""
|
|
377
|
+
result = result or self.check()
|
|
378
|
+
if result.status is not UpdateStatus.AVAILABLE:
|
|
379
|
+
return result
|
|
380
|
+
manifest, asset = result.manifest, result.asset
|
|
381
|
+
assert manifest is not None and asset is not None
|
|
382
|
+
self.layout.ensure()
|
|
383
|
+
archive: Path | None = None
|
|
384
|
+
dl_lock = _layout.FileLock(self.layout.staging / ".download.lock")
|
|
385
|
+
if not dl_lock.acquire(timeout=0):
|
|
386
|
+
raise LockedError("another update download is in progress")
|
|
387
|
+
try:
|
|
388
|
+
archive = self._download(manifest, asset)
|
|
389
|
+
version = manifest.version
|
|
390
|
+
tmp = self.layout.staging / f"{version}.extract"
|
|
391
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
392
|
+
extract_archive(archive, tmp, limits=self.archive_limits)
|
|
393
|
+
try:
|
|
394
|
+
self._verify_release(tmp, manifest)
|
|
395
|
+
build = managed_build(tmp)
|
|
396
|
+
if build is not None:
|
|
397
|
+
install_managed_venv(tmp, build, version=manifest.version)
|
|
398
|
+
_layout.fsync_dir(tmp)
|
|
399
|
+
with self.layout.update_lock().held(timeout=60):
|
|
400
|
+
p = self.layout.read_pointer()
|
|
401
|
+
if version in p.quarantined:
|
|
402
|
+
raise UpdateError(f"version {version} is quarantined")
|
|
403
|
+
if version in (p.current, p.previous):
|
|
404
|
+
raise UpdateError(f"version {version} is installed already")
|
|
405
|
+
dest = self.layout.version_dir(version)
|
|
406
|
+
if dest.exists() or dest.is_symlink():
|
|
407
|
+
if dest.is_symlink() or not dest.is_dir():
|
|
408
|
+
dest.unlink()
|
|
409
|
+
else:
|
|
410
|
+
shutil.rmtree(dest) # an earlier, superseded staging of it
|
|
411
|
+
tmp.replace(dest)
|
|
412
|
+
_layout.fsync_dir(self.layout.versions)
|
|
413
|
+
if self.config.updates.activation == "next-start":
|
|
414
|
+
p.pending, p.staged = version, None
|
|
415
|
+
else:
|
|
416
|
+
p.staged, p.pending = version, None
|
|
417
|
+
self.layout.write_pointer(p)
|
|
418
|
+
self.layout.note(f"staged {version} ({self.config.updates.activation})")
|
|
419
|
+
self._prune_locked(p)
|
|
420
|
+
finally:
|
|
421
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
422
|
+
archive.unlink(missing_ok=True)
|
|
423
|
+
except (LayoutError, OSError) as e:
|
|
424
|
+
raise UpdateError(f"staging failed: {e}") from None
|
|
425
|
+
except UnsafeArchiveError:
|
|
426
|
+
if archive is not None:
|
|
427
|
+
archive.unlink(missing_ok=True)
|
|
428
|
+
raise
|
|
429
|
+
finally:
|
|
430
|
+
dl_lock.release()
|
|
431
|
+
return UpdateResult(
|
|
432
|
+
UpdateStatus.STAGED, self.running_version, manifest.version, manifest, asset
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
# ------------------------------------------------------------ lifecycle
|
|
436
|
+
@property
|
|
437
|
+
def pending_restart(self) -> bool:
|
|
438
|
+
"""A newer version is staged and starts when the app is next launched."""
|
|
439
|
+
p = self._pointer()
|
|
440
|
+
return p.pending is not None and p.pending != self.running_version
|
|
441
|
+
|
|
442
|
+
@property
|
|
443
|
+
def staged_version(self) -> str | None:
|
|
444
|
+
p = self._pointer()
|
|
445
|
+
return p.pending or p.staged
|
|
446
|
+
|
|
447
|
+
def activate_staged(self) -> bool:
|
|
448
|
+
"""``activation = "prompt"``: after the user agreed, start the staged
|
|
449
|
+
version at the next launch."""
|
|
450
|
+
with self.layout.update_lock().held(timeout=60):
|
|
451
|
+
p = self.layout.read_pointer()
|
|
452
|
+
if p.staged is None:
|
|
453
|
+
return False
|
|
454
|
+
p.pending, p.staged = p.staged, None
|
|
455
|
+
self.layout.write_pointer(p)
|
|
456
|
+
return True
|
|
457
|
+
|
|
458
|
+
def relaunch(self, argv: Sequence[str] | None = None) -> bool:
|
|
459
|
+
"""Restart into the staged version, on the user's explicit request only.
|
|
460
|
+
|
|
461
|
+
Call it after the application has stopped (``app.run()`` returned):
|
|
462
|
+
it replaces this process with the install's launcher (``launcher.py``),
|
|
463
|
+
which activates the pending version as a trial (rolled back at the next
|
|
464
|
+
launch unless it confirms). Returns False, without restarting, when no
|
|
465
|
+
version is pending. Raises :class:`UpdateError` when the app was not
|
|
466
|
+
started by the launcher or the platform has no ``exec``. Nothing in
|
|
467
|
+
this package ever calls it on its own: the default policy is to
|
|
468
|
+
activate at the next start.
|
|
469
|
+
"""
|
|
470
|
+
if not self.pending_restart:
|
|
471
|
+
return False
|
|
472
|
+
root = os.environ.get(ENV_ROOT)
|
|
473
|
+
launcher = Path(root) / LAUNCHER if root else None
|
|
474
|
+
if launcher is None or not launcher.is_file():
|
|
475
|
+
raise UpdateError(
|
|
476
|
+
"this copy was not started by the update launcher, so it cannot restart into "
|
|
477
|
+
"the new version",
|
|
478
|
+
hint="the new version starts the next time the installed command is run",
|
|
479
|
+
)
|
|
480
|
+
if os.name != "posix":
|
|
481
|
+
raise UpdateError("restarting in place needs exec (Linux/macOS)",
|
|
482
|
+
hint="the new version starts at the next launch") # fmt: skip
|
|
483
|
+
base = getattr(sys, "_base_executable", None) or sys.executable
|
|
484
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
485
|
+
cmd = [base, "-I", str(launcher), "--app-dir", str(root), "--", *args]
|
|
486
|
+
self.layout.note(f"restart requested by {self.running_version}")
|
|
487
|
+
logging.shutdown()
|
|
488
|
+
sys.stdout.flush()
|
|
489
|
+
sys.stderr.flush()
|
|
490
|
+
os.execv(cmd[0], cmd) # noqa: S606 - fixed argv, no shell; keeps the launch lock fd
|
|
491
|
+
raise AssertionError("unreachable") # pragma: no cover
|
|
492
|
+
|
|
493
|
+
def confirm_healthy(self) -> bool:
|
|
494
|
+
"""End this version's trial (call once the backend and page are ready)."""
|
|
495
|
+
return confirm_healthy(
|
|
496
|
+
root=self.paths.root,
|
|
497
|
+
version=self._env.get(ENV_VERSION) or self.running_version,
|
|
498
|
+
keep_versions=self.config.updates.keep_versions,
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
def prune(self) -> list[str]:
|
|
502
|
+
with self.layout.update_lock().held(timeout=60):
|
|
503
|
+
return self._prune_locked(self.layout.read_pointer())
|
|
504
|
+
|
|
505
|
+
def _prune_locked(self, p: _layout.Pointer) -> list[str]:
|
|
506
|
+
return prune(self.layout, p, self.config.updates.keep_versions)
|
|
507
|
+
|
|
508
|
+
def start_background_checks(self, app: Any = None, **kw: Any) -> BackgroundChecker | None:
|
|
509
|
+
return start_background_checks(app, self, **kw)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
def managed_build(tree: Path) -> dict[str, Any] | None:
|
|
513
|
+
"""The build manifest of a managed release (``neutralino build --mode
|
|
514
|
+
managed``: wheelhouse + ``requirements.lock.txt``), else None."""
|
|
515
|
+
try:
|
|
516
|
+
with (tree / BUILD_MANIFEST).open("rb") as f:
|
|
517
|
+
doc = json.loads(f.read(4 * 1024 * 1024))
|
|
518
|
+
except (OSError, ValueError):
|
|
519
|
+
return None
|
|
520
|
+
if not isinstance(doc, dict):
|
|
521
|
+
return None
|
|
522
|
+
build = cast("dict[str, Any]", doc)
|
|
523
|
+
if build.get("mode") != "managed":
|
|
524
|
+
return None
|
|
525
|
+
return build
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def _clean_env() -> dict[str, str]:
|
|
529
|
+
env = {k: v for k, v in os.environ.items() if not k.startswith(("PIP_", "PYTHON"))}
|
|
530
|
+
env.update(PIP_CONFIG_FILE=os.devnull, PIP_NO_INDEX="1", PIP_DISABLE_PIP_VERSION_CHECK="1")
|
|
531
|
+
return env
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
def find_python(want: str, *, need_pip: bool) -> str | None:
|
|
535
|
+
"""A CPython ``want`` (``"3.12"``) able to create a venv (with pip when
|
|
536
|
+
wheels must be installed): this interpreter, its base, or ``pythonX.Y``."""
|
|
537
|
+
probe = "import sys, venv" + (", ensurepip" if need_pip else "")
|
|
538
|
+
probe += "; print('%d.%d' % sys.version_info[:2])"
|
|
539
|
+
base = getattr(sys, "_base_executable", None)
|
|
540
|
+
found = (sys.executable, base, shutil.which(f"python{want}"))
|
|
541
|
+
for cand in dict.fromkeys(c for c in found if c):
|
|
542
|
+
try:
|
|
543
|
+
r = subprocess.run(
|
|
544
|
+
[cand, "-I", "-c", probe], capture_output=True, encoding="utf-8",
|
|
545
|
+
errors="replace", timeout=60, env=_clean_env(), check=False,
|
|
546
|
+
) # fmt: skip
|
|
547
|
+
except (OSError, subprocess.SubprocessError):
|
|
548
|
+
continue
|
|
549
|
+
if r.returncode == 0 and r.stdout.strip() == want:
|
|
550
|
+
return cand
|
|
551
|
+
return None
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
def install_managed_venv(tree: Path, build: Mapping[str, Any], *, version: str) -> None:
|
|
555
|
+
"""Create ``tree/venv`` and install the bundled wheels into it, offline
|
|
556
|
+
(``pip --no-index --require-hashes`` from ``tree/wheelhouse``), as the
|
|
557
|
+
managed installer does; the wheelhouse is removed afterwards."""
|
|
558
|
+
target: object = build.get("target")
|
|
559
|
+
want: object = (
|
|
560
|
+
cast("dict[str, object]", target).get("python") if isinstance(target, dict) else None
|
|
561
|
+
)
|
|
562
|
+
wheels: object = build.get("wheels")
|
|
563
|
+
if not isinstance(want, str) or not re.fullmatch(r"3\.\d{1,2}", want):
|
|
564
|
+
raise InvalidManifestError(f"version {version}: the managed build names no CPython version")
|
|
565
|
+
if not isinstance(wheels, list):
|
|
566
|
+
raise InvalidManifestError(f"version {version}: the managed build lists no wheels")
|
|
567
|
+
lock, house = tree / "requirements.lock.txt", tree / "wheelhouse"
|
|
568
|
+
has_wheels = bool(cast("list[object]", wheels))
|
|
569
|
+
if has_wheels and not (lock.is_file() and house.is_dir()):
|
|
570
|
+
raise InvalidManifestError(f"version {version}: the wheelhouse or its lock file is missing")
|
|
571
|
+
python = find_python(want, need_pip=has_wheels)
|
|
572
|
+
if python is None:
|
|
573
|
+
raise UpdateError(
|
|
574
|
+
f"version {version} needs CPython {want} with venv"
|
|
575
|
+
+ (" and ensurepip" if has_wheels else ""),
|
|
576
|
+
hint=f"install python{want} (Debian/Ubuntu: python{want}-venv) and check again",
|
|
577
|
+
)
|
|
578
|
+
venv = tree / "venv"
|
|
579
|
+
steps = [[python, "-m", "venv", *([] if has_wheels else ["--without-pip"]), str(venv)]]
|
|
580
|
+
if has_wheels:
|
|
581
|
+
steps.append([str(venv / "bin" / "python"), "-m", "pip", "install", "--no-index",
|
|
582
|
+
"--find-links", str(house), "--require-hashes", "--only-binary=:all:",
|
|
583
|
+
"--no-input", "--disable-pip-version-check", "-r", str(lock)]) # fmt: skip
|
|
584
|
+
for n, cmd in enumerate(steps):
|
|
585
|
+
what = "creating the venv" if n == 0 else "installing the bundled wheels (offline)"
|
|
586
|
+
try:
|
|
587
|
+
r = subprocess.run(cmd, capture_output=True, encoding="utf-8", errors="replace",
|
|
588
|
+
env=_clean_env(), timeout=VENV_TIMEOUT, check=False) # fmt: skip
|
|
589
|
+
except (OSError, subprocess.SubprocessError) as e:
|
|
590
|
+
raise UpdateError(f"{what} of version {version} failed: {type(e).__name__}") from None
|
|
591
|
+
if r.returncode != 0:
|
|
592
|
+
tail = (r.stderr or r.stdout).strip()[-600:]
|
|
593
|
+
raise UpdateError(f"{what} of version {version} failed: {tail}")
|
|
594
|
+
if _layout.venv_python(tree) is None:
|
|
595
|
+
raise UpdateError(f"version {version}: the new venv has no interpreter")
|
|
596
|
+
shutil.rmtree(house, ignore_errors=True)
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
def _digest(path: Path) -> tuple[str, int]:
|
|
600
|
+
h = hashlib.sha256()
|
|
601
|
+
n = 0
|
|
602
|
+
with path.open("rb") as f:
|
|
603
|
+
while chunk := f.read(_CHUNK):
|
|
604
|
+
n += len(chunk)
|
|
605
|
+
h.update(chunk)
|
|
606
|
+
return h.hexdigest(), n
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def prune(layout: Layout, p: _layout.Pointer, keep_versions: int = 2) -> list[str]:
|
|
610
|
+
"""Remove versions other than current, previous (if keep_versions >= 2),
|
|
611
|
+
pending/staged/trial and the newest others up to ``keep_versions``; old
|
|
612
|
+
quarantined builds and stale staging files. Never touches user data."""
|
|
613
|
+
keep = {v for v in (p.current, p.pending, p.staged, p.trial) if v}
|
|
614
|
+
if keep_versions >= 2 and p.previous:
|
|
615
|
+
keep.add(p.previous)
|
|
616
|
+
extra = keep_versions - (2 if p.previous else 1)
|
|
617
|
+
for v in reversed(layout.installed()):
|
|
618
|
+
if extra <= 0:
|
|
619
|
+
break
|
|
620
|
+
if v not in keep:
|
|
621
|
+
keep.add(v)
|
|
622
|
+
extra -= 1
|
|
623
|
+
removed: list[str] = []
|
|
624
|
+
for v in layout.installed():
|
|
625
|
+
if v not in keep:
|
|
626
|
+
d = layout.versions / v
|
|
627
|
+
if d.is_symlink():
|
|
628
|
+
d.unlink()
|
|
629
|
+
else:
|
|
630
|
+
shutil.rmtree(d, ignore_errors=True)
|
|
631
|
+
removed.append(v)
|
|
632
|
+
if layout.quarantine_dir.is_dir():
|
|
633
|
+
newest = p.quarantined[-1:] if p.quarantined else []
|
|
634
|
+
for d in layout.quarantine_dir.iterdir():
|
|
635
|
+
if d.name not in newest:
|
|
636
|
+
shutil.rmtree(d, ignore_errors=True)
|
|
637
|
+
if removed:
|
|
638
|
+
layout.note(f"pruned {', '.join(removed)}")
|
|
639
|
+
return removed
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
def _refresh_launcher(layout: Layout) -> None:
|
|
643
|
+
src = Path(_layout.__file__).read_bytes()
|
|
644
|
+
target = layout.root / _layout.LAUNCHER
|
|
645
|
+
with contextlib.suppress(OSError):
|
|
646
|
+
if target.read_bytes() == src:
|
|
647
|
+
return
|
|
648
|
+
_layout.atomic_write(target, src, 0o644)
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
def confirm_healthy(
|
|
652
|
+
*,
|
|
653
|
+
root: str | os.PathLike[str] | None = None,
|
|
654
|
+
version: str | None = None,
|
|
655
|
+
keep_versions: int = 2,
|
|
656
|
+
) -> bool:
|
|
657
|
+
"""End the running version's trial after real backend/page readiness.
|
|
658
|
+
|
|
659
|
+
Without arguments it uses what the launcher exported
|
|
660
|
+
(``NEUTRALINO_UPDATE_ROOT``/``NEUTRALINO_UPDATE_VERSION``); outside a
|
|
661
|
+
versioned install it does nothing and returns False. True if a trial ended.
|
|
662
|
+
Also refreshes ``<root>/launcher.py`` and prunes old versions.
|
|
663
|
+
"""
|
|
664
|
+
root = root or os.environ.get(ENV_ROOT)
|
|
665
|
+
version = version or os.environ.get(ENV_VERSION)
|
|
666
|
+
if not root or not version:
|
|
667
|
+
return False
|
|
668
|
+
layout = Layout(root)
|
|
669
|
+
try:
|
|
670
|
+
with layout.update_lock().held(timeout=30):
|
|
671
|
+
p = layout.read_pointer()
|
|
672
|
+
ended = p.trial == version and p.current == version
|
|
673
|
+
if ended:
|
|
674
|
+
p.trial = None
|
|
675
|
+
layout.write_pointer(p)
|
|
676
|
+
layout.note(f"version {version} confirmed healthy")
|
|
677
|
+
if p.current == version and p.trial is None:
|
|
678
|
+
prune(layout, p, keep_versions)
|
|
679
|
+
_refresh_launcher(layout)
|
|
680
|
+
return ended
|
|
681
|
+
except (LayoutError, OSError) as e:
|
|
682
|
+
log.debug("confirm_healthy failed: %s", type(e).__name__)
|
|
683
|
+
return False
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
# ------------------------------------------------------------- background
|
|
687
|
+
def _app_stopped(app: Any) -> bool:
|
|
688
|
+
if app is None:
|
|
689
|
+
return False
|
|
690
|
+
state = getattr(app, "state", None)
|
|
691
|
+
if state is None and hasattr(app, "native"):
|
|
692
|
+
state = getattr(app.native, "state", None)
|
|
693
|
+
return getattr(state, "value", None) == "STOPPED"
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
class BackgroundChecker:
|
|
697
|
+
"""A daemon thread that checks (and stages) updates periodically.
|
|
698
|
+
|
|
699
|
+
Failures never raise and never show UI: they are logged at debug level
|
|
700
|
+
(warning if ``silent_on_failure = false``) without credentials. It ends
|
|
701
|
+
with :meth:`stop` or when ``app`` reaches the STOPPED state.
|
|
702
|
+
"""
|
|
703
|
+
|
|
704
|
+
def __init__(
|
|
705
|
+
self,
|
|
706
|
+
manager: UpdateManager,
|
|
707
|
+
app: Any = None,
|
|
708
|
+
*,
|
|
709
|
+
interval: float | None = None,
|
|
710
|
+
initial_delay: float = 3.0,
|
|
711
|
+
stage: bool = True,
|
|
712
|
+
on_result: Callable[[UpdateResult], Any] | None = None,
|
|
713
|
+
poll: float = 1.0,
|
|
714
|
+
) -> None:
|
|
715
|
+
u = manager.config.updates
|
|
716
|
+
self.manager = manager
|
|
717
|
+
self.app = app
|
|
718
|
+
self.interval = u.check_interval_hours * 3600 if interval is None else interval
|
|
719
|
+
self.initial_delay = initial_delay if u.check_on_startup else self.interval
|
|
720
|
+
self.stage = stage
|
|
721
|
+
self.on_result = on_result
|
|
722
|
+
self.poll = poll
|
|
723
|
+
self.last_result: UpdateResult | None = None
|
|
724
|
+
self.checks = 0
|
|
725
|
+
self._stop = threading.Event()
|
|
726
|
+
self._thread = threading.Thread(target=self._run, name="neutralino-updates", daemon=True)
|
|
727
|
+
|
|
728
|
+
def start(self) -> BackgroundChecker:
|
|
729
|
+
self._thread.start()
|
|
730
|
+
return self
|
|
731
|
+
|
|
732
|
+
def stop(self, timeout: float | None = 5.0) -> None:
|
|
733
|
+
self._stop.set()
|
|
734
|
+
if self._thread.is_alive() and threading.current_thread() is not self._thread:
|
|
735
|
+
self._thread.join(timeout)
|
|
736
|
+
|
|
737
|
+
@property
|
|
738
|
+
def running(self) -> bool:
|
|
739
|
+
return self._thread.is_alive()
|
|
740
|
+
|
|
741
|
+
def _wait(self, seconds: float) -> bool:
|
|
742
|
+
"""Sleep up to ``seconds``; False if stopped meanwhile."""
|
|
743
|
+
remaining = seconds
|
|
744
|
+
while remaining > 0:
|
|
745
|
+
step = min(self.poll, remaining)
|
|
746
|
+
if self._stop.wait(step) or _app_stopped(self.app):
|
|
747
|
+
return False
|
|
748
|
+
remaining -= step
|
|
749
|
+
return not (self._stop.is_set() or _app_stopped(self.app))
|
|
750
|
+
|
|
751
|
+
def _report(self, result: UpdateResult) -> None:
|
|
752
|
+
self.last_result = result
|
|
753
|
+
if result.status is UpdateStatus.ERROR and result.error is not None:
|
|
754
|
+
level = (
|
|
755
|
+
logging.DEBUG if self.manager.config.updates.silent_on_failure else logging.WARNING
|
|
756
|
+
)
|
|
757
|
+
log.log(level, "background update check failed: %s: %s",
|
|
758
|
+
type(result.error).__name__, result.error) # fmt: skip
|
|
759
|
+
else:
|
|
760
|
+
log.debug("background update check: %s", result.status.value)
|
|
761
|
+
if self.on_result is not None:
|
|
762
|
+
try:
|
|
763
|
+
self.on_result(result)
|
|
764
|
+
except Exception as e:
|
|
765
|
+
log.debug("update on_result callback raised %s", type(e).__name__)
|
|
766
|
+
|
|
767
|
+
def run_once(self) -> UpdateResult:
|
|
768
|
+
result = self.manager.check_quietly()
|
|
769
|
+
if result.available and self.stage:
|
|
770
|
+
try:
|
|
771
|
+
result = self.manager.download_and_stage(result)
|
|
772
|
+
except UpdateError as e:
|
|
773
|
+
result = UpdateResult(UpdateStatus.ERROR, result.current_version, error=e)
|
|
774
|
+
except Exception as e:
|
|
775
|
+
err = UpdateError(f"unexpected {type(e).__name__} while staging")
|
|
776
|
+
result = UpdateResult(UpdateStatus.ERROR, result.current_version, error=err)
|
|
777
|
+
self.checks += 1
|
|
778
|
+
self._report(result)
|
|
779
|
+
return result
|
|
780
|
+
|
|
781
|
+
def _run(self) -> None:
|
|
782
|
+
if not self._wait(self.initial_delay):
|
|
783
|
+
return
|
|
784
|
+
while True:
|
|
785
|
+
self.run_once()
|
|
786
|
+
if self.interval <= 0 or not self._wait(self.interval):
|
|
787
|
+
return
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
def start_background_checks(
|
|
791
|
+
app: Any = None, manager: UpdateManager | None = None, **kw: Any
|
|
792
|
+
) -> BackgroundChecker | None:
|
|
793
|
+
"""Start periodic update checks for ``app`` (``ui.Application`` or core
|
|
794
|
+
``Application``); returns None if updates are disabled or no checks are
|
|
795
|
+
configured. Never blocks the app's event loop and never raises for update
|
|
796
|
+
failures (a missing/invalid ``app.toml`` is logged at debug level)."""
|
|
797
|
+
if manager is None:
|
|
798
|
+
try:
|
|
799
|
+
manager = UpdateManager.from_environment()
|
|
800
|
+
except UpdateError as e:
|
|
801
|
+
log.debug("background update checks not started: %s", type(e).__name__)
|
|
802
|
+
return None
|
|
803
|
+
u = manager.config.updates
|
|
804
|
+
if not u.enabled or (u.check_interval_hours <= 0 and not u.check_on_startup):
|
|
805
|
+
return None
|
|
806
|
+
if u.check_interval_hours <= 0:
|
|
807
|
+
kw.setdefault("interval", 0)
|
|
808
|
+
return BackgroundChecker(manager, app, **kw).start()
|