-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
116 lines (94 loc) · 4.04 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#
# uchroma - Copyright (C) 2021 Stefanie Kondik
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
#
import os
import re
from pydoc import locate
from setuptools import command, setup, Extension
from setuptools.command.install import install
from setuptools.dist import Distribution
RAZER_VENDOR_ID = 0x1532
# Make sure Cython is installed first
Distribution(dict(setup_requires=['cython>=0.24', 'numpy']))
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import numpy as np
# Read the version file (since we can't import it yet)
def get_version():
module_init = 'uchroma/version.py'
if not os.path.isfile(module_init):
module_init = '../' + module_init
if not os.path.isfile(module_init):
raise ValueError('Unable to determine version!')
return re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
open(module_init).read()).group(1)
# Generates the HWDB file for use with our udev rule. This is done
# by loading the YAML descriptors via the Hardware API
class HWDBGenerator(install):
@staticmethod
def generate():
hw = locate('uchroma.server.Hardware')
assert hw is not None
hwdb = ""
for hw_type in hw.Type:
for model in hw.get_type(hw_type):
hwdb += ('uchroma:usb:v%04Xp%04X*\n'
' UCHROMA_DEVICE=%s\n\n'
% (model.vendor_id, model.product_id, model.type.name.lower()))
return hwdb
def run(self):
print(HWDBGenerator.generate())
# Cython
extensions = [
Extension('uchroma.server._crc', ['uchroma/server/_crc.pyx'], include_dirs=[np.get_include()]),
Extension('uchroma._layer', ['uchroma/_layer.pyx'], include_dirs=[np.get_include()]),
Extension('uchroma.fxlib._plasma', ['uchroma/fxlib/_plasma.pyx'], include_dirs=[np.get_include()], extra_compile_args=['-O3'])]
for e in extensions:
e.cython_directives = {'embedsignature': True}
setup(name='uchroma',
version=get_version(),
description='Color control for Razer Chroma peripherals',
url='https://github.com/cyanogen/uchroma',
author='Stefanie Kondik',
author_email='shade@chemlab.org',
license='LGPL',
platform='Linux',
packages=['uchroma', 'uchroma.fxlib', 'uchroma.client', 'uchroma.server'],
ext_modules = extensions,
entry_points={
'console_scripts': [
'uchroma = uchroma.client.client:run_client',
'uchromad = uchroma.server.server:run_server'
],
'uchroma.plugins': ['renderers = uchroma.fxlib']
},
install_requires=['argcomplete', 'cffi', 'colorlog', 'colr', 'evdev',
'frozendict', 'gbulb', 'grapefruit', 'hidapi-cffi',
'hsluv', 'matplotlib', 'numpy', 'pydbus', 'pyudev',
'ruamel.yaml', 'scikit-image', 'scipy', 'traitlets', 'wrapt'],
cmdclass={'hwdb': HWDBGenerator, 'build_ext': build_ext},
keywords='razer chroma uchroma driver keyboard mouse',
include_package_data=True,
setup_requires=['setuptools>=18.0', 'pytest-runner'],
tests_require=['pytest'],
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3 :: Only',
'Topic :: System :: Hardware :: Hardware Drivers'
])