| 1 |
#!/usr/bin/env python3 |
| 2 |
import os, glob, sys |
| 3 |
import os.path |
| 4 |
from shutil import copyfile |
| 5 |
from setuptools import find_namespace_packages |
| 6 |
from setuptools import setup |
| 7 |
|
| 8 |
# handle flags for package manager like aurman and pacaur. |
| 9 |
# Allow both environment variable and command line flag |
| 10 |
forceSettingsFlag = ( |
| 11 |
"--force-settings" in sys.argv or |
| 12 |
os.environ.get('FENRIR_FORCE_SETTINGS') == '1' |
| 13 |
) |
| 14 |
if "--force-settings" in sys.argv: |
| 15 |
sys.argv.remove("--force-settings") |
| 16 |
|
| 17 |
dataFiles = [] |
| 18 |
|
| 19 |
# Handle locale files |
| 20 |
localeFiles = glob.glob('locale/*/LC_MESSAGES/*.mo') |
| 21 |
for localeFile in localeFiles: |
| 22 |
lang = localeFile.split(os.sep)[1] |
| 23 |
destDir = f'/usr/share/locale/{lang}/LC_MESSAGES' |
| 24 |
dataFiles.append((destDir, [localeFile])) |
| 25 |
|
| 26 |
# Handle other configuration files |
| 27 |
directories = glob.glob('config/*') |
| 28 |
for directory in directories: |
| 29 |
files = glob.glob(directory+'/*') |
| 30 |
destDir = '' |
| 31 |
if 'config/punctuation' in directory : |
| 32 |
destDir = '/etc/fenrirscreenreader/punctuation' |
| 33 |
elif 'config/keyboard' in directory: |
| 34 |
destDir = '/etc/fenrirscreenreader/keyboard' |
| 35 |
elif 'config/settings' in directory: |
| 36 |
destDir = '/etc/fenrirscreenreader/settings' |
| 37 |
if not forceSettingsFlag: |
| 38 |
try: |
| 39 |
files = [f for f in files if not f.endswith('settings.conf')] |
| 40 |
except Exception as e: |
| 41 |
pass |
| 42 |
elif 'config/scripts' in directory: |
| 43 |
destDir = '/usr/share/fenrirscreenreader/scripts' |
| 44 |
if destDir != '': |
| 45 |
dataFiles.append((destDir, files)) |
| 46 |
|
| 47 |
files = glob.glob('config/sound/default/*') |
| 48 |
destDir = '/usr/share/sounds/fenrirscreenreader/default' |
| 49 |
dataFiles.append((destDir, files)) |
| 50 |
files = glob.glob('config/sound//template/*') |
| 51 |
destDir = '/usr/share/sounds/fenrirscreenreader/template' |
| 52 |
dataFiles.append((destDir, files)) |
| 53 |
files = glob.glob('tools/*') |
| 54 |
dataFiles.append(('/usr/share/fenrirscreenreader/tools', files)) |
| 55 |
dataFiles.append(('/usr/share/man/man1', ['docs/fenrir.1'])) |
| 56 |
|
| 57 |
def read(fname): |
| 58 |
return open(os.path.join(os.path.dirname(__file__), fname)).read() |
| 59 |
|
| 60 |
setup( |
| 61 |
# Application name: |
| 62 |
name="fenrir-screenreader", |
| 63 |
# description |
| 64 |
description="A TTY Screen Reader for Linux.", |
| 65 |
long_description=read('README.md'), |
| 66 |
long_description_content_type="text/markdown", |
| 67 |
keywords=['screenreader', 'a11y', 'accessibility', 'terminal', 'TTY', 'console'], |
| 68 |
license="License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", |
| 69 |
url="https://git.stormux.org/storm/fenrir/", |
| 70 |
classifiers=[ |
| 71 |
"Programming Language :: Python", |
| 72 |
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", |
| 73 |
"Development Status :: 5 - Production/Stable", |
| 74 |
"Topic :: Multimedia :: Sound/Audio :: Speech", |
| 75 |
"Environment :: Console", |
| 76 |
], |
| 77 |
|
| 78 |
# Application author details: |
| 79 |
author="Storm Dragon, Jeremiah, Chrys and others", |
| 80 |
author_email="[email protected]", |
| 81 |
|
| 82 |
# Packages |
| 83 |
package_dir={'': 'src'}, |
| 84 |
packages=find_namespace_packages( |
| 85 |
where='src', |
| 86 |
include=['fenrirscreenreader*'] |
| 87 |
), |
| 88 |
scripts=['src/fenrir'], |
| 89 |
|
| 90 |
# Include additional files into the package |
| 91 |
include_package_data=True, |
| 92 |
zip_safe=False, |
| 93 |
|
| 94 |
data_files=dataFiles, |
| 95 |
|
| 96 |
# Dependent packages (distributions) |
| 97 |
python_requires='>=3.6', |
| 98 |
install_requires=[ |
| 99 |
"evdev>=1.1.2", |
| 100 |
"daemonize>=2.5.0", |
| 101 |
"dbus-python>=1.2.8", |
| 102 |
"pyperclip", |
| 103 |
"pyudev>=0.21.0", |
| 104 |
"setuptools", |
| 105 |
"setproctitle", |
| 106 |
"pyte>=0.7.0", |
| 107 |
], |
| 108 |
extras_require={ |
| 109 |
"dectalk_usb": ["pyusb>=1.2.1"], |
| 110 |
"x11": ["python-xlib>=0.33"], |
| 111 |
}, |
| 112 |
) |
| 113 |
|
| 114 |
if not forceSettingsFlag: |
| 115 |
print('') |
| 116 |
# create settings file from example if not exist |
| 117 |
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'): |
| 118 |
try: |
| 119 |
copyfile('config/fenrirscreenreader/settings/settings.conf', '/etc/fenrirscreenreader/settings/settings.conf') |
| 120 |
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf') |
| 121 |
except OSError as e: |
| 122 |
print(f"Could not copy settings file to destination: {e}") |
| 123 |
else: |
| 124 |
print('settings.conf file found. It is not overwritten automatical') |
| 125 |
|
| 126 |
print('') |
| 127 |
print('To have Fenrir start at boot:') |
| 128 |
print('sudo systemctl enable fenrir') |
| 129 |
print('Pulseaudio users may want to run:') |
| 130 |
print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh') |
| 131 |
print('once as their user account and once as root to configure Pulseaudio.') |
| 132 |
print('Please install the following packages manually:') |
| 133 |
print('- Speech-dispatcher: for the default speech driver') |
| 134 |
print('- Espeak: as basic TTS engine') |
| 135 |
print('- sox: is a player for the generic sound driver') |