From 1aea68a2a7132a57aafee27852e43f43ae2cb496 Mon Sep 17 00:00:00 2001 From: sinseman44 Date: Sun, 15 Nov 2020 11:02:13 +0000 Subject: [PATCH] update setup.py --- .../create_service.sh | 2 +- .../piplotter.service | 0 setup.py | 23 +++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) rename {install_scripts => inst_scripts}/create_service.sh (67%) rename {install_scripts => inst_scripts}/piplotter.service (100%) diff --git a/install_scripts/create_service.sh b/inst_scripts/create_service.sh similarity index 67% rename from install_scripts/create_service.sh rename to inst_scripts/create_service.sh index 86922b2..7708926 100755 --- a/install_scripts/create_service.sh +++ b/inst_scripts/create_service.sh @@ -1,6 +1,6 @@ #!/bin/bash -cp -a "install_scripts/piplotter.service" /etc/systemd/system +cp -a "inst_scripts/piplotter.service" /etc/systemd/system chown root:root /etc/systemd/system/piplotter.service systemctl daemon-reload diff --git a/install_scripts/piplotter.service b/inst_scripts/piplotter.service similarity index 100% rename from install_scripts/piplotter.service rename to inst_scripts/piplotter.service diff --git a/setup.py b/setup.py index 7817bf9..db83ac6 100755 --- a/setup.py +++ b/setup.py @@ -1,13 +1,26 @@ -from setuptools import setup, find_packages from setuptools.command.install import install +from setuptools.command.develop import develop +from setuptools import setup, find_packages import subprocess +import distutils.cmd import os -class CustomInstallCommand(install): +class ServiceCommand(distutils.cmd.Command): + """A custom command to install systemd service """ + + description = 'Install systemd service' + user_options = [] + + def initialize_options(self): + """Set default values for options.""" + + def finalize_options(self): + """Post-process options.""" + def run(self): - install.run(self) + """Run command.""" current_dir_path = os.path.dirname(os.path.realpath(__file__)) - create_service_script_path = os.path.join(current_dir_path, 'install_scripts', 'create_service.sh') + create_service_script_path = os.path.join(current_dir_path, 'inst_scripts', 'create_service.sh') subprocess.check_output([create_service_script_path]) with open("README.md", "r") as fh: @@ -24,7 +37,7 @@ setup( url="https://github.com/sinseman44/PiPlot2D", scripts=['piplotter'], cmdclass={ - 'install': CustomInstallCommand + 'install_service': ServiceCommand }, packages=find_packages(), classifiers=[