A package to make it easy for other packages to report their version.
Project description
packageversion
packageversion
is a package designed to help
other packages help their users keep tract of
what version they are using.
It was built with packages that are maintained with poetry in mind but it works in a more limited way with other approaches.
For Package Maintainers
To use packageversion
in your package, first take
a dependency on packageversion
. In Poetry, you would
do this with
poetry add usingversion
In other environments, you might add it to e.g.
requirements.txt.
Now, just
add the following to the very end of your top-level __init__.py
:
from usingversion import getattr_with_version
__getattr__ = getattr_with_version("mypackage", __file__, __name__)
Be sure to substitute the actual name of your package for
"mypackage"
.
To test, try
import mypackage
print(f"The version of mypackage is {mypackage.version}.")
For End Users
There's really nothing all that exciting to do.
If a package somepackage
that you depend on uses
packageversion
then you can check the version with
import somepackage
print(f"The version of somepackage is {somepackage.version}.")
Unless the maintainters of somepackage
have chosen
otherwise, somepackage._version
is the same as
somepackage.version
so you can use whichever you
prefer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for usingversion-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3991b129c693a4a56283c420ea4eed02eb732121a07a87009af02f0c4584a587 |
|
MD5 | bc871e52dafc6e08019b5fce46a1d4ac |
|
BLAKE2b-256 | 0a00922c6113837ab52d8dacd71bc85c01ef5ac802f53f60991c0f6f685d2d94 |