|
| 1 | +import InstallPip from './content/_install-pip.mdx'; |
| 2 | +import InstallVpk from './content/_install-vpk.mdx'; |
| 3 | +import BuildRelease from './content/_build-release.mdx'; |
| 4 | +import Completion from './content/_completion.mdx'; |
| 5 | +import Admonition from '@theme/Admonition'; |
| 6 | + |
| 7 | + |
| 8 | +# Getting Started: Python |
| 9 | +<AppliesTo all /> |
| 10 | +Get started with our python library. |
| 11 | + |
| 12 | + |
| 13 | +<InstallPip step={1}/> |
| 14 | + |
| 15 | +<FancyStep step={2}> |
| 16 | + <details> |
| 17 | + <summary> |
| 18 | + <strong>Configure Velopack at the beginning of your entry point</strong> |
| 19 | + </summary> |
| 20 | + |
| 21 | + Add the following code to your entry point (eg. `main.py`) as early as possible (before any electron startup code etc.): |
| 22 | + ```python |
| 23 | + import velopack |
| 24 | + |
| 25 | + if __name__ == "__main__": |
| 26 | + # Velopack builder needs to be the first thing to run in the main process. |
| 27 | + # In some cases, it might quit/restart the process to perform tasks. |
| 28 | + velopack.App().run() |
| 29 | + |
| 30 | + # ... your other app startup code here |
| 31 | + ``` |
| 32 | +
|
| 33 | + </details> |
| 34 | +</FancyStep> |
| 35 | +
|
| 36 | +<FancyStep step={3}> |
| 37 | + <details> |
| 38 | + <summary> |
| 39 | + <strong>Add update check within your app</strong> |
| 40 | + </summary> |
| 41 | +
|
| 42 | + Velopack provides a simple way to check for updates and apply them. |
| 43 | + The following shows how to implement a basic update check within your application. |
| 44 | + |
| 45 | + You can also split up the various methods to allow your users to control when to check for updates, download them, or apply them. |
| 46 | +
|
| 47 | + ```python |
| 48 | + def update_app(): |
| 49 | + manager = velopack.UpdateManager("https://the.place/you-host/updates") |
| 50 | +
|
| 51 | + update_info = manager.check_for_updates() |
| 52 | + if not update_info: |
| 53 | + return # no updates available |
| 54 | +
|
| 55 | + # Download the updates, optionally providing progress callbacks |
| 56 | + manager.download_updates(update_info) |
| 57 | +
|
| 58 | + # Apply the update and restart the app |
| 59 | + manager.apply_updates_and_restart(update_info) |
| 60 | + ``` |
| 61 | + |
| 62 | + </details> |
| 63 | +</FancyStep> |
| 64 | + |
| 65 | +<FancyStep step={4}> |
| 66 | + <details> |
| 67 | + <summary> |
| 68 | + <strong>Build your app</strong> |
| 69 | + </summary> |
| 70 | + |
| 71 | + Compile your app to a binary (eg. `.exe` on Windows). Example using PyInstaller: |
| 72 | + ```sh |
| 73 | + pyinstaller --onedir app.py |
| 74 | + ``` |
| 75 | + </details> |
| 76 | +</FancyStep> |
| 77 | + |
| 78 | +<InstallVpk step={5}/> |
| 79 | + |
| 80 | +<BuildRelease step={6}/> |
| 81 | + |
| 82 | +<Completion /> |
0 commit comments