Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the module does not expose its version #190

Closed
fcbond opened this issue Oct 22, 2018 · 5 comments
Closed

the module does not expose its version #190

fcbond opened this issue Oct 22, 2018 · 5 comments
Milestone

Comments

@fcbond
Copy link
Member

fcbond commented Oct 22, 2018

Although the version is defined in about.py and it looks as though it is being read in setup.py, I can't actually see it:

>>> import delphin
>> delphin.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'delphin' has no attribute '__version__'
>>> delphin.version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'delphin' has no attribute 'version'
>>> 

This makes it impossible to request a given version, ...

@goodmami
Copy link
Member

In setup.py it is read from __about__.py and set in the package metadata. See these lines:

pydelphin/setup.py

Lines 15 to 22 in 4f6c43a

base_dir = os.path.dirname(__file__)
about = {}
with open(os.path.join(base_dir, "delphin", "__about__.py")) as f:
exec(f.read(), about)
setup(
name=about['__title__'],
version=about['__version__'],

There is no standard that I'm aware of that says the version string must be defined at the top-level package (though it seems sensible). By putting it in __about__.py I was following a recommendation described here (see item 3): https://packaging.python.org/guides/single-sourcing-package-version

You can get PyDelphin's version programmatically as follows:

>>> from delphin.__about__ import __version__
>>> __version__
'0.9.0'

Or from the command line (although the output looks like the command version instead of the library version):

$ delphin -V
delphin 0.9.0

It is certainly possible to install a specific version from pip (assuming it was uploaded to PyPI):

$ pip install pydelphin==0.8.0
Collecting pydelphin==0.8.0
...

If it's important for you to have delphin.__version__ defined, the simplest solution is probably to put from __about__ import __version__ in delphin/__init__.py.

@goodmami
Copy link
Member

@fcbond can you reproduce a problem caused by the current setup? Or is there a change you'd like to see (and if so, why)?

Otherwise I'll consider the issue closed.

@fcbond
Copy link
Member Author

fcbond commented Oct 26, 2018 via email

@goodmami
Copy link
Member

goodmami commented Oct 26, 2018

I'm sorry you had so much trouble finding the version. Making the __version__ and __version_info__ variables, if not the others, available in the delphin package is possible through an import (but actually moving them there would cause the same potential problem as importing the package in setup.py, which is circular dependencies). Also, if delphin becomes a namespace package (#182) then it may be dispreferred to have the namespace define its own version rather than the packages in the namespace (as they can be developed separately), but I think there are ways to avoid that situation.

And the 'single-sourcing' link implies package.__version__ in options 1 and 6, but not the others, so I still don't think it is standard, but maybe it should be.

Also relevant (but note the "deferred" status): https://www.python.org/dev/peps/pep-0396/

In any case I'll leave this open and decide on something for the next release.

@goodmami goodmami modified the milestones: v0.10.0, v0.9.1 Oct 26, 2018
@goodmami
Copy link
Member

Next release is actually v0.9.1, so I'm switching the milestone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants