PyUpdater Documentation

repository·main·Indexed 19 days ago

https://github.com/digital-sapphire/pyupdater

An auto-update framework for PyInstaller-packaged applications that enables secure and efficient distribution of app updates. It provides a client-side API for checking and applying updates via AppUpdate and LibUpdate, a command-line tool for building, signing, and uploading packages, and a plugin system for extending upload capabilities.

Tokens
11.7K
Snippets
56
Records
78
Agent score
66%

What's inside PyUpdater

  1. Key features of PyUpdater

    main

    PyUpdater provides several features for managing application lifecycles and security:

    • Security: Secured with EdDSA, supports cryptographically secure offline updates, and utilizes a dual key verification system.
    • Update Management: Supports release channels, automatic patch updates, and intelligent update workflows.
    • Performance: Features asynchronous downloads and download progress callbacks.
    • Extensibility: Uploading to the cloud is handled via plugins (e.g., S3 and SCP plugins are available).
    • Asset Management: Supports versioned external assets.
    • Infrastructure: Easy setup and CI/CD support, including Basic Auth support.
  2. Manage plugin configuration settings

    main

    Plugin authors can manage configuration in two primary ways:

    1. Interactive User Input: Use the set_config(self, config) method to prompt the user for information using self.get_answer(). This information is then saved to the configuration on disk. Use init_config(self, config) to map those saved configuration values to instance attributes after initialization.
    2. Environment Variables: Configuration can also be retrieved via environment variables.
  3. Understand the PyUpdater local repository layout

    main

    PyUpdater uses a specific directory structure to manage application updates, build artifacts, and configuration. The layout is divided into two main areas: the project root (containing application code and data) and the .pyupdater directory (containing configuration and build metadata).

    Project Root Layout

    • client_config.py: A configuration file automatically generated by PyUpdater for use by the client application.
    • pyu-data/:
      • new/: Place newly compiled programs here when they are ready to be signed.
      • deploy/: Contains signed updates, version metadata, and public keys staged for upload to a server.
      • files/: Stores the most recent update of each app/library. PyUpdater uses these files as a base to create patches during subsequent builds.

    .pyupdater Directory Layout

    • .pyupdater/:
      • config.pyu: Stores the configuration information for the specific application.
      • spec/: Contains PyInstaller .spec files for different platforms (e.g., mac.spec, win.spec, nix.spec, nix64.spec).
      • work/: Contains build artifacts generated by PyInstaller during the build process (e.g., .toc, .pkg, .pyz files).
    .
    ├── SuperApp.py
    ├── client_config.py
    ├── pyu-data
    │   ├── deploy
    │   ├── files
    │   └── new
    └── requirements.txt
    
    .pyupdater
    ├── config.pyu
    ├── spec
    │   └── mac.spec
    └── work
        └── mac
            ├── out00-Analysis.toc
            └── ...
  4. How PyUpdater finds upload plugins

    main

    PyUpdater discovers upload plugins using setuptools entry points. To make your plugin available to PyUpdater, you must register it under the pyupdater.plugins entry point in your package's setup.py file.

    setup(
        provides=['pyupdater.plugins',],
        entry_points={
            'pyupdater.plugins': [
                'my_uploader = my_uploader:MyUploader',
                ]
            },
        )
  5. How dual key verification works in PyUpdater

    main

    PyUpdater uses a dual key verification mechanism to ensure secure updates:

    1. An offline private key is used to sign an application-specific key pair.
    2. The application-specific key pair is then used to sign and verify update metadata.
    3. The client is shipped with the offline public key to bootstrap the entire verification process.
  6. Compare Esky and PyUpdater configuration and update mechanisms

    main

    When migrating from Esky to PyUpdater, note the following architectural differences in how configuration, versioning, and updates are handled:

    FeatureEskyPyUpdater
    ConfigurationUses setup.pySet during repository initialization
    Current App VersionParses local repositorySet within the application script
    Update VersioningParses update repositoryUses a dedicated version file including hashes for security and integrity
    Update ProcessInitialize Esky client, then call update()Initialize PyUpdater client, then call update()
  7. Build your application

    main

    You can build your application using either a PyInstaller spec file or a direct Python script. You must provide the --app-version flag.

    To view PyInstaller build information, use the --pyinstaller-log-info flag.

    # Build from a spec file
    $ pyupdater build --app-version=1.0.0 main.spec
    
    # Build from a script
    $ pyupdater build --app-version=1.0.0 main.py