From f9b6e79829e6a7126b0149827f3b898163b211cf Mon Sep 17 00:00:00 2001 From: Marek Wydmuch Date: Wed, 10 Nov 2021 00:15:05 +0100 Subject: [PATCH] Fixed removing CMakeCache.txt in setup.py --- examples/python/audio_buffer.py | 4 +++- setup.py | 34 ++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/python/audio_buffer.py b/examples/python/audio_buffer.py index 04cd2b6ef..7a00d28f5 100755 --- a/examples/python/audio_buffer.py +++ b/examples/python/audio_buffer.py @@ -8,16 +8,18 @@ import vizdoom as vzd +import os from random import choice import numpy as np from scipy.io import wavfile from time import sleep + if __name__ == "__main__": game = vzd.DoomGame() # Load config of the basic scenario - game.load_config('../../scenarios/basic.cfg') + game.load_config(os.path.join(vzd.scenarios_path, "basic.cfg")) # Turns on the audio buffer. (turned off by default) # If this is switched on, the audio will stop playing on device, even with game.set_sound_enabled(True) diff --git a/setup.py b/setup.py index 178e90c07..2418e6162 100644 --- a/setup.py +++ b/setup.py @@ -43,12 +43,11 @@ def get_vizdoom_version(): def get_python_library(python_root_dir): paths_to_check = [ - "libs\python{}{}.{}", - "libs\python{}.{}.{}", - "libpython{}.{}m.{}", - "libpython{}.{}.{}", - "lib\libpython{}.{}m.{}", - "lib\libpython{}.{}.{}", + "libs/python{}{}.{}", # Windows Python/Anaconda + "libpython{}.{}m.{}", # Unix + "libpython{}.{}.{}", # Unix + "lib/libpython{}.{}m.{}", # Unix Anaconda + "lib/libpython{}.{}.{}", # Unix Anaconda ] for path_format in paths_to_check: @@ -82,12 +81,12 @@ def run(self): if platform.startswith("win"): generator = os.getenv('VIZDOOM_BUILD_GENERATOR_NAME') - if generator is None: - pass # TODO: Raise Error - - deps_root = os.getenv('VIZDOOM_WIN_DEPS_ROOT') + if not generator: + raise RuntimeError("VIZDOOM_BUILD_GENERATOR_NAME is not set") # TODO: Improve + + deps_root = os.getenv('VIZDOOM_WIN_DEPS_ROOT') if deps_root is None: - pass # TODO: Raise Error + raise RuntimeError("VIZDOOM_WIN_DEPS_ROOT is not set") # TODO: Improve mpg123_include=os.path.join(deps_root, 'libmpg123') mpg123_lib=os.path.join(deps_root, 'libmpg123/libmpg123-0.lib') @@ -122,21 +121,20 @@ def run(self): if os.path.exists(python_include_dir): cmake_arg_list.append("-DPYTHON_INCLUDE_DIR={}".format(python_include_dir)) - else: - pass # TODO: Raise Error if os.path.exists(python_library): cmake_arg_list.append("-DPYTHON_LIBRARY={}".format(python_library)) - else: - pass # TODO: Raise Error - shutil.rmtree('CMakeCache.txt', ignore_errors=True) - subprocess.check_call(cmake_arg_list) + if os.path.exists('CMakeCache.txt'): + os.remove('CMakeCache.txt') if platform.startswith("win"): - shutil.rmtree("src/lib_python/libvizdoom_python.dir", ignore_errors=True) + if os.path.exists("./src/lib_python/libvizdoom_python.dir"): + shutil.rmtree("./src/lib_python/libvizdoom_python.dir") # TODO: This is not very elegant, improve + subprocess.check_call(cmake_arg_list) subprocess.check_call(['cmake', '--build', '.', '--config', 'Release']) else: + subprocess.check_call(cmake_arg_list) subprocess.check_call(['make', '-j', str(cpu_cores)]) except subprocess.CalledProcessError: sys.stderr.write("\033[1m\nInstallation failed, you may be missing some dependencies. "