Skip to main content

Simple program to update package from PyPi with pip.

Project description

PyPiUpdater

UNFINISHED Still early code, functions might change drasticly

PyPiUpdater is a Python library for managing updates of packages installed via pip.

Features

  • Check the latest version of a package on PyPI
    • Determine if an update is available
  • Upgrade the package using pip
  • Restart the Python script after updating

Installation

pip install PyPiUpdater

Usage example

NOTE: Example only work for client application, GUI apps such as OptimaLab35 with QT need also to close the window and should not use the restart function.

Now the example by ChatGPT:

Here's a short example code snippet for your PyPiUpdater package to include in your README:

# Example usage of PyPiUpdater

from PyPiUpdater import PyPiUpdater

# Initialize the updater with the package name, current version, and log file path
updater = PyPiUpdater(package_name="OptimaLab35", local_version="0.7.0", log_path="update_log.txt")

# Check if an update is available (optionally forcing the check, otherwise only checked every 20 hours(default set with update_interval_seconds = int seconds))
is_newer, latest_version = updater.check_for_update(force=False)

if is_newer:
    print(f"Update available! Latest version: {latest_version}")
    # Update the package using pip
    success, message = updater.update_package()
    print(message)
    if success:
        # Restart the program after update
        updater.restart_program()
else:
    print("No update available or checked too recently.")

Explanation:

  • The example shows how to initialize the PyPiUpdater class with the package name, current version, and the path to a log file.
  • It checks for an update by calling check_for_update().
  • If an update is available, it proceeds with updating the package using update_package() and restarts the program with restart_program().
  • If no update is available, or it was checked too recently, it prints an appropriate message.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypiupdater-0.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypiupdater-0.3.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file pypiupdater-0.3.0.tar.gz.

File metadata

  • Download URL: pypiupdater-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for pypiupdater-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9f4034e5fcf22ba1a86723cddee311deb4fb2af5f862312170da6d607fbf0d76
MD5 3b25e79644ec16129b0f439a5333543c
BLAKE2b-256 91d29c79948710f02fc94e1b1678a997f335b0a000bf017b25d6208179cf7e7f

See more details on using hashes here.

File details

Details for the file pypiupdater-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pypiupdater-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for pypiupdater-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fd01071efee31e194a79615897ffc917d8b24319f73ed7adc789f4e8def41b4
MD5 7221decffb2881ce0cdcdf47ebc97560
BLAKE2b-256 973c29dffde529dbd25e0c19f76da37f9dc2cd439129e520dd7802e14c256ceb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page