forked from puresec/puresec-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·83 lines (72 loc) · 2.44 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
#!/usr/bin/env python3
from setuptools import setup, find_packages
import distutils.cmd
import setuptools.command.bdist_egg
import setuptools.command.sdist
import setuptools.command.test
import re
import subprocess
def find_version():
with open('puresec_cli/__init__.py') as f:
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
f.read(), re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
def run_test(self):
# nosetests raises SystemExit(False) which stops the setup process
try:
self.run_command('nosetests')
except SystemExit as e:
if e.code: raise
class InstallNonPythonDepsCommand(distutils.cmd.Command):
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.announce("Running command: rm -rf puresec_cli/resources/node_modules", level=distutils.log.INFO)
subprocess.check_call(['rm', '-rf', 'puresec_cli/resources/node_modules'])
self.announce("Running command: npm install", level=distutils.log.INFO)
subprocess.check_call(['npm', 'install', 'dependency-tree@^5.9.1', '--prefix', 'puresec_cli/resources'])
class BdistEggCommand(setuptools.command.bdist_egg.bdist_egg):
def run(self):
self.run_command('install_non_python_deps')
run_test(self)
super().run()
class SdistCommand(setuptools.command.sdist.sdist):
def run(self):
self.run_command('install_non_python_deps')
run_test(self)
super().run()
setup(
name='puresec-cli',
version=find_version(),
description="PureSec CLI tools for improving the security of your serverless applications.",
long_description=open('README.rst').read(),
author='PureSec',
author_email='support@puresec.io',
url='https://github.com/puresec/puresec-cli',
cmdclass={
'install_non_python_deps': InstallNonPythonDepsCommand,
'bdist_egg': BdistEggCommand,
'sdist': SdistCommand,
},
packages=find_packages(exclude=['tests*']),
include_package_data=True,
entry_points={
'console_scripts': [
'puresec=puresec_cli.cli:main',
],
},
install_requires=[
'PyYAML',
'termcolor',
'analytics-python',
# AWS
'boto3',
'aws-parsecf',
],
setup_requires=['nose'],
tests_require=['coverage'],
)