Skip to content

Commit d626f7e

Browse files
committed
Add __version__ and derive package version from it
1 parent e4ebd2e commit d626f7e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

jwt/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
basestring = str
2626

2727

28+
__version__ = '0.2.2'
2829
__all__ = ['encode', 'decode', 'DecodeError']
2930

3031

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
#!/usr/bin/env python
22
import os
3+
import re
34
from setuptools import setup
45

56

7+
def get_version(package):
8+
"""
9+
Return package version as listed in `__version__` in `init.py`.
10+
"""
11+
init_py = open(os.path.join(package, '__init__.py')).read()
12+
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
13+
14+
15+
version = get_version('jwt')
16+
617
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
718
long_description = readme.read()
819

20+
921
setup(
1022
name='PyJWT',
11-
version='0.2.2',
23+
version=version,
1224
author='Jeff Lindsay',
1325
author_email='progrium@gmail.com',
1426
description='JSON Web Token implementation in Python',

0 commit comments

Comments
 (0)