forked from Bashfuscator/Bashfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
73 lines (58 loc) · 2.29 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
"""
Get dependencies, install bashfuscator to PATH and enable auto-completion
"""
from setuptools import setup, find_packages
from setuptools.command.install import install
from subprocess import call, Popen, PIPE
from sys import exit
import os
def findArgcompletePath(command):
proc = Popen("which " + command, stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
command1Path, __ = proc.communicate()
proc = Popen("which " + command + "3", stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
command2Path, __ = proc.communicate()
if command1Path:
finalCommandPath = command1Path
elif command2Path:
finalCommandPath = command2Path
else:
print("ERROR: python3-argcomplete is not installed, install it with your package manager to activate autocompletion")
exit(1)
return finalCommandPath[:-1]
with open("README.md") as f:
longDescription = f.read()
setup(
name="bashfuscator",
version="0.0.1",
description="Configurable and extendable Bash obfuscation framework",
license="MIT",
long_description=longDescription,
author="Andrew LeFevre",
packages=find_packages(),
scripts=["bashfuscator/bin/bashfuscator"],
install_requires=[
"argcomplete",
"pyperclip",
],
extras_require={
"dev": [
"pytest",
]
}
)
# activate autocompletion for bashfuscator
bashrcFile = os.environ["HOME"] + os.sep + ".bashrc"
if os.path.exists(bashrcFile):
with open(bashrcFile, "r") as f:
bashrcContent = f.read()
if "bashfuscator" not in bashrcContent:
print("\nRegistering bashfuscator in .bashrc for auto-completion ...")
proc = call(findArgcompletePath("activate-global-python-argcomplete") + " --user", shell=True)
argcompleteComment = "# Enables autocompletion of options for bashfuscator"
with open(bashrcFile, "a") as f:
f.write("\n\n{0}\n".format(argcompleteComment))
f.write('eval "$({0})"\n'.format(findArgcompletePath("register-python-argcomplete") + " bashfuscator"))
print("Auto-completion has been installed.")
proc = call("source " + bashrcFile, executable="/bin/bash", shell=True)
else:
print("ERROR: could not find your .bashrc file, autocompletion will not enabled")