diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6396b1d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +dist: trusty +sudo: required +cache: + apt: true +language: python +addons: + apt: + packages: + - python-dev +python: + - "2.7" + - "3.5" +install: pip install tox-travis +script: tox + +notifications: + slack: + secure: h/Mxm8K+avH/2W0818zCHmLloRPMFN4NJL01+VShvAkH80/acfjeq/+mMdWXXPL/oOB6kSHDk+GDhwR6+s03ZcPMn5INTFvFYqUc6UWmT+NXtOPxGTN0xda6MdYUkWQUKaMyjFrweZQOMOASFBIzPOq4XeVbM5aB8s4EJhnfAcYZhp/idwKbToVihN4KZgxlvZIFc8iEp1o9uSl5qrsaeYYYXRkb6mauacAwOo4/Chu+cOnoLUOnvhBFE3rV3doDNrbnoalO8XiExtgx5CIAYWrlMni7r2Q+LlzgwdyTH19ZtybPxJTZIIWSBQ2UtcoYdIEDcc36GcUwz1VUGg32mLJJnY2xw80CWR4ixFPpLwwP5Y99WTn8v094B4nmFTWOwNWXp3EkqtTN9XcJoRBqXB5ArucIPqrx57dOCljSKx22gL6WaF2p3stSAxIGFektGyGnisaELrFZG1C63aHoUPicj3gUlijmAoUmYaDRf6P1wnpXqBpKDAWWhAMSatvx1ekmEJgR7OQklQnnfjx9kENDUygNUWS4IQwN2qYieuzHFL3of7/30mTM43+Vt/vWN8GI7j01BXu6FNGGloHxjH1pt3bLP/+uj5BJsT2HWF+Z8XR4VE6cyVuKsQAFgCXwOkoDHALbcwsspONDIt/9ixkesgh1oFt4CzU3UuU5wYs= + on_success: change diff --git a/README.md b/README.md index 76ae5f4..97f2fb3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # atari_py +[![Build Status](https://travis-ci.org/openai/atari-py.svg?branch=master)](https://travis-ci.org/openai/atari-py) + A packaged and slightly-modified version of [https://github.com/bbitmaster/ale_python_interface](https://github.com/bbitmaster/ale_python_interface). ## Installation @@ -8,7 +10,7 @@ To install via pip, run: ```pip install atari-py``` -Alternatively, you can install using setuptools using +Alternatively, you can install using setuptools using: ```python setup.py install``` diff --git a/atari_py/__init__.py b/atari_py/__init__.py index 6dd7b48..f12d58d 100644 --- a/atari_py/__init__.py +++ b/atari_py/__init__.py @@ -1,4 +1,4 @@ -from ale_python_interface import * +from .ale_python_interface import * import os def _game_dir(): @@ -9,4 +9,4 @@ def get_game_path(game_name): def list_games(): files = os.listdir(_game_dir()) - return [os.path.basename(f).split(".")[0] for f in files] \ No newline at end of file + return [os.path.basename(f).split(".")[0] for f in files] diff --git a/atari_py/ale_python_interface.py b/atari_py/ale_python_interface.py index fd2280a..02c812e 100644 --- a/atari_py/ale_python_interface.py +++ b/atari_py/ale_python_interface.py @@ -7,6 +7,7 @@ import numpy as np from numpy.ctypeslib import as_ctypes import os +import six ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__), 'ale_interface/build/libale_c.so')) @@ -134,7 +135,7 @@ def setFloat(self, key, value): ale_lib.setFloat(self.obj, key, value) def loadROM(self, rom_file): - ale_lib.loadROM(self.obj, rom_file) + ale_lib.loadROM(self.obj, six.b(rom_file)) def act(self, action): return ale_lib.act(self.obj, int(action)) diff --git a/atari_py/tests/test_smoke.py b/atari_py/tests/test_smoke.py new file mode 100644 index 0000000..3fe28bc --- /dev/null +++ b/atari_py/tests/test_smoke.py @@ -0,0 +1,16 @@ +import atari_py +import numpy as np + +def test_smoke(): + pong_path = atari_py.get_game_path('pong') + ale = atari_py.ALEInterface() + ale.loadROM(pong_path) + action_set = ale.getMinimalActionSet() + + # Test stepping + ale.act(action_set[0]) + + # Test screen capture + (screen_width,screen_height) = ale.getScreenDims() + arr = np.zeros((screen_height, screen_width, 4), dtype=np.uint8) + ale.getScreenRGB(arr) diff --git a/setup.py b/setup.py index 3670684..dde650f 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +import multiprocessing import os from setuptools import setup import subprocess @@ -9,18 +10,20 @@ class Build(DistutilsBuild): def run(self): + cores_to_use = max(1, multiprocessing.cpu_count() - 1) + cmd = ['make', 'build', '-C', 'atari_py/ale_interface', '-j', str(cores_to_use)] try: - subprocess.check_call(['make', 'build', '-C', 'atari_py/ale_interface']) + subprocess.check_call(cmd) except subprocess.CalledProcessError as e: sys.stderr.write("Could not build atari-py: %s. (HINT: are you sure cmake is installed? You might also be missing a library. Atari-py requires: zlib [installable as 'apt-get install zlib1g-dev' on Ubuntu].)\n" % e) raise except OSError as e: - sys.stderr.write("Unable to execute 'make build -C atari_py/ale_interface'. HINT: are you sure `make` is installed?\n") + sys.stderr.write("Unable to execute '{}'. HINT: are you sure `make` is installed?\n".format(' '.join(cmd))) raise DistutilsBuild.run(self) setup(name='atari-py', - version='0.0.14', + version='0.0.18', description='Python bindings to Atari games', url='https://github.com/openai/atari-py', author='OpenAI', @@ -29,6 +32,6 @@ def run(self): packages=['atari_py'], package_data={'atari_py': package_data}, cmdclass={'build': Build}, - install_requires=['numpy'], + install_requires=['numpy', 'six'], tests_require=['nose2'] ) diff --git a/tox.ini b/tox.ini index 77b0842..fe17214 100644 --- a/tox.ini +++ b/tox.ini @@ -8,13 +8,14 @@ envlist = py27, py35 [testenv:py35] whitelist_externals=make -deps = - nose2 - numpy + echo +install_command=echo {packages} commands = + pip install numpy nose2 make python setup.py build pip install -e . + nose2 python setup.py clean --all make clean