|
|
@ -28,23 +28,24 @@ from setuptools import setup
|
|
|
|
from setuptools.command.install import install
|
|
|
|
from setuptools.command.install import install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PO_FILES = 'po/*.po'
|
|
|
|
PO_FILES = "po/*.po"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Install(install):
|
|
|
|
class Install(install):
|
|
|
|
"""Add the commit hash and build .mo translations."""
|
|
|
|
"""Add the commit hash and build .mo translations."""
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
commit = os.popen('git rev-parse HEAD').read().strip()
|
|
|
|
commit = os.popen("git rev-parse HEAD").read().strip()
|
|
|
|
if re.match(r'^([a-z]|[0-9])+$', commit):
|
|
|
|
if re.match(r"^([a-z]|[0-9])+$", commit):
|
|
|
|
# for whatever reason different systems have different paths here
|
|
|
|
# for whatever reason different systems have different paths here
|
|
|
|
build_dir = ''
|
|
|
|
build_dir = ""
|
|
|
|
if os.path.exists('build/lib/keymapper'):
|
|
|
|
if os.path.exists("build/lib/keymapper"):
|
|
|
|
build_dir = 'build/lib/'
|
|
|
|
build_dir = "build/lib/"
|
|
|
|
with open(f'{build_dir}keymapper/commit_hash.py', 'w+') as f:
|
|
|
|
with open(f"{build_dir}keymapper/commit_hash.py", "w+") as f:
|
|
|
|
f.write(f"COMMIT_HASH = '{commit}'\n")
|
|
|
|
f.write(f"COMMIT_HASH = '{commit}'\n")
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
print('Failed to save the commit hash:', e)
|
|
|
|
print("Failed to save the commit hash:", e)
|
|
|
|
|
|
|
|
|
|
|
|
# generate .mo files
|
|
|
|
# generate .mo files
|
|
|
|
make_lang()
|
|
|
|
make_lang()
|
|
|
@ -52,21 +53,21 @@ class Install(install):
|
|
|
|
install.run(self)
|
|
|
|
install.run(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_packages(base='keymapper'):
|
|
|
|
def get_packages(base="keymapper"):
|
|
|
|
"""Return all modules used in key-mapper.
|
|
|
|
"""Return all modules used in key-mapper.
|
|
|
|
|
|
|
|
|
|
|
|
For example 'keymapper.gui' or 'keymapper.injection.consumers'
|
|
|
|
For example 'keymapper.gui' or 'keymapper.injection.consumers'
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if not os.path.exists(os.path.join(base, '__init__.py')):
|
|
|
|
if not os.path.exists(os.path.join(base, "__init__.py")):
|
|
|
|
# only python modules
|
|
|
|
# only python modules
|
|
|
|
return []
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
result = [base.replace('/', '.')]
|
|
|
|
result = [base.replace("/", ".")]
|
|
|
|
for name in os.listdir(base):
|
|
|
|
for name in os.listdir(base):
|
|
|
|
if not os.path.isdir(os.path.join(base, name)):
|
|
|
|
if not os.path.isdir(os.path.join(base, name)):
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
if name == '__pycache__':
|
|
|
|
if name == "__pycache__":
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
# find more python submodules in that directory
|
|
|
|
# find more python submodules in that directory
|
|
|
@ -77,55 +78,57 @@ def get_packages(base='keymapper'):
|
|
|
|
|
|
|
|
|
|
|
|
def make_lang():
|
|
|
|
def make_lang():
|
|
|
|
"""Build po files into mo/."""
|
|
|
|
"""Build po files into mo/."""
|
|
|
|
os.makedirs('mo', exist_ok=True)
|
|
|
|
os.makedirs("mo", exist_ok=True)
|
|
|
|
for po_file in glob.glob(PO_FILES):
|
|
|
|
for po_file in glob.glob(PO_FILES):
|
|
|
|
lang = splitext(basename(po_file))[0]
|
|
|
|
lang = splitext(basename(po_file))[0]
|
|
|
|
os.makedirs(join('mo', lang), exist_ok=True)
|
|
|
|
os.makedirs(join("mo", lang), exist_ok=True)
|
|
|
|
print(f'generating translation for {lang}')
|
|
|
|
print(f"generating translation for {lang}")
|
|
|
|
subprocess.run(['msgfmt', '-o', join('mo', lang, 'key-mapper.mo'), str(po_file)], check=True)
|
|
|
|
subprocess.run(
|
|
|
|
|
|
|
|
["msgfmt", "-o", join("mo", lang, "key-mapper.mo"), str(po_file)],
|
|
|
|
|
|
|
|
check=True,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lang_data = []
|
|
|
|
lang_data = []
|
|
|
|
for po_file in glob.glob(PO_FILES):
|
|
|
|
for po_file in glob.glob(PO_FILES):
|
|
|
|
lang = splitext(basename(po_file))[0]
|
|
|
|
lang = splitext(basename(po_file))[0]
|
|
|
|
lang_data.append((
|
|
|
|
lang_data.append(
|
|
|
|
f'/usr/share/key-mapper/lang/{lang}/LC_MESSAGES',
|
|
|
|
(f"/usr/share/key-mapper/lang/{lang}/LC_MESSAGES", [f"mo/{lang}/key-mapper.mo"])
|
|
|
|
[f'mo/{lang}/key-mapper.mo']
|
|
|
|
)
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
setup(
|
|
|
|
name='key-mapper',
|
|
|
|
name="key-mapper",
|
|
|
|
version='1.2.1',
|
|
|
|
version="1.2.1",
|
|
|
|
description='A tool to change the mapping of your input device buttons',
|
|
|
|
description="A tool to change the mapping of your input device buttons",
|
|
|
|
author='Sezanzeb',
|
|
|
|
author="Sezanzeb",
|
|
|
|
author_email='proxima@sezanzeb.de',
|
|
|
|
author_email="proxima@sezanzeb.de",
|
|
|
|
url='https://github.com/sezanzeb/key-mapper',
|
|
|
|
url="https://github.com/sezanzeb/key-mapper",
|
|
|
|
license='GPL-3.0',
|
|
|
|
license="GPL-3.0",
|
|
|
|
packages=get_packages(),
|
|
|
|
packages=get_packages(),
|
|
|
|
include_package_data=True,
|
|
|
|
include_package_data=True,
|
|
|
|
data_files=[
|
|
|
|
data_files=[
|
|
|
|
# see development.md#files
|
|
|
|
# see development.md#files
|
|
|
|
*lang_data,
|
|
|
|
*lang_data,
|
|
|
|
('/usr/share/key-mapper/', glob.glob('data/*')),
|
|
|
|
("/usr/share/key-mapper/", glob.glob("data/*")),
|
|
|
|
('/usr/share/applications/', ['data/key-mapper.desktop']),
|
|
|
|
("/usr/share/applications/", ["data/key-mapper.desktop"]),
|
|
|
|
('/usr/share/polkit-1/actions/', ['data/key-mapper.policy']),
|
|
|
|
("/usr/share/polkit-1/actions/", ["data/key-mapper.policy"]),
|
|
|
|
('/usr/lib/systemd/system', ['data/key-mapper.service']),
|
|
|
|
("/usr/lib/systemd/system", ["data/key-mapper.service"]),
|
|
|
|
('/etc/dbus-1/system.d/', ['data/keymapper.Control.conf']),
|
|
|
|
("/etc/dbus-1/system.d/", ["data/keymapper.Control.conf"]),
|
|
|
|
('/etc/xdg/autostart/', ['data/key-mapper-autoload.desktop']),
|
|
|
|
("/etc/xdg/autostart/", ["data/key-mapper-autoload.desktop"]),
|
|
|
|
('/usr/lib/udev/rules.d', ['data/99-key-mapper.rules']),
|
|
|
|
("/usr/lib/udev/rules.d", ["data/99-key-mapper.rules"]),
|
|
|
|
('/usr/bin/', ['bin/key-mapper-gtk']),
|
|
|
|
("/usr/bin/", ["bin/key-mapper-gtk"]),
|
|
|
|
('/usr/bin/', ['bin/key-mapper-service']),
|
|
|
|
("/usr/bin/", ["bin/key-mapper-service"]),
|
|
|
|
('/usr/bin/', ['bin/key-mapper-control']),
|
|
|
|
("/usr/bin/", ["bin/key-mapper-control"]),
|
|
|
|
('/usr/bin/', ['bin/key-mapper-helper']),
|
|
|
|
("/usr/bin/", ["bin/key-mapper-helper"]),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
install_requires=[
|
|
|
|
install_requires=[
|
|
|
|
'setuptools',
|
|
|
|
"setuptools",
|
|
|
|
'evdev',
|
|
|
|
"evdev",
|
|
|
|
'pydbus',
|
|
|
|
"pydbus",
|
|
|
|
'pygobject',
|
|
|
|
"pygobject",
|
|
|
|
],
|
|
|
|
],
|
|
|
|
cmdclass={
|
|
|
|
cmdclass={
|
|
|
|
'install': Install,
|
|
|
|
"install": Install,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|