-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
109 lines (96 loc) · 3.31 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
import os
import sys
import re
import ast
from subprocess import call
import io
import pip
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.install import install
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
_version_re = re.compile(r'__version__\s+=\s+(.*)')
with open('owtf/__init__.py', 'rb') as f:
version = str(ast.literal_eval(_version_re.search(f.read().decode('utf-8')).group(1)))
def parse_file(filename, encoding='utf-8'):
"""Return contents of the given file using the given encoding."""
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename)
with io.open(path, encoding=encoding) as fo:
contents = fo.read()
return contents
links = []
requires = []
# new versions of pip requires a session
requirements = pip.req.parse_requirements('requirements.txt', session=pip.download.PipSession())
for item in requirements:
if getattr(item, 'url', None): # older pip has url
links.append(str(item.url))
if getattr(item, 'link', None): # newer pip has link
links.append(str(item.link))
if item.req:
requires.append(str(item.req)) # always the package name
post_script = os.path.join(ROOT_DIR, "owtf/install/install.py")
tests_requires = [
'PyHamcrest==1.9.0',
'mock>=1.3.0',
]
docs_requires = [
'sphinx',
'sphinx_py3doc_enhanced_theme'
]
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
develop.run(self)
print('Running post install')
call([sys.executable, post_script])
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
# Need because of a setuptools bug: https://github.com/pypa/setuptools/issues/456
self.do_egg_install()
print('Running post install')
call([sys.executable, post_script])
setup(
name='owtf',
version=version,
url='https://github.com/owtf/owtf',
license='BSD',
author="Abraham Aranguren",
author_email="[email protected]",
description='OWASP+PTES focused try to unite great tools and make pen testing more efficient',
long_description=parse_file('README.md'),
packages=find_packages(exclude=["node_modules.*", "*.node_modules", "*.node_modules.*", "node_modules"]),
include_package_data=True,
zip_safe=False,
platforms='any',
install_requires=sorted(requires, key=lambda s: s.split("==")[0].lower()),
dependency_links=links,
extras_require={
'test': tests_requires + requires,
'docs': docs_requires
},
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
entry_points={
'console_scripts': [
'owtf = owtf.__main__:main'
]
},
classifiers=[
'License :: OSI Approved :: BSD License',
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Operating System :: POSIX :: Linux',
'Topic :: Security'
]
)