allenai / python-package-template

A template repo for Python packages
Apache License 2.0
395 stars 67 forks source link

Allow accessing version variables after initialization #58

Closed TheRealKeto closed 2 years ago

TheRealKeto commented 2 years ago

This PR correctly "exports" version variables after package initialization. What this means is that, rather than importing my_package/version.py, you can just import my_package as a whole (though technically, the old behavior is still there)

# Before
>>> from my_package.version import VERSION
>>> VERSION
'0.1.0'

# After
>>> import my_package
>>> my_package.VERSION
'0.1.0'
TheRealKeto commented 2 years ago

Hey @TheRealKeto, I'm a little confused about what the point of this is. I can see importing VERSION into the main __init__.py being useful, but why change the name of VERSION to RELEASE and VERSION_SHORT to VERSION?

That was mostly after seeing that the Sphinx configuration refers to VERSION_SHORT as VERSION and VERSION as RELEASE; I think this makes more sense, but the change can be reverted.

epwalsh commented 2 years ago

Gotcha, thanks for clarifying. Personally I think VERSION and VERSION_SHORT are more clear, so I'd to keep it that way.

TheRealKeto commented 2 years ago

The latest commit reverts the renaming of version variables :)