Open orionlee opened 1 month ago
Yes, currently, to get the version, we need to:
import tesscentroidvetting
import importlib.metadata
print(importlib.metadata.version('tesscentroidvetting'))
The version number is only in pyproject.toml, but I think it is possible to dinamically mention 'version' in that file to avoid having two places to write the same info, what can lead to errors.
Thx, I'll manage to have the 2 ways of getting the version number.
I didn't know about importlib.metadata
.
You're right in that the way lightkurve
does it requires maintaining the version at two places.
(I think the approach used to work when the package is specified by old-school setup.py
, but broke down when it was switched to pyproject.toml
)
For now, one minor downside of importlib.metadata.version('tesscentroidvetting')
is that it does not work when I directly include the source in the path, without going through install. I'm probably the only one who does it so it's not a priority.
After struggling with several build errors when trying to use pyproject.toml with dynamic = ["version"], and the help of stackoverflow (...), I managed to have the version number only in file version.py. The new release v1.3.3 is also available in PyPi (pip install tesscentroidvetting --upgrade).
import tesscentroidvetting
import importlib.metadata
print(tesscentroidvetting.__version__) // 1.3.3
print(importlib.metadata.version('tesscentroidvetting')) // 1.3.3
It'd be useful to include the standard-ish
.__version__
so that one can tell the version being used, e.g.,Example pattern:
https://github.com/lightkurve/lightkurve/blob/71b04c3caa573d8932a2405619f77a55d363129c/src/lightkurve/__init__.py#L104
https://github.com/lightkurve/lightkurve/blob/71b04c3caa573d8932a2405619f77a55d363129c/src/lightkurve/version.py#L1-L3