{
 "kind": "tool",
 "slug": "packaging",
 "path": "tools/packaging/",
 "name": "packaging",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Build tools and bundlers",
   "tools/build-tools/"
  ]
 ],
 "lead": "Compare and check Python version numbers correctly.",
 "chips": [
  {
   "label": "Build tools and bundlers",
   "path": "tools/build-tools/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install packaging"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/pypa/packaging"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "Apache-2.0 OR BSD-2-Clause",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "license = \"Apache-2.0 OR BSD-2-Clause\"",
   "note": "Use it under either Apache-2.0 or BSD-2-Clause; both allow commercial and closed-source use.",
   "src": "https://github.com/pypa/packaging/blob/main/pyproject.toml"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 23, 2026",
   "note": "Latest GitHub release Nov 23, 2026. ",
   "src": "https://github.com/pypa/packaging"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "90 projects",
   "status": "info",
   "sub": "#11 of 185 in its category",
   "note": "Dependency in 90 public GitHub projects set up for AI coding agents that we scanned (1.4%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Community skills",
   "status": "info",
   "sub": "1 skills by others",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What packaging does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Tell users an update is out",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Check a version fits a range",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Read a requirements line",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Only for some systems or Pythons",
       "text": "Decide whether a package is needed on this computer, for example only on Windows or only before Python 3.11.",
       "idea": false
      },
      {
       "title": "Match package names reliably",
       "text": "Treat \"Django_REST.framework\" and \"django-rest-framework\" as the same package when you look names up or compare lists.",
       "idea": false
      },
      {
       "title": "Clean up license names",
       "text": "A report on the packages in a project shows license names in one standard spelling, like \"MIT OR Apache-2.0\".",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "packaging popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "68",
       "of": "/ 100",
       "l": "Gid Score, #513 overall"
      },
      {
       "n": "457M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "761",
       "l": "GitHub stars"
      },
      {
       "n": "90",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How packaging is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "55 projects, 1.7%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "42 projects, 1.4%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "29 projects, 1.2%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "11 projects, 3.3%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "7 projects, 1.5%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "5 projects, 1.1%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 71.1% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 63.3% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 63.3% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      },
      {
       "l": "In 62.2% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 58.9% of its projects",
       "v": "Click",
       "path": "tools/click-py/"
      },
      {
       "l": "In 58.9% of its projects",
       "v": "NumPy",
       "path": "tools/numpy/"
      },
      {
       "l": "In 56.7% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about packaging",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Agent Skills for it",
       "path": "skills/",
       "items": [
        "packaging-youtube-thumbnails: Create, render, revise, and learn from evidence-backed title-thumbnail packages. Channel profiles, package scoring, visual QA."
       ]
      },
      {
       "title": "More in Build tools and bundlers",
       "path": "tools/build-tools/",
       "items": [
        {
         "text": "Vite",
         "path": "tools/vite/"
        },
        {
         "text": "Turborepo",
         "path": "tools/turbo/"
        },
        {
         "text": "esbuild",
         "path": "tools/esbuild/"
        },
        {
         "text": "Babel (JavaScript)",
         "path": "tools/babel-npm/"
        },
        {
         "text": "Laravel Vite Plugin",
         "path": "tools/laravel-vite-plugin/"
        },
        {
         "text": "React Compiler Babel Plugin",
         "path": "tools/babel-plugin-react-compiler/"
        },
        {
         "text": "Nx",
         "path": "tools/nx/"
        },
        {
         "text": "vite-tsconfig-paths",
         "path": "tools/vite-tsconfig-paths/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "packaging",
       "me": true,
       "facts": [
        "Apache-2.0 OR BSD-2-Clause",
        "Gid 68",
        "457M/wk"
       ]
      },
      {
       "name": "semantic-version",
       "why": "Pick semantic-version when your version strings follow strict SemVer (major.minor.patch) rather than Python's own version rules.",
       "path": "tools/semantic-version/",
       "facts": []
      },
      {
       "name": "semver (JavaScript)",
       "why": "Pick semver when the versions belong to JavaScript packages and your code runs in Node.js.",
       "path": "tools/semver-npm/",
       "facts": []
      },
      {
       "name": "setuptools",
       "why": "Pick setuptools when you need to build and publish your own Python package, not just read version numbers.",
       "path": "tools/setuptools/",
       "facts": []
      }
     ],
     "more": "Compare packaging with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install packaging into your project's Python environment.",
       "code": "pip install packaging",
       "src": "https://packaging.pypa.io/en/stable/"
      },
      {
       "text": "Parse two versions and compare them.",
       "code": ">>> from packaging.version import Version, parse\n>>> v1 = parse(\"1.0a5\")\n>>> v2 = Version(\"1.0\")\n>>> v1 < v2\nTrue\n",
       "src": "https://packaging.pypa.io/en/stable/version.html"
      },
      {
       "text": "Check versions against a set of rules with SpecifierSet.",
       "code": ">>> from packaging.specifiers import SpecifierSet\n>>> spec1 = SpecifierSet(\"~=1.0\")\n",
       "src": "https://packaging.pypa.io/en/stable/specifiers.html"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "sorted(versions) or max(versions) on plain strings, or comparing \"1.10\" > \"1.9\" as text",
       "fix": "sorted(versions, key=Version) and Version(a) > Version(b)",
       "why": "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']."
      },
      {
       "dont": "\"2.0.0b1\" in SpecifierSet(\">=1.9\") to keep test releases out",
       "fix": "SpecifierSet(\">=1.9\", prereleases=False), or spec.contains(v, prereleases=False)",
       "why": "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."
      },
      {
       "dont": "Relying on spec.contains(\"banana\") to raise for a bad version string",
       "fix": "Parse with Version() first and catch InvalidVersion",
       "why": "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."
      },
      {
       "dont": "packaging.version.LegacyVersion or parse(\"latest\") expecting a loose version object",
       "fix": "Version(s) inside try/except InvalidVersion",
       "why": "LegacyVersion was removed in 22.0; parse() now only accepts PEP 440 versions."
      },
      {
       "dont": "Comparing package names as typed (\"Django_REST.framework\" vs \"django-rest-framework\")",
       "fix": "Compare canonicalize_name(a) == canonicalize_name(b)",
       "why": "Package names differ in case, dots and underscores but mean the same package."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Why not just compare version strings?",
       "a": "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.",
       "evidence": {
        "url": "https://packaging.pypa.io/en/stable/version.html",
        "quote": "A Version instance is comparison aware and can be compared and sorted using the standard Python interfaces."
       }
      },
      {
       "q": "What happens with a version like \"latest\" or \"french toast\"?",
       "a": "Version() raises InvalidVersion; catch it in your code.",
       "evidence": {
        "url": "https://packaging.pypa.io/en/stable/version.html",
        "quote": "Raised when a version string is not a valid version."
       }
      },
      {
       "q": "Can I use it in a paid app?",
       "a": "Yes. It is under Apache-2.0 or BSD-2-Clause, at your choice.",
       "evidence": {
        "url": "https://github.com/pypa/packaging/blob/main/pyproject.toml",
        "quote": "license = \"Apache-2.0 OR BSD-2-Clause\""
       }
      },
      {
       "q": "Can it tell which wheel file fits this computer?",
       "a": "Yes, the tags module parses wheel tags and lists the ones the running Python supports.",
       "evidence": {
        "url": "https://packaging.pypa.io/en/stable/tags.html",
        "quote": "This module provides support for both parsing these tags as well as discovering what tags the running Python interpreter supports."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi packaging"
  ],
  [
   "Category",
   "Build tools and bundlers"
  ],
  [
   "License",
   "Apache-2.0 OR BSD-2-Clause"
  ],
  [
   "Gid Score",
   "67.5"
  ],
  [
   "Rank in category",
   "#11 of 185"
  ],
  [
   "GitHub",
   "pypa/packaging"
  ],
  [
   "Last change",
   "Nov 23, 2026"
  ]
 ],
 "good": [
  "It reads and compares version numbers and version rules; it does not install, download or update anything.",
  "Its own version numbers follow the calendar (26.3 is a 2026 release), so a jump in the first number is not a sign of a big rewrite.",
  "Version 26.3 came out on 2026-08-03 and needs Python 3.9 or newer."
 ],
 "checked_line": "Read by AgentGid from 15 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/pypa.png"
}