forked from leamas/ddupdate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
100 lines (85 loc) · 3.05 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
"""ddupdate install data."""
import shutil
import os
import subprocess
from distutils.command.clean import clean
from distutils.command.install import install
from glob import glob
from setuptools import setup
# pylint: disable=bad-continuation
ROOT = os.path.dirname(__file__)
ROOT = ROOT if ROOT else '.'
def systemd_unitdir():
"""Return the official systemd user unit dir path."""
cmd = 'pkg-config systemd --variable=systemduserunitdir'.split()
try:
return subprocess.check_output(cmd).decode().strip()
except (OSError, subprocess.CalledProcessError):
return "/usr/lib/systemd/user"
DATA = [
(systemd_unitdir(), glob('systemd/*')),
('share/bash-completion/completions/', ['bash_completion.d/ddupdate']),
('share/man/man8', ['ddupdate.8', 'ddupdate-config.8']),
('share/man/man5', ['ddupdate.conf.5']),
('share/ddupdate/plugins', glob('plugins/*.py')),
('share/ddupdate/dispatcher.d', ['dispatcher.d/50-ddupdate']),
('share/ddupdate/systemd', glob('systemd/*'))
]
class _ProjectClean(clean):
"""Actually clean up everything generated."""
def run(self):
super().run()
paths = ['build', 'install', 'dist', 'lib/ddupdate.egg-info']
for path in paths:
if os.path.exists(path):
shutil.rmtree(path)
class _ProjectInstall(install):
"""Log used installation paths."""
def run(self):
super().run()
from distutils.fancy_getopt import longopt_xlate
s = ""
install_lib = ""
for (option, _, _) in self.user_options:
option = option.translate(longopt_xlate)
if option[-1] == "=":
option = option[:-1]
try:
value = getattr(self, option)
except AttributeError:
continue
if option == "install_lib":
install_lib = value
s += option + " = " + (str(value) if value else "") + "\n"
if not install_lib:
print("Warning: cannot create platform install paths file")
return
path = install_lib + "/ddupdate/install.conf"
print("Creating install config file " + path)
with open(path, "w") as f:
f.write("[install]\n")
f.write(s)
setup(
name='ddupdate',
version='0.6.4',
description='Update dns data for dynamic ip addresses',
long_description=open(ROOT + '/README.md').read(),
include_package_data=True,
license='MIT',
url='http://github.com/leamas/ddupdate',
author='Alec Leamas',
author_email='[email protected]',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: End Users/Desktop',
'Topic :: System :: Networking',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.4',
],
keywords=['dyndns', 'dhcp', 'dns'],
package_dir={'': 'lib'},
packages=['ddupdate'],
scripts=['ddupdate', 'ddupdate-config'],
data_files=DATA,
cmdclass={'clean': _ProjectClean, 'install': _ProjectInstall}
)