https://github.com/aahnik/verlat
Get info about the latest release of a package on PyPI.
https://github.com/aahnik/verlat
latest-version poetry pypi pypi-package python python-package python3 requests semantic semantic-versioning versioning
Last synced: 11 months ago
JSON representation
Get info about the latest release of a package on PyPI.
- Host: GitHub
- URL: https://github.com/aahnik/verlat
- Owner: aahnik
- License: mit
- Created: 2021-05-20T18:32:40.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-07T12:09:15.000Z (about 5 years ago)
- Last Synced: 2025-02-01T09:51:19.392Z (over 1 year ago)
- Topics: latest-version, poetry, pypi, pypi-package, python, python-package, python3, requests, semantic, semantic-versioning, versioning
- Language: Python
- Homepage: https://pypi.org/project/verlat
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# verlat
Get info about the latest release of a package on PyPI.
[](https://github.com/aahnik/verlat/actions/workflows/quality.yml)
[](https://github.com/aahnik/verlat/actions/workflows/test.yml)
[](https://codecov.io/gh/aahnik/verlat)

## Installation
```shell
pip install --upgrade verlat
```
## Usage
```python
from verlat import latest_release
package = "verlat" # name of the package on PyPI
release = latest_release(package)
print(release.version)
```
## Application
Many CLI apps like
[`pip`](https://pip.pypa.io/en/stable/)
or
[`gh`](https://cli.github.com/)
produce warnings if you are not using their latest release.
Using `verlat` you can fetch information about the latest release
of your package on PyPI.
You can then compare the version strings of the latest release and
the currently running program.
Based on whether it is a major or minor release, or whatever logic you have,
you can log useful information for the user.
For dealing with version strings, you may use the
[`packaging`](https://pypi.org/project/packaging/v)
library.
Here is an example code that demonstrates practical application of `verlat`.
> **NOTE** Assuming that you have build your python package using
[`poetry`](https://python-poetry.org/docs/),
and the `version` key exists under `[tool.poetry]` of your
[`pyproject.toml`](https://python-poetry.org/docs/pyproject/)
file.
```python
# __init__.py
import logging
from importlib.metadata import version
from verlat import latest_release
__version__ = version(__package__)
latest = latest_release(__package__)
def major(string):
# based on semantic versioning
return int(string.split(".", 1)[0])
if major(__version__) < major(latest.version):
logging.warning(
f"A new major release for {__package__} is availaible.\
\nDownload it from {latest.release_url}"
)
```