https://github.com/marcfrederick/php-version-compare
PHP-compatible version comparison for Python
https://github.com/marcfrederick/php-version-compare
php python version version-check versioning
Last synced: 8 months ago
JSON representation
PHP-compatible version comparison for Python
- Host: GitHub
- URL: https://github.com/marcfrederick/php-version-compare
- Owner: marcfrederick
- License: apache-2.0
- Created: 2024-09-03T14:46:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-24T12:34:51.000Z (about 1 year ago)
- Last Synced: 2024-10-25T07:43:26.932Z (about 1 year ago)
- Topics: php, python, version, version-check, versioning
- Language: Python
- Homepage: https://pypi.org/project/php-version-compare
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# php-version-compare
[](https://github.com/marcfrederick/php-version-compare/actions/workflows/test.yml)
[](https://badge.fury.io/py/php-version-compare)
[](https://pypi.org/project/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).