-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,60 @@ | ||
from distutils.core import setup, Extension | ||
import os.path, sys | ||
import sys | ||
import os | ||
import multiprocessing | ||
from setuptools import setup | ||
import os.path as op | ||
import distutils.command.build as _build | ||
import distutils.dir_util as dd | ||
import distutils.spawn as ds | ||
|
||
rle_c_lib = 'rle_python_interface/librle_c.so' | ||
if not os.path.isfile(rle_c_lib): | ||
print 'ERROR: Unable to find required library: %s. Please ensure you\'ve '\ | ||
'built RLE using CMake.'%(rle_c_lib) | ||
sys.exit() | ||
# script based on: | ||
# https://github.com/mgbellemare/Arcade-Learning-Environment/blob/master/setup.py | ||
# https://github.com/sim-x/simx/blob/master/setup.py | ||
# https://github.com/openai/atari-py/blob/master/setup.py | ||
|
||
def run_cmake(): | ||
if ds.find_executable('cmake') is None: | ||
print "CMake is required to build RLE" | ||
print "Please install cmake version >= 3.02 and re-run setup" | ||
sys.exit(-1) | ||
|
||
new_dir = op.join(op.split(__file__)[0], 'build') | ||
dd.mkpath(new_dir) | ||
os.chdir(new_dir) | ||
cmake_args = ' -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON' | ||
cores_to_use = max(1, multiprocessing.cpu_count() - 1) | ||
|
||
try: | ||
ds.spawn(['cmake', '../'] + cmake_args.split()) | ||
ds.spawn(['make', '-j', str(cores_to_use)]) | ||
except ds.DistutilsExecError: | ||
print "Error while running cmake" | ||
print "run 'setup.py build --help' for build options" | ||
print "You may also try editing the settings in CMakeLists.txt file and re-running setup" | ||
sys.exit(-1) | ||
|
||
########################### | ||
# Custom 'build' command | ||
########################### | ||
class Build(_build.build): | ||
def run(self): | ||
cwd = os.getcwd() | ||
run_cmake() | ||
os.chdir(cwd) | ||
|
||
module1 = Extension('rle_python_interface.rle_c_wrapper', | ||
libraries = ['rle_c'], | ||
include_dirs = ['src'], | ||
library_dirs = ['rle_python_interface'], | ||
extra_compile_args=['-D__STDC_CONSTANT_MACROS', '-std=c++11'], | ||
sources=['rle_python_interface/rle_c_wrapper.cpp']) | ||
setup(name = 'rle_python_interface', | ||
version='0.1.0', | ||
description = 'Retro Learning Environment Python Interface based on Ben Goodrich\'s work', | ||
url='https://github.com/nadavbh12/Retro-Learning-Environment', | ||
download_url='https://github.com/nadavbh12/Retro-Learning-Environment/tarball/1.0.1', | ||
author='Nadav Bhonker, Shai Rozenberg', | ||
author_email='[email protected];[email protected]', | ||
license = 'GPL', | ||
ext_modules = [module1], | ||
packages=['rle_python_interface'], | ||
package_dir={'rle_python_interface': 'rle_python_interface'}, | ||
package_data={'rle_python_interface': ['librle_c.so']}) | ||
package_data={'rle_python_interface': ['librle_c.so', | ||
'stella_libretro.so', | ||
'snes9x2010_libretrolinux-x86_64.so', | ||
'genesis_plus_gx_libretro.so']}, | ||
cmdclass={'build': Build } | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters