-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·88 lines (60 loc) · 2.38 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
#!/usr/bin/env python3
import os
if 'ARCHFLAGS' not in os.environ:
# Gnarly workaround from https://stackoverflow.com/questions/2584595.
os.environ['ARCHFLAGS'] = '-arch x86_64'
import platform, setuptools, sys, unittest
import Cython.Compiler.Options
TIMEDATA_PATH = os.path.abspath('../timedata/src/py')
sys.path.extend((TIMEDATA_PATH,))
from timedata_build.arguments import check_python, insert_dependencies
from timedata_build.config import CONFIG, FLAGS
from timedata_build import commands, execute
_JUCE_MAP = dict(
Darwin=(
'MacOSX',
'xcodebuild -project juce/MacOSX/timedata_visualizer_juce.xcodeproj'
' -configuration Release -jobs 6',
'-framework Carbon -framework Cocoa -framework IOKit'
' -framework QuartzCore -framework WebKit'),
Linux=('LinuxMakefile', 'make', ()), # TODO: need to cd and set CONFIG=Release.
Windows=('VisualStudio2015', 'TODO', ()),
)
_JUCE_DIR, _JUCE_COMMAND, _JUCE_LINK = _JUCE_MAP[platform.system()]
class BuildExt(commands.BuildExt):
def _extension_dict(self):
# Add the directory containing the Juce library to the compile args.
base = os.path.join('juce', _JUCE_DIR)
# TODO: this next line will be different for Windows.
library_dir = os.path.join(base, 'build', 'Release')
d = super()._extension_dict()
d['extra_link_args'] = ['-L%s' % library_dir] + _JUCE_LINK.split()
return d
class BuildJuce(commands.Command.Command):
description = 'Run Juce build'
def run(self):
print(execute.run(*_JUCE_COMMAND.split()))
class CleanJuce(commands.Clean):
NAME = 'juce_files'
class CleanCython(commands.Clean):
NAME = 'cython_files'
class Generate(commands.Generate):
def _classes(self, template_directory):
return []
COMMANDS = dict(
build_ext=BuildExt,
build_juce=BuildJuce,
clean=commands.Clean,
clean_juce=CleanJuce,
clean_cython=CleanCython,
generate=Generate,
)
# http://stackoverflow.com/a/37033551/43839
def test_suite():
return unittest.TestLoader().discover('tests', pattern=FLAGS.test_pattern)
check_python(FLAGS.minimum_python_version)
sys.argv = insert_dependencies(sys.argv, **CONFIG.dependencies)
# See: http://goo.gl/1kNY1n
# Cython.Compiler.Options.annotate = True
print('About to build targets', *sys.argv[1:])
setuptools.setup(cmdclass=COMMANDS, **CONFIG.setuptools)