forked from openai/atari-py
-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup.py
99 lines (85 loc) · 3.5 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
import glob
import os
import sys
from setuptools import setup
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.extension import Library
# Force linker to produce a shared library
class build_ext(_build_ext):
if sys.platform.startswith('linux'):
def get_ext_filename(self, fullname):
import setuptools.command.build_ext
tmp = setuptools.command.build_ext.libtype
setuptools.command.build_ext.libtype = 'shared'
ret = _build_ext.get_ext_filename(self, fullname)
setuptools.command.build_ext.libtype = tmp
return ret
def setup_shlib_compiler(self):
_build_ext.setup_shlib_compiler(self)
if sys.platform == 'win32':
from distutils.ccompiler import CCompiler
mtd = CCompiler.link_shared_object.__get__(self.shlib_compiler)
self.shlib_compiler.link_shared_object = mtd
elif sys.platform.startswith('linux'):
from functools import partial
c = self.shlib_compiler
c.link_shared_object = partial(c.link, c.SHARED_LIBRARY)
def list_files(path):
for root, dirs, files in os.walk(path):
for fname in files:
yield os.path.join(root, fname)
for dirname in dirs:
for rpath in list_files(os.path.join(root, dirname)):
yield rpath
basepath = os.path.normpath(r'atari_py/ale_interface/src')
modules = [os.path.join(basepath, os.path.normpath(path))
for path in 'common controllers emucore emucore/m6502/src '
'emucore/m6502/src/bspf/src environment games '
'games/supported external external/TinyMT'.split()]
defines = []
cflags = []
ldflags = []
sources = [os.path.join('atari_py', 'ale_c_wrapper.cpp'),
os.path.join(basepath, 'ale_interface.cpp')]
includes = ['atari_py', basepath, os.path.join(basepath, 'os_dependent')]
includes += modules
for folder in modules:
sources += glob.glob(os.path.join(folder, '*.c'))
sources += glob.glob(os.path.join(folder, '*.c?[xp]'))
if sys.platform.startswith('linux'):
defines.append(('BSPF_UNIX', None))
for fname in 'SettingsUNIX.cxx OSystemUNIX.cxx FSNodePOSIX.cxx'.split():
sources.append(os.path.join(basepath, 'os_dependent', fname))
elif sys.platform == "darwin":
defines.append(('BSPF_MAC_OSX', None))
includes.append(
'/System/Library/Frameworks/vecLib.framework/Versions/Current/Headers')
elif sys.platform == "win32":
defines.append(('BSPF_WIN32', None))
for fname in 'SettingsWin32.cxx OSystemWin32.cxx FSNodeWin32.cxx'.split():
sources.append(os.path.join(basepath, 'os_dependent', fname))
# disable msvc secure warnings
defines.append(('_CRT_SECURE_NO_WARNINGS', None))
cflags += ['/O2', '/GL', '/GF', '/EHs-']
ldflags += ['/LTCG']
ale_c = Library('ale_c',
define_macros=defines,
extra_compile_args=cflags,
extra_link_args=ldflags,
sources=sources,
include_dirs=includes,
)
setup(name='atari-py',
version='1.2.2',
description='Python bindings to Atari games',
url='https://github.com/openai/atari-py',
author='OpenAI',
author_email='[email protected]',
license='',
packages=['atari_py'],
package_data={'atari_py': ['atari_roms/*']},
cmdclass={'build_ext': build_ext},
ext_modules=[ale_c],
install_requires=['numpy'],
tests_require=['nose2']
)