Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Version Compare To PyPI #4798

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions cve_bin_tool/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: GPL-3.0-or-later

# THIS IS A SETUP FILE FOR THE VERSION COMPARE MODULE

import pathlib

from setuptools import find_packages, setup

PACKAGE_ROOT_PATH = pathlib.Path(__file__).parent.resolve()

with open(PACKAGE_ROOT_PATH / "version_compare" / "README.md", encoding="utf-8") as f:
readme = f.read()

setup(
name="version_compare",
version="0.1.0",
description="Version checker module for CVE Binary Checker Tool",
long_description=readme,
long_description_content_type="text/markdown",
author="Terri Oda",
author_email="[email protected]",
maintainer="Terri Oda",
maintainer_email="[email protected]",
url="https://github.com/intel/cve-bin-tool",
license="GPL-3.0-or-later",
keywords=["version", "parsers", "checker"],
python_requires=">=3.8",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
install_requires=[],
packages=find_packages(include=["version_checker", "version_checker.*"]),
)
39 changes: 39 additions & 0 deletions cve_bin_tool/version_compare/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Version Compare Package

The `version_compare.py` module, originally part of `cve-bin-tool`, is now released as a separate package on PyPI while maintaining the same existing API. You can install it via:

```sh
pip install version_compare
```

## Example Usage

### Using `version_compare` Directly
```python
from version_compare import version_compare

print(version_compare("1.2", "1.1")) # Output: 1 (1.2 > 1.1)
print(version_compare("1.2a", "1.2b")) # Output: -1 (1.2a < 1.2b)
```

### Using the `Version` Class from `version_compare`
```python
from parsers import Version

print(Version("1.2") < Version("1.3")) # Output: True
```

### Using `Version` from `cve-bin-tool`
```python
from cve_bin_tool.version_compare import Version

print(Version("1.2") < Version("1.3")) # Output: True
```

## Exceptions

- **`CannotParseVersionException`**: Raised when a version string cannot be parsed.
- **`UnknownVersion`**: Raised if the version is `null` or `unknown`.

This README serves as documentation for the `parsers` package and its usage within `cve-bin-tool`.

3 changes: 3 additions & 0 deletions cve_bin_tool/version_compare/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: GPL-3.0-or-later
from .version_compare import *
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

"""

__all__ = [
"parse_version",
"version_compare",
"Version",
"CannotParseVersionException",
"UnknownVersion",
]


class CannotParseVersionException(Exception):
"""
Expand Down
3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ The CVE Binary Tool helps you determine if your system includes known vulnerabil
triaging_process.md
new-contributor-tips.md
pypi_downloads.md
mismatch_data.md
mismatch_data.md
../version_compare/README.md

Indices and tables
==================
Expand Down
Loading