Revert back to setup.py because it worked.

This commit is contained in:
Storm Dragon 2024-12-20 12:19:09 -05:00
parent 099d49d670
commit 9f57f7faec
2 changed files with 124 additions and 90 deletions

View File

@ -1,52 +0,0 @@
[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/*"]

150
setup.py
View File

@ -1,46 +1,132 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os #https://python-packaging.readthedocs.io/en/latest/minimal.html
import glob import os, glob, sys
import os.path
from shutil import copyfile
from setuptools import find_namespace_packages
from setuptools import setup from setuptools import setup
def get_data_files(): # handle flags for package manager like aurman and pacaur.
data_files = [] forceSettingsFlag = False
if "--force-settings" in sys.argv:
forceSettingsFlag = True
sys.argv.remove("--force-settings")
# Handle configuration files dataFiles = []
directories = glob.glob('config/*')
for directory in directories: # Handle locale files
localeFiles = glob.glob('locale/*/LC_MESSAGES/*.mo')
for localeFile in localeFiles:
lang = localeFile.split(os.sep)[1]
destDir = f'/usr/share/locale/{lang}/LC_MESSAGES'
dataFiles.append((destDir, [localeFile]))
# Handle other configuration files
directories = glob.glob('config/*')
for directory in directories:
files = glob.glob(directory+'/*') files = glob.glob(directory+'/*')
dest_dir = '' destDir = ''
if 'config/punctuation' in directory: if 'config/punctuation' in directory :
dest_dir = 'etc/fenrirscreenreader/punctuation' destDir = '/etc/fenrirscreenreader/punctuation'
elif 'config/keyboard' in directory: elif 'config/keyboard' in directory:
dest_dir = 'etc/fenrirscreenreader/keyboard' destDir = '/etc/fenrirscreenreader/keyboard'
elif 'config/settings' in directory: elif 'config/settings' in directory:
dest_dir = 'etc/fenrirscreenreader/settings' destDir = '/etc/fenrirscreenreader/settings'
if not forceSettingsFlag:
try:
del(files[files.index('config/settings/settings.conf')])
except:
pass
elif 'config/scripts' in directory: elif 'config/scripts' in directory:
dest_dir = 'usr/share/fenrirscreenreader/scripts' destDir = '/usr/share/fenrirscreenreader/scripts'
if dest_dir and files: if destDir != '':
data_files.append((dest_dir, files)) dataFiles.append((destDir, files))
# Handle sound files files = glob.glob('config/sound/default/*')
files = glob.glob('config/sound/default/*') destDir = '/usr/share/sounds/fenrirscreenreader/default'
if files: dataFiles.append((destDir, files))
data_files.append(('usr/share/sounds/fenrirscreenreader/default', 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']))
files = glob.glob('config/sound/template/*') def read(fname):
if files: return open(os.path.join(os.path.dirname(__file__), fname)).read()
data_files.append(('usr/share/sounds/fenrirscreenreader/template', files))
# Handle tools directory setup(
files = glob.glob('tools/*') # Application name:
if files: name="fenrir-screenreader",
data_files.append(('usr/share/fenrirscreenreader/tools', files)) # 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'),
long_description_content_type="text/markdown",
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/",
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",
],
# Add man page # Application author details:
if os.path.exists('docs/fenrir.1'): author="Storm Dragon, Jeremiah, Chrys and others",
data_files.append(('usr/share/man/man1', ['docs/fenrir.1'])) author_email="storm_dragon@stormux.org",
return data_files # Packages
package_dir={'': 'src'},
packages=find_namespace_packages(
where='src',
include=['fenrirscreenreader*']
),
scripts=['src/fenrir'],
if __name__ == "__main__": # Include additional files into the package
setup(data_files=get_data_files()) include_package_data=True,
zip_safe=False,
data_files=dataFiles,
# Dependent packages (distributions)
python_requires='>=3.6',
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('')
# 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 automatical')
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')