#!/usr/bin/env python3 import os import sys import glob from shutil import copyfile from setuptools import setup def get_data_files(force_settings=False): data_files = [] # Handle locale files locale_files = glob.glob('locale/*/LC_MESSAGES/*.mo') for locale_file in locale_files: lang = locale_file.split(os.sep)[1] dest_dir = f'/usr/share/locale/{lang}/LC_MESSAGES' data_files.append((dest_dir, [locale_file])) # Handle configuration files directories = glob.glob('config/*') for directory in directories: files = glob.glob(directory+'/*') dest_dir = '' if 'config/punctuation' in directory: dest_dir = '/etc/fenrirscreenreader/punctuation' elif 'config/keyboard' in directory: dest_dir = '/etc/fenrirscreenreader/keyboard' elif 'config/settings' in directory: dest_dir = '/etc/fenrirscreenreader/settings' if not force_settings: try: files.remove('config/settings/settings.conf') except ValueError: pass elif 'config/scripts' in directory: dest_dir = '/usr/share/fenrirscreenreader/scripts' if dest_dir: data_files.append((dest_dir, files)) # Handle sound files files = glob.glob('config/sound/default/*') data_files.append(('/usr/share/sounds/fenrirscreenreader/default', files)) files = glob.glob('config/sound/template/*') data_files.append(('/usr/share/sounds/fenrirscreenreader/template', files)) return data_files def post_install_actions(): if '--force-settings' not in sys.argv: print('') # create settings file from example if not exist if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'): try: copyfile('/etc/fenrirscreenreader/settings/settings.conf.example', '/etc/fenrirscreenreader/settings/settings.conf') print('create settings file in /etc/fenrirscreenreader/settings/settings.conf') except: pass else: print('settings.conf file found. It is not overwritten automatically') print('') print('To have Fenrir start at boot:') print('sudo systemctl enable fenrir') print('Pulseaudio users may want to run:') print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh') print('once as their user account and once as root to configure Pulseaudio.') print('Please install the following packages manually:') print('- Speech-dispatcher: for the default speech driver') print('- Espeak: as basic TTS engine') print('- sox: is a player for the generic sound driver') if __name__ == "__main__": force_settings = '--force-settings' in sys.argv if force_settings: sys.argv.remove('--force-settings') setup( data_files=get_data_files(force_settings), ) post_install_actions()