Skip to main content

Get version of any tools

Project description

Versionix logo Latest PyPI version Supported Python versions CI status Coverage Codacy grade License

Versionix is a lightweight Python tool that retrieves and displays the version of any standalone software — handling the many different version output formats found in the wild.

Source:

github.com/sequana/versionix

Issues:

github.com/sequana/versionix/issues

Changelog:

See the Changelog section below


Overview

Many standalone tools expose their version in different ways:

  • Some require --version, some -v, and some no argument at all.

  • Some write to stdout, others to stderr.

  • Version strings come in many formats (1.2.3, v1.2.3, tool 1.2.3 (build ...), …).

Versionix handles all of these cases automatically. For ~80 % of tools the built-in regular-expression heuristic is enough; for the rest a curated registry of metadata ensures the right command is run and the right output channel is parsed.

Key features

  • 🔍 Auto-detection — works out-of-the-box for the vast majority of tools

  • 📋 Registry — curated metadata for tools with non-standard version output

  • 🐍 Pure Python — no compiled dependencies; works on any platform

  • Fast — single subprocess call, minimal overhead

  • 🔗 Library API — importable get_version() function for use in your own code

  • 📦 Container support — introspect versions from local Singularity/Apptainer image files

Installation

Install from PyPI with pip:

pip install versionix --upgrade

No extra dependencies are required beyond the Python standard library and a handful of small pure-Python packages.

Usage

Command line

Just type versionix followed by the name of any executable on your $PATH:

versionix ls          # any system command
versionix fastqc      # common bioinformatics tool
versionix bwa

versionix prints a clean X.Y.Z version string to the terminal.

List all registered tools:

versionix --registered

Full help:

versionix --help
versionix --help output

Container introspection

You can retrieve the version of a tool that is packaged inside a local Singularity/Apptainer image file (.img or .sif) using the --from option:

versionix sniffles --from sniffles_2.7.3.img
versionix fastqc --from fastqc.sif

If apptainer is available it is preferred over singularity; both are tried automatically.

Python API

You can also call get_version directly from Python:

from versionix import get_version

version = get_version("fastqc")
print(version)  # e.g. "0.11.9"

Pass a container argument to introspect a tool inside a local image file:

from versionix import get_version

version = get_version("sniffles", container="sniffles_2.7.3.img")

How it works

The first difficulty is that standalone applications have different ways to obtain their version information. Some require the use of a long or short argument (--version or -v), while others do not require any argument at all. In addition, the display channel (stdout or stderr) and the format of the version output differ between applications.

To handle these various cases, Versionix uses a regular expression that covers the majority of applications. For non-standard cases, a dictionary of metadata for each registered standalone is available. These metadata specify:

  • the command and options to run,

  • whether to read stdout or stderr, and

  • how to parse the output to extract the version string.

Versionix is designed to be used with all Sequana pipelines and is not intended to be universal. You can add support for your own tool by editing versionix/registry.py and opening a Pull Request.

Contributing

Contributions are very welcome! Please:

  1. Fork the repository and create a feature branch.

  2. Add or update tests as appropriate.

  3. Open a Pull Request against main.

Run the test suite locally with:

pytest -v --cov versionix

Changelog

Version

Description

0.99.5

run subprocess with a time limit. add bwa and ktImport* in registry

0.99.4

allow introspection of apptainers, cleanup, more tests

0.99.3

Maintenance release

0.99.2

Handle cases where e.g. –version is returned to the stderr (instead of stdout)

0.99.1

Remove warning if we are using registered entry.

0.99.0

Final version before 1.0.0

0.3.0

Refactor to use regular expression and registry only if needed. This makes versionix quite generic.

0.2.4

More tools in the registry and added precommit

0.2.3

More tools in the registry

0.2.2

add all tools required by sequana pipelines (oct 2023)

0.2.1

More tools added.

0.2

simplification. Add tests. Add more tools

0.1

first draft

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

versionix-0.99.5.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

versionix-0.99.5-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file versionix-0.99.5.tar.gz.

File metadata

  • Download URL: versionix-0.99.5.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.14 Linux/6.14.5-100.fc40.x86_64

File hashes

Hashes for versionix-0.99.5.tar.gz
Algorithm Hash digest
SHA256 14413939afd1ce19c903ab16ad581144d4a0ab75aaad16100b47cb4e709d9361
MD5 16e2a8b1aaa771cf9bb3e42fc9505e07
BLAKE2b-256 be9b89ecea928d4d128a7e4534fbf21408e362d9bb9934bcff6664799cce18ae

See more details on using hashes here.

File details

Details for the file versionix-0.99.5-py3-none-any.whl.

File metadata

  • Download URL: versionix-0.99.5-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.14 Linux/6.14.5-100.fc40.x86_64

File hashes

Hashes for versionix-0.99.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ae71129e41ff996bee1e9532f4549e31238e3d173103bd8754b01315448a37a6
MD5 db6fb9926b225580cb27738ef07e30b0
BLAKE2b-256 9b5e9690aa30dd65f727c73543ad8c20d2a8c05803126135ccc6ad5e9a3734cf

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