-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
134 lines (113 loc) · 3.56 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env python3
#
# Copyright 2019 British Broadcasting Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import os
import subprocess
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
from nmosauth.auth_server.constants import NMOSAUTH_DIR
GEN_CERT_FILE = 'gen_cert.py'
GEN_CERT_PATH = os.path.join(NMOSAUTH_DIR, GEN_CERT_FILE)
# Basic metadata
name = "nmos-auth"
version = "1.5.0"
description = "OAuth2 Server Implementation"
url = 'https://github.com/bbc/nmos-auth-server'
author = 'Danny Meloy'
author_email = '[email protected]'
license = 'Apache2'
long_description = "OAuth2 Server Implementation to produce JWTs for API Access"
def gen_certs():
try:
subprocess.call([GEN_CERT_PATH])
except Exception as e:
print('Error: {}. Failed to generate certificates.'.format(str(e)))
print('Please run "{}" in {}'.format(GEN_CERT_FILE, NMOSAUTH_DIR))
pass
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
develop.run(self)
gen_certs()
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
gen_certs()
def is_package(path):
return (
os.path.isdir(path) and os.path.isfile(os.path.join(path, '__init__.py'))
)
def find_packages(path, base=""):
""" Find all packages in path """
packages = {}
for item in os.listdir(path):
dir = os.path.join(path, item)
if is_package(dir):
if base:
module_name = "%(base)s.%(item)s" % vars()
else:
module_name = item
packages[module_name] = dir
packages.update(find_packages(dir, module_name))
return packages
packages = find_packages(".")
package_names = packages.keys()
# This is where you list packages which are required
packages_required = [
"six",
"flask",
"sqlalchemy",
"flask-sqlalchemy",
"flask-cors",
"requests",
"gevent",
"nmoscommon",
"werkzeug>=0.14.1,<1.0.0", # Echo pin from nmos-common to avoid Flask overriding it
"authlib>=0.13,<0.15", # 0.15 requires an update to client_registration.py parsing incoming token for user
"pyopenssl>=16.0",
"cryptography>=1.5"
]
deps_required = []
setup(
name=name,
version=version,
description=description,
url=url,
author=author,
author_email=author_email,
license=license,
packages=package_names,
package_dir=packages,
install_requires=packages_required,
include_package_data=True,
scripts=[
'bin/nmosauth'
],
package_data={
'nmosauth': ['auth_server/templates/*', 'auth_server/static/*']
},
data_files=[
('/usr/bin', ['bin/nmosauth']),
(NMOSAUTH_DIR, ['nmosauth/certs/{}'.format(GEN_CERT_FILE)])
],
long_description=long_description,
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand
}
)