Modernize installation.
This commit is contained in:
parent
55ce73322b
commit
d6a9332f80
52
pyproject.toml
Normal file
52
pyproject.toml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64.0.0", "wheel", "setuptools_scm[toml]>=6.2"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "fenrir-screenreader"
|
||||||
|
dynamic = ["version"]
|
||||||
|
description = "A TTY Screen Reader for Linux"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
license = {text = "GNU General Public License v3 or later (GPLv3+)"}
|
||||||
|
keywords = ["screenreader", "a11y", "accessibility", "terminal", "TTY", "console"]
|
||||||
|
authors = [
|
||||||
|
{name = "Storm Dragon, Jeremiah, Chrys and others", email = "storm_dragon@stormux.org"}
|
||||||
|
]
|
||||||
|
classifiers = [
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
|
||||||
|
"Development Status :: 5 - Production/Stable",
|
||||||
|
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
||||||
|
"Environment :: Console",
|
||||||
|
]
|
||||||
|
dependencies = [
|
||||||
|
"evdev>=1.1.2",
|
||||||
|
"daemonize>=2.5.0",
|
||||||
|
"dbus-python>=1.2.8",
|
||||||
|
"pyudev>=0.21.0",
|
||||||
|
"setuptools",
|
||||||
|
"pexpect",
|
||||||
|
"pyttsx3",
|
||||||
|
"pyte>=0.7.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://git.stormux.org/storm/fenrir/"
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
package-dir = {"" = "src"}
|
||||||
|
include-package-data = true
|
||||||
|
zip-safe = false
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
where = ["src"]
|
||||||
|
include = ["fenrirscreenreader*"]
|
||||||
|
namespaces = true
|
||||||
|
|
||||||
|
[tool.setuptools_scm]
|
||||||
|
write_to = "src/fenrirscreenreader/_version.py"
|
||||||
|
|
||||||
|
[tool.setuptools.data-files]
|
||||||
|
"usr/share/man/man1" = ["docs/fenrir.1"]
|
||||||
|
"usr/share/fenrirscreenreader/tools" = ["tools/*"]
|
183
setup.py
183
setup.py
@ -1,128 +1,81 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#https://python-packaging.readthedocs.io/en/latest/minimal.html
|
import os
|
||||||
import os, glob, sys
|
import sys
|
||||||
import os.path
|
import glob
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from setuptools import find_packages
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
# handle flags for package manager like aurman and pacaur.
|
def get_data_files(force_settings=False):
|
||||||
forceSettingsFlag = False
|
data_files = []
|
||||||
if "--force-settings" in sys.argv:
|
|
||||||
forceSettingsFlag = True
|
|
||||||
sys.argv.remove("--force-settings")
|
|
||||||
|
|
||||||
dataFiles = []
|
# 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 locale files
|
# Handle configuration files
|
||||||
localeFiles = glob.glob('locale/*/LC_MESSAGES/*.mo')
|
directories = glob.glob('config/*')
|
||||||
for localeFile in localeFiles:
|
for directory in directories:
|
||||||
lang = localeFile.split(os.sep)[1]
|
files = glob.glob(directory+'/*')
|
||||||
destDir = f'/usr/share/locale/{lang}/LC_MESSAGES'
|
dest_dir = ''
|
||||||
dataFiles.append((destDir, [localeFile]))
|
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 other configuration files
|
# Handle sound files
|
||||||
directories = glob.glob('config/*')
|
files = glob.glob('config/sound/default/*')
|
||||||
for directory in directories:
|
data_files.append(('/usr/share/sounds/fenrirscreenreader/default', files))
|
||||||
files = glob.glob(directory+'/*')
|
files = glob.glob('config/sound/template/*')
|
||||||
destDir = ''
|
data_files.append(('/usr/share/sounds/fenrirscreenreader/template', files))
|
||||||
if 'config/punctuation' in directory :
|
|
||||||
destDir = '/etc/fenrirscreenreader/punctuation'
|
return data_files
|
||||||
elif 'config/keyboard' in directory:
|
|
||||||
destDir = '/etc/fenrirscreenreader/keyboard'
|
def post_install_actions():
|
||||||
elif 'config/settings' in directory:
|
if '--force-settings' not in sys.argv:
|
||||||
destDir = '/etc/fenrirscreenreader/settings'
|
print('')
|
||||||
if not forceSettingsFlag:
|
# create settings file from example if not exist
|
||||||
|
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
|
||||||
try:
|
try:
|
||||||
del(files[files.index('config/settings/settings.conf')])
|
copyfile('/etc/fenrirscreenreader/settings/settings.conf.example',
|
||||||
|
'/etc/fenrirscreenreader/settings/settings.conf')
|
||||||
|
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
elif 'config/scripts' in directory:
|
else:
|
||||||
destDir = '/usr/share/fenrirscreenreader/scripts'
|
print('settings.conf file found. It is not overwritten automatically')
|
||||||
if destDir != '':
|
|
||||||
dataFiles.append((destDir, files))
|
|
||||||
|
|
||||||
files = glob.glob('config/sound/default/*')
|
|
||||||
destDir = '/usr/share/sounds/fenrirscreenreader/default'
|
|
||||||
dataFiles.append((destDir, files))
|
|
||||||
files = glob.glob('config/sound//template/*')
|
|
||||||
destDir = '/usr/share/sounds/fenrirscreenreader/template'
|
|
||||||
dataFiles.append((destDir, files))
|
|
||||||
files = glob.glob('tools/*')
|
|
||||||
dataFiles.append(('/usr/share/fenrirscreenreader/tools', files))
|
|
||||||
dataFiles.append(('/usr/share/man/man1', ['docs/fenrir.1']))
|
|
||||||
|
|
||||||
def read(fname):
|
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
|
||||||
|
|
||||||
setup(
|
|
||||||
# Application name:
|
|
||||||
name="fenrir-screenreader",
|
|
||||||
# Version is now handled by setuptools_scm
|
|
||||||
use_scm_version=True,
|
|
||||||
setup_requires=['setuptools_scm'],
|
|
||||||
# description
|
|
||||||
description="A TTY Screen Reader for Linux.",
|
|
||||||
long_description=read('README.md'),
|
|
||||||
keywords=['screenreader', 'a11y', 'accessibility', 'terminal', 'TTY', 'console'],
|
|
||||||
license="License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
|
||||||
url="https://git.stormux.org/storm/fenrir/",
|
|
||||||
# Remove download_url as it contained hardcoded version
|
|
||||||
classifiers=[
|
|
||||||
"Programming Language :: Python",
|
|
||||||
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
|
|
||||||
"Development Status :: 5 - Production/Stable",
|
|
||||||
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
||||||
"Environment :: Console",
|
|
||||||
],
|
|
||||||
|
|
||||||
# Application author details:
|
|
||||||
author="Storm Dragon, Jeremiah, Chrys and others",
|
|
||||||
author_email="storm_dragon@stormux.org",
|
|
||||||
|
|
||||||
# Packages
|
|
||||||
packages=find_packages('src/'),
|
|
||||||
package_dir={'': 'src/'},
|
|
||||||
scripts=['src/fenrir'],
|
|
||||||
|
|
||||||
# Include additional files into the package
|
|
||||||
include_package_data=True,
|
|
||||||
zip_safe=False,
|
|
||||||
|
|
||||||
data_files=dataFiles,
|
|
||||||
|
|
||||||
# Dependent packages (distributions)
|
|
||||||
install_requires=[
|
|
||||||
"evdev>=1.1.2",
|
|
||||||
"daemonize>=2.5.0",
|
|
||||||
"dbus-python>=1.2.8",
|
|
||||||
"pyudev>=0.21.0",
|
|
||||||
"setuptools",
|
|
||||||
"pexpect",
|
|
||||||
"pyttsx3",
|
|
||||||
"pyte>=0.7.0",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
if not forceSettingsFlag:
|
|
||||||
print('')
|
print('')
|
||||||
# create settings file from example if not exist
|
print('To have Fenrir start at boot:')
|
||||||
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
|
print('sudo systemctl enable fenrir')
|
||||||
try:
|
print('Pulseaudio users may want to run:')
|
||||||
copyfile('/etc/fenrirscreenreader/settings/settings.conf.example', '/etc/fenrirscreenreader/settings/settings.conf')
|
print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh')
|
||||||
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
|
print('once as their user account and once as root to configure Pulseaudio.')
|
||||||
except:
|
print('Please install the following packages manually:')
|
||||||
pass
|
print('- Speech-dispatcher: for the default speech driver')
|
||||||
else:
|
print('- Espeak: as basic TTS engine')
|
||||||
print('settings.conf file found. It is not overwritten automatical')
|
print('- sox: is a player for the generic sound driver')
|
||||||
|
|
||||||
print('')
|
if __name__ == "__main__":
|
||||||
print('To have Fenrir start at boot:')
|
force_settings = '--force-settings' in sys.argv
|
||||||
print('sudo systemctl enable fenrir')
|
if force_settings:
|
||||||
print('Pulseaudio users may want to run:')
|
sys.argv.remove('--force-settings')
|
||||||
print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh')
|
|
||||||
print('once as their user account and once as root to configure Pulseaudio.')
|
setup(
|
||||||
print('Please install the following packages manually:')
|
data_files=get_data_files(force_settings),
|
||||||
print('- Speech-dispatcher: for the default speech driver')
|
)
|
||||||
print('- Espeak: as basic TTS engine')
|
|
||||||
print('- sox: is a player for the generic sound driver')
|
post_install_actions()
|
||||||
|
Loading…
Reference in New Issue
Block a user