2017-02-24 00:21:02 +01:00
|
|
|
# vim: fileencoding=utf-8
|
|
|
|
|
2017-05-12 00:16:26 +02:00
|
|
|
import os
|
2017-02-24 00:21:02 +01:00
|
|
|
import setuptools
|
2017-11-09 17:46:06 +01:00
|
|
|
import setuptools.command.install
|
2017-04-14 13:26:45 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
exclude=[]
|
2017-05-11 23:40:49 +02:00
|
|
|
if sys.version_info[0:2] < (3, 4):
|
|
|
|
exclude += ['qubesadmin.tools', 'qubesadmin.tests.tools']
|
2017-07-15 14:12:39 +02:00
|
|
|
exclude += ['qubesadmin.backup', 'qubesadmin.tests.backup']
|
2017-04-14 13:26:45 +02:00
|
|
|
if sys.version_info[0:2] < (3, 5):
|
2017-05-11 23:40:49 +02:00
|
|
|
exclude += ['qubesadmin.events']
|
2017-02-24 00:21:02 +01:00
|
|
|
|
2017-05-12 00:16:26 +02:00
|
|
|
# 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('./qubesadmin/tools'):
|
|
|
|
basename, ext = os.path.splitext(os.path.basename(filename))
|
|
|
|
if basename in ['__init__', 'dochelpers'] or ext != '.py':
|
|
|
|
continue
|
2017-11-09 17:46:06 +01:00
|
|
|
yield basename.replace('_', '-'), 'qubesadmin.tools.{}'.format(basename)
|
2017-05-12 00:16:26 +02:00
|
|
|
|
2017-11-09 17:46:06 +01:00
|
|
|
# create simple scripts that run much faster than "console entry points"
|
|
|
|
class CustomInstall(setuptools.command.install.install):
|
|
|
|
def run(self):
|
|
|
|
bin = os.path.join(self.root, "usr/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)
|
2017-05-12 00:16:26 +02:00
|
|
|
|
2017-02-24 00:21:02 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
setuptools.setup(
|
2017-05-11 23:21:04 +02:00
|
|
|
name='qubesadmin',
|
2017-02-24 00:21:02 +01:00
|
|
|
version=open('version').read().strip(),
|
|
|
|
author='Invisible Things Lab',
|
|
|
|
author_email='marmarek@invisiblethingslab.com',
|
2017-05-11 23:21:04 +02:00
|
|
|
description='Qubes Admin API package',
|
2017-02-24 00:21:02 +01:00
|
|
|
license='LGPL2.1+',
|
|
|
|
url='https://www.qubes-os.org/',
|
2017-04-14 13:26:45 +02:00
|
|
|
packages=setuptools.find_packages(exclude=exclude),
|
2017-07-16 05:22:13 +02:00
|
|
|
package_data={
|
|
|
|
'qubesadmin.tests.backup': ['*.xml'],
|
|
|
|
},
|
2017-11-09 17:46:06 +01:00
|
|
|
cmdclass={
|
|
|
|
'install': CustomInstall
|
2017-02-28 01:34:09 +01:00
|
|
|
},
|
|
|
|
|
2017-02-24 00:21:02 +01:00
|
|
|
)
|