Skip to main content

php-version-compare

Test PyPI version PyPI - Python Version PyPI - License

ℹ️ Note: This project is feature-complete and will only receive updates for bug fixes or compatibility with new Python versions. No new features are planned. If you require additional features, please consider forking the project.

A simple Python library for comparing version strings in a manner compatible with PHP's version_compare function. Although this implementation is not derived from PHP's code, it passes the same tests to ensure compatibility.

Installation

To install php-version-compare, use pip:

pip install php-version-compare

Usage

Documentation

The complete documentation can be found on Read the Docs.

Basic Usage

from php_version_compare import version_compare

# Without operator
print(version_compare('1.0', '1.1'))  # Output: -1
print(version_compare('1.1', '1.0'))  # Output: 1
print(version_compare('1.0', '1.0'))  # Output: 0

# With operator
print(version_compare('1.1', '1.0.0', operator='>='))  # Output: True
print(version_compare('1.0.0', '1.1', operator='<='))  # Output: True
print(version_compare('1.0', '1.0', operator='!='))  # Output: False

Contributing

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add new feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a pull request.

Running Tests

To run tests, make sure you have tox installed and run the following command, which will run the tests for all supported Python versions that are installed on your system:

tox

If you only want to run the tests for a specific Python version, you can specify the version:

tox -e py39

License

This project is licensed under either of the following, at your option:

Which license to use is up to you. This project is dual-licensed for compatibility with both. When contributing, you agree to license your contributions under the same terms.

Versioning

This project uses Semantic Versioning. For the versions available, see the tags on this repository or the releases page.

Metadata

Release files for php-version-compare 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for php-version-compare 1.1.2
File Size Uploaded
php_version_compare-1.1.2.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for php-version-compare 1.1.2
File Interpreter ABI Platform
php_version_compare-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / php_version_compare-1.1.2.tar.gz

Download URL php_version_compare-1.1.2.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ad47ba2f1d1f2329317f3b5ec6d69dc22307225cf2a297a90a55dd8856733d2c
BLAKE2b-256 checksum
How to use checksums
facab4dc6d03464556f9e0e37bfddf89f62fc8fc7e7f920d89b332820b5dfeaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / php_version_compare-1.1.2-py3-none-any.whl

Download URL php_version_compare-1.1.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60e3a07f72b6b34e8ea15a5f9d3be171af9a3985901d76186392cdfe9fb1c3c4
BLAKE2b-256 checksum
How to use checksums
a1ec7755a334f39f55cd6385a3bc0b279a529c4df356f12da5a60caadcf1d533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page