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

uvloop.__version__ isn't set #137

Closed
MarkReedZ opened this issue Apr 8, 2018 · 6 comments
Closed

uvloop.__version__ isn't set #137

MarkReedZ opened this issue Apr 8, 2018 · 6 comments

Comments

@MarkReedZ
Copy link

MarkReedZ commented Apr 8, 2018

__init__.py should set the version though the following can be done to get the version:

import pkg_resources
pkg_resources.require("uvloop")[0].version
@kxepal
Copy link

kxepal commented Apr 8, 2018

Not really. pkg_resources gets all the information from package metadata directories (.egg-info or .dist-info). If you install uvloop correctly (via pip), then it will works as expected.

$ pip install uvloop
Collecting uvloop
  Downloading uvloop-0.9.1-cp36-cp36m-manylinux1_x86_64.whl (3.2MB)
    100% |████████████████████████████████| 3.2MB 451kB/s 
Installing collected packages: uvloop
Successfully installed uvloop-0.9.1
$ python
Python 3.6.5 (default, Apr  8 2018, 11:23:52) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> pkg_resources.require("uvloop")[0].version
'0.9.1'
>>> type(pkg_resources.require("uvloop")[0])
<class 'pkg_resources.DistInfoDistribution'>
>>> 

@MarkReedZ
Copy link
Author

I may have worded that wrong, but python states you should make the version number available in version which I don't think is set by uvloop.

@asvetlov
Copy link
Contributor

asvetlov commented Apr 8, 2018

IMHO Python never states it.
But very many distros (not all) have __version__ attribute in top level package.

@kxepal
Copy link

kxepal commented Apr 8, 2018

__version__ thing is just an agreement the same as __author__, __revision__ and the rest of those. These has no effect nor special meaning. However, version in package metadata matters since all the managers (pip, setuptools, pipenv) will use it for their work. Which makes it's more reliable source of truth than some custom module attribute.

The main problem with __version__ attribute is a chicken and egg one. You need package version to install the package, but you can't get package version without install it. So you have to found yourself to do import hacks (install-without-install) or doing regexp parsing. Not quite cool nor reliable ways to go just to achieve...what?

@1st1
Copy link
Member

1st1 commented May 18, 2018

What's the actual intent behind checking __version__? Ideally you should never depend on it in your source code.

@sakurai-youhei
Copy link

FYI: Mine is reliable & straightfoward version check by python -c 'import uvloop; print(uvloop.__version__)' rather than querying pip.

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

No branches or pull requests

5 participants