input-remapper/setup.py

98 lines
3.0 KiB
Python
Raw Normal View History

2020-10-26 22:45:22 +00:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# key-mapper - GUI for device specific keyboard mappings
2021-02-22 18:48:20 +00:00
# Copyright (C) 2021 sezanzeb <proxima@sezanzeb.de>
2020-10-26 22:45:22 +00:00
#
2020-10-31 13:02:59 +00:00
# This file is part of key-mapper.
2020-10-26 22:45:22 +00:00
#
2020-10-31 13:02:59 +00:00
# key-mapper is free software: you can redistribute it and/or modify
2020-10-26 22:45:22 +00:00
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
2020-10-31 13:02:59 +00:00
# key-mapper is distributed in the hope that it will be useful,
2020-10-26 22:45:22 +00:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
2020-10-31 13:02:59 +00:00
# along with key-mapper. If not, see <https://www.gnu.org/licenses/>.
2020-10-26 22:45:22 +00:00
2020-11-29 09:42:20 +00:00
import glob
2021-01-31 14:09:47 +00:00
import os
import re
2020-11-29 09:42:20 +00:00
from setuptools import setup
2021-01-31 14:09:47 +00:00
from setuptools.command.install import install
class Install(install):
"""Add the current commit hash to logger.py."""
def run(self):
2021-01-31 14:23:02 +00:00
commit = os.popen('git rev-parse HEAD').read().strip()
2021-01-31 14:09:47 +00:00
if re.match(r'^([a-z]|[0-9])+$', commit):
with open('keymapper/logger.py', 'r') as f:
contents = f.read()
2021-02-07 14:00:36 +00:00
contents = re.sub(
r"COMMIT_HASH = '.*?'",
2021-02-07 14:00:36 +00:00
f"COMMIT_HASH = '{commit}'",
contents
2021-01-31 14:09:47 +00:00
)
with open('keymapper/logger.py', 'w') as f:
f.write(contents)
install.run(self)
2020-10-26 22:45:22 +00:00
2021-03-21 18:15:20 +00:00
def get_packages():
"""Return all modules used in key-mapper.
For example 'keymapper.gui'.
"""
result = ['keymapper']
for name in os.listdir('keymapper'):
if not os.path.isdir(f'keymapper/{name}'):
continue
if name == '__pycache__':
continue
result.append(f'keymapper.{name}')
return result
2020-11-29 09:42:20 +00:00
setup(
name='key-mapper',
2021-03-27 17:18:38 +00:00
version='0.8.0',
2020-11-29 09:42:20 +00:00
description='A tool to change the mapping of your input device buttons',
author='Sezanzeb',
2021-02-22 18:48:20 +00:00
author_email='proxima@sezanzeb.de',
2020-11-29 09:42:20 +00:00
url='https://github.com/sezanzeb/key-mapper',
2020-10-26 22:45:22 +00:00
license='GPL-3.0',
2021-03-21 18:15:20 +00:00
packages=get_packages(),
2020-10-26 22:45:22 +00:00
data_files=[
2020-12-25 14:39:04 +00:00
# see development.md#files
2020-11-29 12:30:16 +00:00
('/usr/share/key-mapper/', glob.glob('data/*')),
('/usr/share/applications/', ['data/key-mapper.desktop']),
('/usr/share/polkit-1/actions/', ['data/key-mapper.policy']),
('/usr/lib/systemd/system', ['data/key-mapper.service']),
('/etc/dbus-1/system.d/', ['data/keymapper.Control.conf']),
('/etc/xdg/autostart/', ['data/key-mapper-autoload.desktop']),
2021-02-07 14:00:36 +00:00
('/etc/udev/rules.d', ['data/key-mapper.rules']),
2020-11-29 12:30:16 +00:00
('/usr/bin/', ['bin/key-mapper-gtk']),
('/usr/bin/', ['bin/key-mapper-service']),
('/usr/bin/', ['bin/key-mapper-control']),
2021-03-21 18:15:20 +00:00
('/usr/bin/', ['bin/key-mapper-helper']),
2020-11-29 09:42:20 +00:00
],
2020-11-29 13:19:32 +00:00
install_requires=[
'setuptools',
'evdev',
'pydbus'
],
2021-01-31 14:09:47 +00:00
cmdclass={
'install': Install,
},
2020-10-26 22:45:22 +00:00
)