Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit c3fd287

Browse files
committed
Use get_version for package version
1 parent 35acda8 commit c3fd287

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

setup.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22
# -*- coding: utf-8 -*-
33

44
import os
5+
import re
56
import sys
67

7-
import rest_framework_jwt
8-
98
from setuptools import setup
109

1110

11+
def get_version(package):
12+
"""
13+
Return package version as listed in `__version__` in `init.py`.
14+
"""
15+
with open(os.path.join(package, '__init__.py'), 'rb') as init_py:
16+
src = init_py.read().decode('utf-8')
17+
return re.search("__version__ = ['\"]([^'\"]+)['\"]", src).group(1)
18+
19+
1220
name = 'djangorestframework-jwt'
13-
version = rest_framework_jwt.__version__
21+
version = get_version('rest_framework_jwt')
1422
package = 'rest_framework_jwt'
1523
description = 'JSON Web Token based authentication for Django REST framework'
1624
url = 'https://github.com/GetBlimp/django-rest-framework-jwt'

0 commit comments

Comments
 (0)