-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
59 lines (51 loc) · 1.75 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
# vim: fileencoding=utf-8
import os
import setuptools
import setuptools.command.install
import sys
exclude=[]
# don't import: import * is unreliable and there is no need, since this is
# compile time and we have source files
def get_console_scripts():
if sys.version_info[0:2] >= (3, 4):
for filename in os.listdir('./qubesadmintt/tools'):
basename, ext = os.path.splitext(os.path.basename(filename))
if basename in ['__init__', 'dochelpers', 'xcffibhelpers']\
or ext != '.py':
continue
yield basename.replace('_', '-'), 'qubesadmintt.tools.{}'.format(
basename)
# create simple scripts that run much faster than "console entry points"
class CustomInstall(setuptools.command.install.install):
def run(self):
bin = os.path.join(os.path.expanduser('~'), "bin")
try:
os.makedirs(bin)
except:
pass
for file, pkg in get_console_scripts():
path = os.path.join(bin, file)
with open(path, "w") as f:
f.write(
"""#!/usr/bin/python3
from {} import main
import sys
if __name__ == '__main__':
sys.exit(main())
""".format(pkg))
os.chmod(path, 0o755)
setuptools.command.install.install.run(self)
if __name__ == '__main__':
setuptools.setup(
name='qubesadmintt',
version=open('version').read().strip(),
author='Ali Mirjamali',
author_email='ali@mirjamali.com',
description='Qubes Admin API Tweak Tools',
license='LGPL2.1+',
url='https://www.github.com/alimirjamali/personal-qubesos/',
packages=['qubesadmintt', 'qubesadmintt.tools'],
cmdclass={
'install': CustomInstall
},
)