Skip to main content

Library for parsing system package strings and comparing package versions

Project description

Introduction

version_utils is under active development. It is designed to provide a pure Python convenience library capable of parsing and comparing package and version strings for a variety of packaging standards. Whenever possible, the exact logic of existing package management comparison standards will be implemented so that users can trust that the results are equivalent to what they would get on the command-line.

Using version_utils ensures that packages can be compared even on systems without access to the command line or distro-provided tools on various Linux systems, allowing for easier and more consistent unit testing, safer deployment to multiple distributions, and easier and quicker development due to a well-documented API and standardized function calls.

Current Status and Roadmap

Currently, only RPM/Yum style packages are supported, but we have plans to add dpkg/Debian in the near future. Development will probably slow from there, although Pacman/Arch and various other distributions are on the radar.

Installation

This package has no dependencies, so a simple:

pip install version_utils

should suffice. Feel free to build from source as well, if you prefer.

Basic Use

Check the API documentation to ensure the module you are seeking to use is present. The example below uses the rpm module. From your application:

from subprocess import PIPE, Popen
from version_utils import rpm

pkg_req = 1.07

# Get a package string for an installed package
out, err = Popen(['rpm', '-q', 'foo'], stdout=PIPE, stderr=PIPE).communicate()
sys_pkg = out

# Get package information
sys_pkg_info = rpm.parse_package(sys_pkg)
sys_pkg_ver = sys_pkg_info['EVR'][1]

# Compare versions
result = rpm.compare_versions(pkg_req, sys_pkg_ver)

if result < 0:  # sys_pkg was newer
    print('System package does not satisfy requirement!')

Note that parse_package['EVR'] returns a 3-tuple (epoc, version, requirement), so if you only need to compare on version, you can pull it out from the tuple.

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

version_utils-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

version_utils-0.1.0-cp34-cp34m-macosx_10_6_intel.whl (4.2 kB view details)

Uploaded CPython 3.4m macOS 10.6+ intel

File details

Details for the file version_utils-0.1.0.tar.gz.

File metadata

File hashes

Hashes for version_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e5c70fe4792113bfbd21139f731568dc85eb0c656e8f94f7e4ba660459b2eb5
MD5 150efd3b56092a0b823cb5ec19fb8c67
BLAKE2b-256 dbf35b5bedf325433a77b4e40a714f8398d0603c2643fcd872afb8544722ae6a

See more details on using hashes here.

File details

Details for the file version_utils-0.1.0-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for version_utils-0.1.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 96c7c97fd25692cb1f1b4e9c0badb7ea4002f49850dbeabab66415886d180507
MD5 fd58a51ea31cd15bbb73918d6da98a09
BLAKE2b-256 d0b9a74f242b7a484554ed2770bce72463b88da487db3a5ad4eee357046752e8

See more details on using hashes here.

Supported by

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