Skip to content

Commit

Permalink
Fixed removing CMakeCache.txt in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Nov 9, 2021
1 parent 8fe7665 commit f9b6e79
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
4 changes: 3 additions & 1 deletion examples/python/audio_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
34 changes: 16 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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. "
Expand Down

0 comments on commit f9b6e79

Please sign in to comment.