1. License
“license = "Apache-2.0 OR BSD-2-Clause"”
Use it under either Apache-2.0 or BSD-2-Clause; both allow commercial and closed-source use.
github.com/pypa/packaging/blob/main/pyproject.toml3. Used by agents' projects
Dependency in 90 public GitHub projects set up for AI coding agents that we scanned (1.4%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error
What packaging does
packaging is a small free Python library that reads version numbers and version rules the way Python's own install tools do. Your program can tell that 1.10 is newer than 1.9, check whether a version fits a rule like ">=2.31,<3", and read the lines of a requirements file. It works offline and installs nothing else.
What people build with it
Tell users an update is out
Your app or command-line tool compares its own version with the newest one and shows "a new version is available" only when it really is newer.
Check a version fits a range
Before a plugin or script runs, check that the installed library version is one it supports, such as at least 2.31 and below 3.
Read a requirements line
A tool that audits a project reads each line like "requests[socks]>=2.31,<3" and gets the name, the extras and the allowed versions apart.
Only for some systems or Pythons
Decide whether a package is needed on this computer, for example only on Windows or only before Python 3.11.
Match package names reliably
Treat "Django_REST.framework" and "django-rest-framework" as the same package when you look names up or compare lists.
Clean up license names
A report on the packages in a project shows license names in one standard spelling, like "MIT OR Apache-2.0".
packaging popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How packaging is used
- packaging is a dependency in 90 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (5.5% of the 1,623 Python ones), #11 of 185 in build tools and bundlers.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,457; those are left out of every share on this page.
- Projects that use it most often also use Pydantic (71.1%), Uvicorn (63.3%), PyYAML (63.3%).
By coding agent
Often used with
More about packaging
Agent Skills for it
- packaging-youtube-thumbnails: Create, render, revise, and learn from evidence-backed title-thumbnail packages. Channel profiles, package scoring, visual QA.
More in Build tools and bundlers
Alternatives
packaging This page
Pick semantic-version when your version strings follow strict SemVer (major.minor.patch) rather than Python's own version rules.
Pick semver when the versions belong to JavaScript packages and your code runs in Node.js.
Pick setuptools when you need to build and publish your own Python package, not just read version numbers.
Get started
Tell your AI assistant
“Use the Python library packaging (pin packaging==26.3, Python 3.9+) to compare version numbers with Version() and check ranges with SpecifierSet(..., prereleases=False); catch InvalidVersion for strings that are not versions.”
Install packaging into your project's Python environment.
pip install packagingParse two versions and compare them.
>>> from packaging.version import Version, parse >>> v1 = parse("1.0a5") >>> v2 = Version("1.0") >>> v1 < v2 TrueCheck versions against a set of rules with SpecifierSet.
>>> from packaging.specifiers import SpecifierSet >>> spec1 = SpecifierSet("~=1.0")
Mistakes to avoid
Text order puts 1.10.0 before 1.9.2; in our run sorted() as text gave ['1.10.0', '1.10.0rc1', '1.2', '1.9.2', '2.0.0b1'].
Since 26.0 test releases are handled per PEP 440 and the plain in check accepts them; in our run it gave True on 26.3 and False on 25.0.
Since 26.0 contains() returns False for a bad version instead of raising; in our run 25.0 raised InvalidVersion and 26.3 returned False.
LegacyVersion was removed in 22.0; parse() now only accepts PEP 440 versions.
Package names differ in case, dots and underscores but mean the same package.
Questions
Why not just compare version strings?
As text, "1.10.0" sorts before "1.9.2". Version objects compare by the version rules, so 1.10.0 comes after 1.9.2.
What happens with a version like "latest" or "french toast"?
Version() raises InvalidVersion; catch it in your code.
Can I use it in a paid app?
Yes. It is under Apache-2.0 or BSD-2-Clause, at your choice.
Can it tell which wheel file fits this computer?
Yes, the tags module parses wheel tags and lists the ones the running Python supports.