# php-version-compare
[![Test](https://github.com/marcfrederick/php-version-compare/actions/workflows/test.yml/badge.svg)](https://github.com/marcfrederick/php-version-compare/actions/workflows/test.yml)
[![PyPI version](https://badge.fury.io/py/php-version-compare.svg)](https://badge.fury.io/py/php-version-compare)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/php-version-compare)](https://pypi.org/project/php-version-compare/)
[![PyPI - License](https://img.shields.io/pypi/l/php-version-compare)](https://pypi.org/project/php-version-compare/)
> ℹ️ **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](https://www.php.net/manual/en/function.version-compare.php) 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:
```bash
pip install php-version-compare
```
## Usage
### Documentation
The complete documentation can be found on
[Read the Docs](https://php-version-compare.readthedocs.io/).
### Basic Usage
```python
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:
```bash
tox
```
If you only want to run the tests for a specific Python version, you can specify the version:
```bash
tox -e py39
```
## License
This project is licensed under either of the following, at your option:
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0))
- MIT License ([LICENSE-MIT](LICENSE-MIT) or
[https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT))
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](https://semver.org/). For the versions available, see
the [tags on this repository](https://github.com/marcfrederick/php-version-compare/tags) or the
[releases page](https://github.com/marcfrederick/php-version-compare/releases).
Raw data
{
"_id": null,
"home_page": null,
"name": "php-version-compare",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "compare, comparison, compatibility, php, version",
"author": null,
"author_email": "Marc Tr\u00f6litzsch <marc.troelitzsch@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/fa/ca/b4dc6d03464556f9e0e37bfddf89f62fc8fc7e7f920d89b332820b5dfeaa/php_version_compare-1.1.2.tar.gz",
"platform": null,
"description": "# php-version-compare\n\n[![Test](https://github.com/marcfrederick/php-version-compare/actions/workflows/test.yml/badge.svg)](https://github.com/marcfrederick/php-version-compare/actions/workflows/test.yml)\n[![PyPI version](https://badge.fury.io/py/php-version-compare.svg)](https://badge.fury.io/py/php-version-compare)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/php-version-compare)](https://pypi.org/project/php-version-compare/)\n[![PyPI - License](https://img.shields.io/pypi/l/php-version-compare)](https://pypi.org/project/php-version-compare/)\n\n> \u2139\ufe0f **Note**: This project is feature-complete and will only receive updates for bug fixes or compatibility with new\n> Python versions. No new features are planned. If you require additional features, please consider forking the project.\n\nA simple Python library for comparing version strings in a manner compatible with PHP's\n[version_compare](https://www.php.net/manual/en/function.version-compare.php) function.\nAlthough this implementation is not derived from PHP's code, it passes the same tests to ensure compatibility.\n\n## Installation\n\nTo install `php-version-compare`, use pip:\n\n```bash\npip install php-version-compare\n```\n\n## Usage\n\n### Documentation\n\nThe complete documentation can be found on\n[Read the Docs](https://php-version-compare.readthedocs.io/).\n\n### Basic Usage\n\n```python\nfrom php_version_compare import version_compare\n\n# Without operator\nprint(version_compare('1.0', '1.1')) # Output: -1\nprint(version_compare('1.1', '1.0')) # Output: 1\nprint(version_compare('1.0', '1.0')) # Output: 0\n\n# With operator\nprint(version_compare('1.1', '1.0.0', operator='>=')) # Output: True\nprint(version_compare('1.0.0', '1.1', operator='<=')) # Output: True\nprint(version_compare('1.0', '1.0', operator='!=')) # Output: False\n```\n\n## Contributing\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature-branch`).\n3. Make your changes.\n4. Commit your changes (`git commit -m 'Add new feature'`).\n5. Push to the branch (`git push origin feature-branch`).\n6. Open a pull request.\n\n### Running Tests\n\nTo run tests, make sure you have `tox` installed and run the following command, which will run the tests for all\nsupported Python versions that are installed on your system:\n\n```bash\ntox\n```\n\nIf you only want to run the tests for a specific Python version, you can specify the version:\n\n```bash\ntox -e py39\n```\n\n## License\n\nThis project is licensed under either of the following, at your option:\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0))\n- MIT License ([LICENSE-MIT](LICENSE-MIT) or\n [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT))\n\nWhich license to use is up to you. This project is dual-licensed for compatibility with both.\nWhen contributing, you agree to license your contributions under the same terms.\n\n## Versioning\n\nThis project uses [Semantic Versioning](https://semver.org/). For the versions available, see\nthe [tags on this repository](https://github.com/marcfrederick/php-version-compare/tags) or the\n[releases page](https://github.com/marcfrederick/php-version-compare/releases).\n",
"bugtrack_url": null,
"license": null,
"summary": "PHP-compatible version comparison for Python",
"version": "1.1.2",
"project_urls": {
"Changelog": "https://github.com/marcfrederick/php-version-compare/releases",
"Documentation": "https://php-version-compare.readthedocs.io",
"Issues": "https://github.com/marcfrederick/php-version-compare/issues",
"Repository": "https://github.com/marcfrederick/php-version-compare"
},
"split_keywords": [
"compare",
" comparison",
" compatibility",
" php",
" version"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a1ec7755a334f39f55cd6385a3bc0b279a529c4df356f12da5a60caadcf1d533",
"md5": "3812d0a9b62f2be2a9d5c17b60aba120",
"sha256": "60e3a07f72b6b34e8ea15a5f9d3be171af9a3985901d76186392cdfe9fb1c3c4"
},
"downloads": -1,
"filename": "php_version_compare-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3812d0a9b62f2be2a9d5c17b60aba120",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 9472,
"upload_time": "2024-10-24T12:35:45",
"upload_time_iso_8601": "2024-10-24T12:35:45.247939Z",
"url": "https://files.pythonhosted.org/packages/a1/ec/7755a334f39f55cd6385a3bc0b279a529c4df356f12da5a60caadcf1d533/php_version_compare-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "facab4dc6d03464556f9e0e37bfddf89f62fc8fc7e7f920d89b332820b5dfeaa",
"md5": "6f904b7ed9bf08d92fc2d55d1655b8ee",
"sha256": "ad47ba2f1d1f2329317f3b5ec6d69dc22307225cf2a297a90a55dd8856733d2c"
},
"downloads": -1,
"filename": "php_version_compare-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "6f904b7ed9bf08d92fc2d55d1655b8ee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 11014,
"upload_time": "2024-10-24T12:35:46",
"upload_time_iso_8601": "2024-10-24T12:35:46.432591Z",
"url": "https://files.pythonhosted.org/packages/fa/ca/b4dc6d03464556f9e0e37bfddf89f62fc8fc7e7f920d89b332820b5dfeaa/php_version_compare-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-24 12:35:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "marcfrederick",
"github_project": "php-version-compare",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "php-version-compare"
}