From de98f3a982c0511c60e27e14a5912d22115ea6bf Mon Sep 17 00:00:00 2001 From: Rico Tiongson Date: Sat, 2 Mar 2019 19:17:10 +0800 Subject: [PATCH] Move install to post-install command --- README.md | 4 ++-- setup.py | 56 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index d1b85a0..a6e8ee3 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures ## Installation -1. Install git, libinput, and g++ +1. Install Python3, libinput, and g++ ```bash - sudo apt-get install git libinput-tools libxdo-dev g++ + sudo apt-get install git python3-dev libinput-tools libxdo-dev ``` 2. Clone this repository diff --git a/setup.py b/setup.py index c4ad48e..7f59bbc 100644 --- a/setup.py +++ b/setup.py @@ -81,38 +81,42 @@ try: # include program to sources so it will be removed on uninstall ) - # create directories if they don't exist yet - if 'install' in sys.argv: - os.path.exists(os.path.dirname(PROGRAM)) or os.makedirs(os.path.dirname(PROGRAM)) - os.path.exists(os.path.dirname(CONFIG)) or os.makedirs(os.path.dirname(CONFIG)) + class Install(install): + def run(self): + # perform original run command + install.run(self) - # copy any of the old config files - conf_files = [path for path in conf_paths if os.path.exists(path) and os.path.isfile(path)] - print('using configuration file at', conf_files[-1]) + # create program/config directories + os.path.exists(os.path.dirname(PROGRAM)) or os.makedirs(os.path.dirname(PROGRAM)) + os.path.exists(os.path.dirname(CONFIG)) or os.makedirs(os.path.dirname(CONFIG)) - if conf_files[-1] != CONFIG: - # new installation or upgrading from old version, copy to new location - copyfile(conf_files[-1], CONFIG) + # copy any of the old config files + conf_files = [path for path in conf_paths if os.path.exists(path) and os.path.isfile(path)] + print('using configuration file at', conf_files[-1]) - if conf_files[-1] == os.path.join(__DIR__, 'defaults.conf'): - # new installation - copy default configuration - print('copying configuration file to', CONFIG) + if conf_files[-1] != CONFIG: + # new installation or upgrading from old version, copy to new location + copyfile(conf_files[-1], CONFIG) - else: - # upgrading - delete the deprecated config file (failsafe) - try: - os.remove(conf_files[-1]) - print('moving deprecated configuration file to', CONFIG) - except: - pass + if conf_files[-1] == os.path.join(__DIR__, 'defaults.conf'): + # new installation - copy default configuration + print('copying configuration file to', CONFIG) - # toggle autostart - os.chdir(os.getenv('HOME')) - from comfortable_swipe import service - service.autostart() - service.autostart() + else: + # upgrading - delete the deprecated config file (failsafe) + try: + os.remove(conf_files[-1]) + print('moving deprecated configuration file to', CONFIG) + except: + pass - print('\nTry running "{} start" to test'.format(NAME)) + # toggle autostart + os.chdir(os.getenv('HOME')) + from comfortable_swipe import service + service.autostart() + service.autostart() + + print('\nTry running "{} start" to test'.format(NAME)) finally: