watercontrol/setup.py
2022-05-20 09:22:24 +02:00

57 lines
1.6 KiB
Python
Executable File

"""Setup"""
import os
import shutil
import stat
from setuptools import setup
from setuptools.command.install import install
NAME = 'Watercontrol'
VERSION = '1'
AUTHOR = 'Thomas Klaehn'
EMAIL = 'tkl@blackfinn.de'
PACKAGES = ['watercontrol']
REQUIRES = ['RPi.GPIO']
CONFIG_FILE = 'config.json'
PACKAGE_DATA = {
'watercontrol': [
'watercontrol/config.json'
]
}
SERVICEDIR = "/lib/systemd/system"
START_SCRIPT = 'watercontrol.service'
DAEMON_START_SCRIPT = os.path.join(SERVICEDIR, START_SCRIPT)
LOGFILE = "/var/log/watercontrol.log"
ENTRY_POINTS = {
'console_scripts': [
'watercontrol = watercontrol.main:main'
]
}
class Install(install):
"""Installer"""
def run(self):
install.run(self)
os.makedirs(SERVICEDIR, exist_ok=True)
shutil.copyfile(START_SCRIPT, DAEMON_START_SCRIPT)
os.chmod(DAEMON_START_SCRIPT, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
try:
open(LOGFILE, 'r', encoding="UTF-8")
except FileNotFoundError:
os.makedirs(os.path.dirname(LOGFILE), exist_ok=True)
open(LOGFILE, 'x', encoding="UTF-8")
os.chmod(LOGFILE,
stat.S_IRUSR |
stat.S_IWUSR |
stat.S_IRGRP |
stat.S_IWGRP |
stat.S_IROTH |
stat.S_IWOTH)
setup(name=NAME, version=VERSION, long_description=__doc__, author=AUTHOR, author_email=EMAIL,
packages=PACKAGES, include_package_data=True, package_data=PACKAGE_DATA, zip_safe=False,
install_requires=REQUIRES, entry_points=ENTRY_POINTS, cmdclass={'install': Install})