forked from preble/pypinproc
-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
90 lines (75 loc) · 3.22 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
import os
from setuptools import setup, Extension
from subprocess import check_output, CalledProcessError, STDOUT
extra_compile_args = ['-O0', '-g']
extra_compile_args.append('-Wno-write-strings') # fix "warning: deprecated conversion from string constant to 'char*'"
extra_link_args = []
# To use the ARCH flag simply:
# ARCH=x86_64 python setup.py build
if 'ARCH' in os.environ:
extra_compile_args += ['-arch', os.environ['ARCH']]
extra_link_args += ['-arch', os.environ['ARCH']]
if os.name == 'nt':
# Windows
libraries = ['pinproc', 'libftd2xx']
else:
# Linux
libraries = ['libusb', 'libftdi1', 'pinproc']
def getstatusoutput(cmd):
try:
data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
status = 0
except CalledProcessError as ex:
data = ex.output
status = ex.returncode
if data[-1:] == '\n':
data = data[:-1]
return status, data
def pkgconfig(package, kw):
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
try:
output = check_output('pkg-config --cflags --libs {}'.format(package), shell=True, universal_newlines=True, stderr=STDOUT)
except CalledProcessError as ex:
raise AssertionError("Could not find lib {}: {}".format(package, ex.output))
for token in output.strip().split():
kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
return kw
kw = {}
for library in libraries:
kw = pkgconfig(library, kw)
module1 = Extension("pinproc",
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
sources=['pypinproc.cpp', 'dmdutil.cpp', 'dmd.c'],
**kw
)
setup(
name="pypinproc",
version="3.0",
description='Python wrapper for libpinproc',
long_description='''pypinproc is a native Python extension exposing the
libpinproc API to Python programs. pypinproc provides a low-level
interface for controlling a Multimorphic P-ROC or P3-ROC (http://www.pinballcontrollers.com/)
Pinball Remote Operations Controller from Python.
Note that Python wheels include libpinproc as well. Building manually
requires that you build and install libpinproc first.''',
url='http://www.pinballcontrollers.com/forum/index.php?board=10.0',
author='Adam Preble, Gerry Stellenberg, & the home brew pinball '
'community',
author_email='brian@missionpinball.com',
license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Topic :: Games/Entertainment :: Arcade',
'Topic :: System :: Hardware :: Hardware Drivers'
],
ext_modules=[module1])