{"id":3177,"library":"node-semver","title":"node-semver (Python)","description":"A Python port of the popular `node-semver` library, which provides semantic versioning utilities as used by npm. The library helps in parsing, comparing, and ranging semantic versions (MAJOR.MINOR.PATCH) according to the SemVer 2.0.0 specification. The current stable version is 0.9.0, released on February 23, 2023. This library is maintained on an as-needed basis.","status":"maintenance","version":"0.9.0","language":"en","source_language":"en","source_url":"https://github.com/podhmo/python-node-semver","tags":["semantic versioning","semver","npm","node-semver","versioning"],"install":[{"cmd":"pip install node-semver","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The module was renamed from `semver` to `nodesemver` in version 0.9.0 to avoid conflicts with `python-semver` and other libraries. Using `from semver import ...` will likely result in an `ImportError` or unexpected behavior if `python-semver` is also installed.","wrong":"from semver import max_satisfying","symbol":"max_satisfying","correct":"from nodesemver import max_satisfying"}],"quickstart":{"code":"from nodesemver import max_satisfying\n\nversions = ['1.2.3', '1.2.4', '1.2.5', '1.2.6', '2.0.1']\nrange_ = '~1.2.3'\n\nsatisfying_version = max_satisfying(versions, range_, loose=False)\nprint(f\"Max satisfying version for range '{range_}' is: {satisfying_version}\")\n# Expected: Max satisfying version for range '~1.2.3' is: 1.2.6\n\nversions_with_prerelease = ['1.2.3', '1.2.4', '1.2.5', '1.2.6-pre.1', '2.0.1']\nrange_prerelease = '~1.2.3'\n\nsatisfying_with_prerelease = max_satisfying(versions_with_prerelease, range_prerelease, loose=False, include_prerelease=True)\nprint(f\"Max satisfying (incl. prerelease) for range '{range_prerelease}' is: {satisfying_with_prerelease}\")\n# Expected: Max satisfying (incl. prerelease) for range '~1.2.3' is: 1.2.6-pre.1","lang":"python","description":"This quickstart demonstrates how to find the maximum version that satisfies a given semantic version range, with options for strict or loose matching and including pre-release versions."},"warnings":[{"fix":"Update import statements to `from nodesemver import ...`.","message":"The primary import module name changed from `semver` to `nodesemver` in version 0.9.0. Code using `from semver import ...` will fail with an `ImportError`.","severity":"breaking","affected_versions":"0.9.0 and later"},{"fix":"Ensure only one semantic versioning library is actively used, and update imports to `nodesemver` for this library. Consider uninstalling `python-semver` if not explicitly needed alongside `node-semver`.","message":"This library might conflict with the `python-semver` package if both are installed and older `semver` import statements are still in use, leading to ambiguous imports.","severity":"gotcha","affected_versions":"All versions, especially 0.9.0 onwards when migrating"},{"fix":"Catch `ValueError` when parsing potentially non-strict versions or set `loose=True` if more permissive parsing is desired.","message":"When `loose=False`, parsing a version with a malformed pre-release (e.g., `2.0.0b1`) that doesn't strictly adhere to SemVer 2.0.0 rules can raise a `ValueError`, which may be unexpected if familiar with more permissive parsers.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always review release notes or `CHANGELOG.md` for any version update, especially when dealing with pre-1.0.0 releases where API stability guarantees are typically weaker.","message":"Despite a significant breaking change (module rename), the library's version number only incremented to 0.9.0, not 1.0.0, which might lead users to believe it's a minor change when it requires code modification.","severity":"gotcha","affected_versions":"0.9.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}