|
|
|
@ -22,10 +22,16 @@
|
|
|
|
|
import glob
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import pathlib
|
|
|
|
|
import subprocess
|
|
|
|
|
from os.path import basename, splitext, join
|
|
|
|
|
from setuptools import setup
|
|
|
|
|
from setuptools.command.install import install
|
|
|
|
|
from setuptools.command.build_ext import build_ext
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PO_FILES = 'po/*.po'
|
|
|
|
|
|
|
|
|
|
class Install(install):
|
|
|
|
|
"""Add the current commit hash to logger.py."""
|
|
|
|
|
def run(self):
|
|
|
|
@ -33,6 +39,8 @@ class Install(install):
|
|
|
|
|
if re.match(r'^([a-z]|[0-9])+$', commit):
|
|
|
|
|
with open('keymapper/commit_hash.py', 'w') as f:
|
|
|
|
|
f.write(f"COMMIT_HASH = '{commit}'\n")
|
|
|
|
|
# generate .mo files
|
|
|
|
|
make_lang()
|
|
|
|
|
|
|
|
|
|
install.run(self)
|
|
|
|
|
|
|
|
|
@ -55,6 +63,25 @@ def get_packages():
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_lang():
|
|
|
|
|
mo_files = []
|
|
|
|
|
prefix = 'keymapper'
|
|
|
|
|
os.makedirs('mo', exist_ok=True)
|
|
|
|
|
|
|
|
|
|
for po_file in glob.glob(PO_FILES):
|
|
|
|
|
lang = splitext(basename(po_file))[0]
|
|
|
|
|
os.makedirs(join('mo', lang), exist_ok=True)
|
|
|
|
|
print(f'generating translation for {lang}')
|
|
|
|
|
subprocess.run(['msgfmt', '-o', join('mo', lang, 'key-mapper.mo'), str(po_file)], check=True)
|
|
|
|
|
|
|
|
|
|
lang_data = []
|
|
|
|
|
for po_file in glob.glob(PO_FILES):
|
|
|
|
|
lang = splitext(basename(po_file))[0]
|
|
|
|
|
lang_data.append((
|
|
|
|
|
f'/usr/share/key-mapper/lang/{lang}/LC_MESSAGES',
|
|
|
|
|
[f'mo/{lang}/key-mapper.mo']
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
|
name='key-mapper',
|
|
|
|
|
version='1.0.0',
|
|
|
|
@ -64,8 +91,10 @@ setup(
|
|
|
|
|
url='https://github.com/sezanzeb/key-mapper',
|
|
|
|
|
license='GPL-3.0',
|
|
|
|
|
packages=get_packages(),
|
|
|
|
|
include_package_data = True,
|
|
|
|
|
data_files=[
|
|
|
|
|
# see development.md#files
|
|
|
|
|
*lang_data,
|
|
|
|
|
('/usr/share/key-mapper/', glob.glob('data/*')),
|
|
|
|
|
('/usr/share/applications/', ['data/key-mapper.desktop']),
|
|
|
|
|
('/usr/share/polkit-1/actions/', ['data/key-mapper.policy']),
|
|
|
|
|