-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
78 lines (66 loc) · 1.96 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import sys
import re
import subprocess
import shlex
try:
from setuptools import setup
from setuptools.command.install import install
except ImportError:
from distutils.core import setup
from distutils.command.install import install
VERSION = '1.0.6'
def get_tag_version():
cmd = 'git tag --points-at HEAD'
versions = subprocess.check_output(shlex.split(cmd)).splitlines()
if not versions:
return None
if len(versions) != 1:
sys.exit(f"Trying to get tag via git: Expected excactly one tag, got {len(versions)}")
version = versions[0].decode()
if re.match('^v[0-9]', version):
version = version[1:]
return version
class VerifyVersionCommand(install):
""" Custom command to verify that the git tag matches our version """
description = 'verify that the git tag matches our version'
def run(self):
tag_version = get_tag_version()
if tag_version and tag_version != VERSION:
sys.exit(f"Git tag: {tag} does not match the version of this app: {VERSION}")
INSTALL_REQUIRES = [
"djangorestframework",
]
setup(
name='rest_framework_roles',
version=VERSION,
description='Role-based permissions for Django REST Framework and vanilla Django.',
author='Johan Hanssen Seferidis',
author_email='[email protected]',
packages=['rest_framework_roles'],
url='https://github.com/Pithikos/rest-framework-roles',
license='LICENSE',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
install_requires=INSTALL_REQUIRES,
python_requires='>=3',
keywords=[
'permissions',
'roles',
'users',
'django',
'rest',
'drf',
'acl',
'security',
'rest framework',
'access control'
],
classifiers=[
'Framework :: Django',
'Topic :: Security',
],
cmdclass={
'verify': VerifyVersionCommand,
},
)