This repository was archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
executable file
·59 lines (46 loc) · 1.6 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
#!/usr/bin/python
from __future__ import print_function
import atexit
import os
import sys
import inspect
from setuptools import setup
from setuptools.command.install import install
PKGNAME = "hashivault_vars"
ANSIBLE_VARS = "/usr/local/lib/python2.7/dist-packages/ansible/plugins/vars"
MODLINK = os.path.join(ANSIBLE_VARS, PKGNAME + ".py")
class CustomInstall(install):
def run(self):
def _post_install():
if os.getuid() != 0:
return
def find_module_path():
for p in sys.path:
if os.path.isdir(p) and PKGNAME in os.listdir(p):
return os.path.join(p, PKGNAME)
install_path = find_module_path()
if os.path.exists(ANSIBLE_VARS):
if os.path.exists(MODLINK):
if os.path.islink(MODLINK):
os.unlink(MODLINK)
else:
raise Exception(
"%s already exists and is not a symlink" % (
MODLINK)
)
# Link Ansible vars plugins to this module
os.symlink(
os.path.join(install_path, PKGNAME + ".py"),
MODLINK
)
atexit.register(_post_install)
install.run(self)
__location__ = os.path.join(os.getcwd(), os.path.dirname(
inspect.getfile(inspect.currentframe())))
setup(
cmdclass={'install': CustomInstall},
name=PKGNAME,
version="0.2.0",
packages=[PKGNAME],
install_requires=["urllib3", "hvac"]
)