Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

nupic.__version__ missing #2555

Closed
rhyolight opened this issue Sep 8, 2015 · 4 comments
Closed

nupic.__version__ missing #2555

rhyolight opened this issue Sep 8, 2015 · 4 comments

Comments

@rhyolight
Copy link
Member

The imported nupic module in python used to have a __version__ attribute. This was assumed to be a part of the public API, so nupic.studio depends on it. At some point in the last few months, this attribute has gone missing.

> python
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nupic
>>> nupic
<module 'nupic' from '/Users/mtaylor/Library/Python/2.7/lib/python/site-packages/nupic.bindings-0.1.5-py2.7-macosx-10.9-intel.egg/nupic/__init__.pyc'>
>>> nupic.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__version__'

Because of module 'nupic' from '/Users/mtaylor/Library/Python/2.7/lib/python/site-packages/nupic.bindings-0.1.5-py2.7-macosx-10.9-intel.egg/nupic/__init__.pyc', I believe this change might have occurred during the C++ move from nupic into nupic.core. That means the change we're looking for is in one of these pull requests:

Unless someone thinks otherwise, I feel like this should be treated as an inadvertent API breakage and labeled priority:1. Especially because it was reported on the mailing list.

It should be pretty easy to add back, hopefully?

@rhyolight rhyolight self-assigned this Sep 8, 2015
@rhyolight rhyolight added this to the 0.3.1: Current Development milestone Sep 8, 2015
@passiweinberger
Copy link
Member

https://github.com/numenta/nupic/blob/master/setup.py#L34
the version file exsists. Hm :/

Only as of: http://stackoverflow.com/a/7071358
We may change that procedure? But the poposed rexeg way is more expensive so hm :$

@scottpurdy
Copy link
Contributor

@rhyolight - This was an intentional change. The issue is that nupic is a namespace package so we can't put anything in nupic/__init__.py. @oxtopus - Do you know any way around this?

@oxtopus
Copy link
Contributor

oxtopus commented Sep 8, 2015

👎

There is no official API for tracking versions, and if nupic.__version__ is/was part of any official public API, it's not documented anywhere. A better, and arguably more correct, way to track versions is using the native setuptools utilities, defining the version in the call to setup() (see https://github.com/numenta/nupic/blob/master/setup.py#L73). This is the mechanism used by pip and friends. For example, this allows you to do the following:

>>> from pkg_resources import get_distribution
>>> get_distribution("nupic").version
'0.3.1.dev0'
>>> get_distribution("nupic.bindings").version
'0.1.5'

I disagree that this is a P1, and that it's a bug. init.py files in namespace packages can't have anything beyond the declare_namespace() call or else you get unexpected results when you have multiple packages that share the namespace.

As noted in the SO link above, the __version__ attr is only a convention, and explicitly NOT an official API. https://www.python.org/dev/peps/pep-0396/ is in a deferred state, rather than accepted.

@rhyolight
Copy link
Member Author

Thanks for jumping on this, guys. You've convinced me this was not a P1 bug.

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

No branches or pull requests

4 participants