File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
33import os
4+ import re
45import sys
56
67from setuptools import find_packages , setup
78
8- __version__ = None
9- with open ('jwt/__init__.py' ) as fp :
10- _locals = {}
11- for line in fp :
12- if line .startswith ('__version__' ):
13- exec (line , None , _locals )
14- __version__ = _locals ['__version__' ]
15- break
9+
10+ def get_version (package ):
11+ """
12+ Return package version as listed in `__version__` in `init.py`.
13+ """
14+ with open (os .path .join (package , '__init__.py' ), 'rb' ) as init_py :
15+ src = init_py .read ().decode ('utf-8' )
16+ return re .search ("__version__ = ['\" ]([^'\" ]+)['\" ]" , src ).group (1 )
17+
18+
19+ version = get_version ('jwt' )
1620
1721with open (os .path .join (os .path .dirname (__file__ ), 'README.md' )) as readme :
1822 long_description = readme .read ()
2125 os .system ('python setup.py sdist upload' )
2226 os .system ('python setup.py bdist_wheel upload' )
2327 print ('You probably want to also tag the version now:' )
24- print (" git tag -a {0} -m 'version {0}'" .format (__version__ ))
28+ print (" git tag -a {0} -m 'version {0}'" .format (version ))
2529 print (' git push --tags' )
2630 sys .exit ()
2731
3337
3438setup (
3539 name = 'PyJWT' ,
36- version = __version__ ,
40+ version = version ,
3741 author = 'José Padilla' ,
3842 author_email = 'hello@jpadilla.com' ,
3943 description = 'JSON Web Token implementation in Python' ,
You can’t perform that action at this time.
0 commit comments