forked from ponty/pysimavr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
156 lines (138 loc) · 4.68 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from setuptools import setup
from setuptools.extension import Extension
import fnmatch
import os.path
import sys
if os.environ.get('distutils_issue8876_workaround_enabled', False):
# sdist_hack: Remove reference to os.link to disable using hardlinks when
# building setup.py's sdist target. This is done because
# VirtualBox VMs shared filesystems don't support hardlinks.
del os.link
NAME = 'pysimavr'
URL = 'https://github.com/ponty/pysimavr'
DESCRIPTION = 'python wrapper for simavr which is AVR and arduino simulator.'
PACKAGES = [NAME,
NAME + '.swig',
NAME + '.examples',
]
# get __version__
__version__ = None
exec(open(os.path.join(NAME, 'about.py')).read())
VERSION = __version__
extra = {}
if sys.version_info >= (3,):
extra['use_2to3'] = True
classifiers = [
# Get more strings from
# http://www.python.org/pypi?%3Aaction=list_classifiers
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
'Programming Language :: Python',
'Programming Language :: Python :: 2',
# "Programming Language :: Python :: 2.3",
# "Programming Language :: Python :: 2.4",
#"Programming Language :: Python :: 2.5",
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
# "Programming Language :: Python :: 2 :: Only",
"Programming Language :: Python :: 3",
# 'Programming Language :: Python :: 3.0',
# "Programming Language :: Python :: 3.1",
# 'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
]
install_requires = open("requirements.txt").read().split('\n')
SWIG = 'pysimavr/swig'
SIMAVR = SWIG + '/simavr' # simavr path
SIM = SIMAVR + '/simavr/sim'
CORES = SIMAVR + '/simavr/cores'
INCLUDE_SIMAVR = SIMAVR + '/simavr'
INCLUDE_AVR = SWIG + '/include'
PARTS = SWIG + '/parts'
EXCLUDE = ['sim_mega324.c', 'sim_mega128rfr2.c']
def listdir(directory, pattern):
names = os.listdir(directory)
names = fnmatch.filter(names, pattern)
return [os.path.join(directory, child) for child in names]
def files(directory, pattern, exclude=[]):
return [p for p in listdir(directory, pattern) if os.path.isfile(p) and os.path.basename(p) not in exclude]
def part(name):
return Extension(name='pysimavr.swig._' + name,
sources=[
PARTS + '/' + name + '.c',
# SWIG + '/' + name + '.i',
SWIG + '/' + name + '_wrap.c',
# 'pysimavr/swig/sim/sim_cycle_timers.c',
# 'pysimavr/swig/sim/sim_irq.c',
# 'pysimavr/swig/sim/sim_io.c',
],
libraries=['elf'],
include_dirs=[
SIM,
INCLUDE_SIMAVR, INCLUDE_AVR,
PARTS,
],
# swig_opts=[
# # '-modern',
# '-I' + PARTS,
# '-I' + SIM,
# ],
extra_compile_args=[
'--std=gnu99',
],
)
ext_modules = [
Extension(name='pysimavr.swig._simavr',
sources=[
# SWIG + '/simavr.i',
SWIG + '/simavr_wrap.c',
SWIG + '/simavr_logger.cpp',
]
+ files(SIM, '*.c')
+ files(CORES, 'sim_*.c', EXCLUDE),
libraries=['elf'],
include_dirs=[
SIM,
INCLUDE_SIMAVR, INCLUDE_AVR,
],
# swig_opts=[
# # '-modern',
# '-I' + SIM,
# ],
extra_compile_args=[
'--std=gnu99',
'-DNO_COLOR',
],
),
part('sgm7'),
part('ledrow'),
part('inverter'),
part('hd44780'),
part('ac_input'),
part('button'),
part('uart_udp'),
part('spk'),
part('uart_buff'),
]
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=open('README.rst', 'r').read(),
classifiers=classifiers,
keywords='avr simavr',
author='ponty',
# author_email='',
url=URL,
license='GPL',
packages=PACKAGES,
include_package_data=True,
# test_suite='nose.collector',
zip_safe=False,
install_requires=install_requires,
ext_modules=ext_modules,
**extra
)