This modern installation method is turning out to be a pita.

This commit is contained in:
Storm Dragon 2024-12-20 11:32:26 -05:00
parent c77d2bddd8
commit 191181a6a5

103
setup.py
View File

@ -2,7 +2,7 @@
import os import os
import sys import sys
import glob import glob
import shutil from shutil import copyfile
from setuptools import setup from setuptools import setup
def get_data_files(): def get_data_files():
@ -16,85 +16,68 @@ def get_data_files():
dest_dir = f'/usr/share/locale/{lang}/LC_MESSAGES' dest_dir = f'/usr/share/locale/{lang}/LC_MESSAGES'
data_files.append((dest_dir, [locale_file])) data_files.append((dest_dir, [locale_file]))
# Handle /etc/fenrirscreenreader directories # Handle configuration files - using original code
etc_dirs = { directories = glob.glob('config/*')
'keyboard': '/etc/fenrirscreenreader/keyboard', for directory in directories:
'punctuation': '/etc/fenrirscreenreader/punctuation', files = glob.glob(directory+'/*')
'settings': '/etc/fenrirscreenreader/settings' dest_dir = ''
} if 'config/punctuation' in directory:
dest_dir = '/etc/fenrirscreenreader/punctuation'
for src_dir, dest_dir in etc_dirs.items(): elif 'config/keyboard' in directory:
src_path = f'config/{src_dir}' dest_dir = '/etc/fenrirscreenreader/keyboard'
if os.path.exists(src_path): elif 'config/settings' in directory:
files = glob.glob(f'{src_path}/*') dest_dir = '/etc/fenrirscreenreader/settings'
if src_dir == 'settings':
if not force_settings: if not force_settings:
# Remove settings.conf if it exists in the list try:
files = [f for f in files if not f.endswith('settings.conf')] files.remove('config/settings/settings.conf')
# Ensure settings.conf.example is included except ValueError:
example_file = os.path.join(src_path, 'settings.conf.example') pass
if os.path.exists(example_file) and example_file not in files: elif 'config/scripts' in directory:
files.append(example_file) dest_dir = '/usr/share/fenrirscreenreader/scripts'
if files: # Only add if there are files to copy if dest_dir:
data_files.append((dest_dir, files)) data_files.append((dest_dir, files))
# Handle /usr/share/fenrirscreenreader directories # Handle sound files
share_dirs = { files = glob.glob('config/sound/default/*')
'scripts': '/usr/share/fenrirscreenreader/scripts', data_files.append(('/usr/share/sounds/fenrirscreenreader/default', files))
} files = glob.glob('config/sound/template/*')
data_files.append(('/usr/share/sounds/fenrirscreenreader/template', files))
for src_dir, dest_dir in share_dirs.items():
src_path = f'config/{src_dir}'
if os.path.exists(src_path):
files = glob.glob(f'{src_path}/*')
if files: # Only add if there are files to copy
data_files.append((dest_dir, files))
# Handle sound directory separately since it has subdirectories
sound_src = 'config/sound'
if os.path.exists(sound_src):
# Handle default sounds
default_files = glob.glob(f'{sound_src}/default/*')
if default_files:
data_files.append(('/usr/share/sounds/fenrirscreenreader/default', default_files))
# Handle template sounds
template_files = glob.glob(f'{sound_src}/template/*')
if template_files:
data_files.append(('/usr/share/sounds/fenrirscreenreader/template', template_files))
# Handle tools directory # Handle tools directory
tools_files = glob.glob('tools/*') files = glob.glob('tools/*')
if tools_files: data_files.append(('/usr/share/fenrirscreenreader/tools', files))
data_files.append(('/usr/share/fenrirscreenreader/tools', tools_files))
# Add man page # Add man page
if os.path.exists('docs/fenrir.1'):
data_files.append(('/usr/share/man/man1', ['docs/fenrir.1'])) data_files.append(('/usr/share/man/man1', ['docs/fenrir.1']))
return data_files return data_files
if __name__ == "__main__": if __name__ == "__main__":
setup(data_files=get_data_files()) setup(
data_files=get_data_files(),
)
# Post-install setup for settings.conf if needed force_settings = os.environ.get('FENRIR_FORCE_SETTINGS') == '1'
if not os.environ.get('FENRIR_FORCE_SETTINGS') == '1': if not force_settings:
settings_path = '/etc/fenrirscreenreader/settings/settings.conf' print('')
example_path = '/etc/fenrirscreenreader/settings/settings.conf.example' # create settings file from example if not exist
if not os.path.exists(settings_path) and os.path.exists(example_path): if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
try: try:
shutil.copyfile(example_path, settings_path) copyfile('/etc/fenrirscreenreader/settings/settings.conf.example',
print(f'Created settings file: {settings_path}') '/etc/fenrirscreenreader/settings/settings.conf')
except Exception as e: print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
print(f'Note: Could not create {settings_path}: {e}') except:
pass
else:
print('settings.conf file found. It is not overwritten automatically')
print('\nSetup complete!') print('')
print('To have Fenrir start at boot:') print('To have Fenrir start at boot:')
print('sudo systemctl enable fenrir') print('sudo systemctl enable fenrir')
print('Pulseaudio users may want to run:') print('Pulseaudio users may want to run:')
print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh') print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh')
print('once as their user account and once as root to configure Pulseaudio.') print('once as their user account and once as root to configure Pulseaudio.')
print('\nPlease install the following packages manually:') print('Please install the following packages manually:')
print('- Speech-dispatcher: for the default speech driver') print('- Speech-dispatcher: for the default speech driver')
print('- Espeak: as basic TTS engine') print('- Espeak: as basic TTS engine')
print('- sox: is a player for the generic sound driver') print('- sox: is a player for the generic sound driver')