-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.py
63 lines (54 loc) · 2.11 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
""" Tool Setup """
# !/usr/bin/env python3
import os
from shutil import copyfile
from setuptools import setup
from setuptools.command.install import install
PACKAGE_NAME = "pihole-dashboard"
VERSION = "1.0.3"
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
def parse_requirements(filename):
"""Load requirements from a pip requirements file."""
lineiter = (line.strip() for line in open(filename))
return [line for line in lineiter if line and not line.startswith("#")]
class PostInstallJob(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
print("Installing cronjob...")
self_dir = os.path.dirname(os.path.realpath(__file__))
cron_dir = os.path.join(self_dir, 'cron')
copyfile(os.path.join(cron_dir, "pihole-dashboard-cron"),
"/etc/cron.d/pihole-dashboard-cron")
print("Installing config file...")
self_dir = os.path.dirname(os.path.realpath(__file__))
conf_dir = os.path.join(self_dir, 'conf')
conf_sys_dir = "/etc/pihole-dashboard"
if not os.path.exists(conf_sys_dir):
os.makedirs(conf_sys_dir)
copyfile(os.path.join(conf_dir, "config.toml"),
"/etc/pihole-dashboard/config.toml")
print("Done.")
if __name__ == "__main__":
setup(
name=PACKAGE_NAME,
version=VERSION,
author="santoru",
author_email="[email protected]",
description="Minimal dashboard for Pi-Hole that works with WaveShare's 2.13 inch HAT display",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/santoru/pihole-dashboard",
packages=["pihole_dashboard"],
package_data={'pihole_dashboard': ['font/*.ttf']},
scripts=[
"scripts/pihole-dashboard-clean-screen",
"scripts/pihole-dashboard-draw"
],
python_requires='>=3.3.5',
install_requires=parse_requirements("requirements.txt"),
cmdclass={
'install': PostInstallJob,
},
)