python-semver

Parse, compare, and bump semantic version strings in Python

Library
PyPI
v3.0.4
521stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
61/100Good
Development Activity60
Maintenance36
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture72
Code Quality76
Innovation62
Learning Curve82

python-semver is a small, focused library for working with Semantic Versioning (semver.org) strings in Python. Its Version class parses a MAJOR.MINOR.PATCH[-prerelease][+build] string into its component parts, compares versions correctly, and provides chainable bump_major/bump_minor/bump_patch methods that return new, immutable Version instances.

Beyond the Python API, the package installs a pysemver command-line tool for parsing, comparing, and bumping versions from shell scripts and CI pipelines, making it useful both as an importable library and as a standalone release-automation utility.

What You Get

  • An immutable Version class with parse, compare, and rich comparison operator support
  • Chainable bump_major/bump_minor/bump_patch/bump_prerelease/bump_build methods
  • A pysemver CLI for parsing, comparing, and bumping versions from shell scripts and CI
  • Prerelease and build-metadata handling per the semver.org spec
  • Backwards-compatible module-level functions for codebases migrating from the legacy tuple-based API

Common Use Cases

  • Validating and comparing version strings in package managers or release tooling
  • Bumping version numbers programmatically as part of a CI/CD release pipeline
  • Sorting a list of releases correctly, including prerelease and build metadata ordering
  • Enforcing semantic-versioning compliance in custom build or publishing scripts

Under The Hood

Architecture The library centers on a single immutable Version class in src/semver/version.py (762 lines) that owns parsing, comparison, and bump logic; _deprecated.py isolates the legacy pre-2.10 tuple/dict-based function API so old call sites keep working without polluting the modern class-based surface, and cli.py wraps Version to expose pysemver as a thin command-line front end. Tech Stack Pure Python with setuptools as the only build dependency (PEP 517 via pyproject.toml), supporting Python 3.10+, with uv.lock present for reproducible dev-dependency resolution and Sphinx-based docs under docs/. Code Quality The tests/ directory splits coverage by concern (test_bump.py, test_compare.py, test_format.py, test_immutable.py, test_deprecated_functions.py, test_docstrings.py), including a dedicated docstring-doctest check, indicating deliberate attention to both behavior and documentation accuracy. API Design The Version class favors immutability and method chaining (Version.parse(...).bump_minor().bump_patch()), mirrors Python’s native comparison operators for intuitive sorting, and keeps the deprecated function-based API available under _deprecated.py so migrations from older versions don’t break silently.

Used by 6 apps in this directory

Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
83%
Other

Bugsink

Developer Tools · Monitoring

2,018

Self-hosted error tracking that accepts Sentry SDKs out of the box, so you keep your instrumentation and drop the monthly bill.

View details
84
Repo Health
80
Technical
76
Dependency
Built with
Python83%
HTML15%
Updated 1 weeks ago
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,367

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
69
Repo Health
78
Technical
66
Dependency
Built with
TypeScript71%
Go16%
Updated yesterday
C++
66%
Other

Memgraph

Databases · AI Development

4,347

High-performance in-memory graph database for AI context and real-time analytics

View details
90
Repo Health
79
Technical
70
Dependency
Built with
C++66%
Python18%
Updated today
Go
56%
Apache 2.0

OSV.dev

Security

2,888

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
90
Repo Health
82
Technical
70
Dependency
Built with
Go56%
Python32%
Updated today
Python
45%
Other

Redash

Analytics · Data Engineering

28,754

Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.

View details
85
Repo Health
74
Technical
61
Dependency
Built with
Python45%
JavaScript31%
TypeScript17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search