python-plyfile icon indicating copy to clipboard operation
python-plyfile copied to clipboard

plyfile is missing version info

Open peendebak opened this issue 9 years ago • 4 comments

The plyfile module is missing the __version__ field. This can be added by including a line

__version__ = '0.4'

in the file plyfile.py. If the version needs to be synchronized with the setup.py the best thing is to parse the version number in setup.py from the source code.

peendebak avatar Sep 26 '16 07:09 peendebak

Thanks for the report, @peendebak, and sorry for not getting back sooner.

From what I can determine, the __version__ specification comes from the deferred PEP-396. Doing a quick and unscientific survey of other third-party Python modules that I use, it seems to be implemented by some but not all.

I'm still undecided on this. The main argument I have against it is the increased maintenance burden. I'm pretty sure there's no "correct" way to do this without introducing significant complexity and new assumptions between setup.py and plyfile.py. As for arguments in favor: I'm not really sure. Is there a compelling reason to have this feature?

Just to be clear: I'm not against having this, but the benefits have to outweigh the increase in complexity and coupling.

dranjan avatar Oct 16 '16 05:10 dranjan

Is there a compelling reason to have this feature?

Yes. I for example have submitted a pull request for a new feature, and I would like to include a check in my software that the user has a recent enough version of plyfile which integrates this feature. This would also apply to any changes in any public methods or attributes exposed.

athompson673 avatar Dec 22 '20 22:12 athompson673

@athompson673 - wouldn't the standard way to do that be with a version specifier (like plyfile>=1.0) in the setup.py script or requirements.txt file?

Anyway, I did a bit of searching and it looks like there may be better ways to do this now than when the issue was created in 2016. If I (or someone) can find a not-too-hacky way to do this, like I said, I'm not opposed to the addition.

dranjan avatar Dec 24 '20 04:12 dranjan

what about moving plyfile to a structure like this:

dir: plyfile
↳   __init__.py (contains all code previously in plyfile.py)
    VERSION.py (file containing just: __version__ = "version string")

Then get __version__ at runtime with from .VERSION import __version__

And get version at install time (assuming plyfile dir is in same folder as setup.py) like this:

execfile(os.path.join('plyfile', 'VERSION.py'))
version = __version__

per: https://stackoverflow.com/a/2073599/3220135

athompson673 avatar Dec 28 '20 03:12 athompson673

As of Python 3.8, we have importlib.metadata:

>>> import importlib.metadata
>>> importlib.metadata.version('plyfile')
'0.7.4'

so it seems the language runtime solved the problem for us. My workaround/solution for this issue is thus to upgrade to Python version 3.8 or greater.

dranjan avatar Feb 17 '23 19:02 dranjan