|
|
|
|
|
|
import shutil |
|
|
|
import subprocess |
|
|
|
import yaml |
|
|
|
from sys import platform |
|
|
|
downloader_install_path = "./.Editor/Unity.app/Contents/MacOS/Unity" |
|
|
|
if platform == "darwin": |
|
|
|
downloader_install_path = "./.Editor/Unity.app/Contents/MacOS/Unity" |
|
|
|
else: # if platform == "linux": |
|
|
|
downloader_install_path = "./.Editor/Unity" |
|
|
|
if os.path.exists(downloader_install_path): |
|
|
|
return downloader_install_path |
|
|
|
raise FileNotFoundError("Can't find executable from unity-downloader-cli") |
|
|
|
|
|
|
verbose: bool = False, |
|
|
|
output_path: str = None, |
|
|
|
scene_path: str = None, |
|
|
|
build_target: str = None, |
|
|
|
artifacts/standalone_build/testPlayer. |
|
|
|
artifacts/standalonebuild/testPlayer. |
|
|
|
print(f"Running BuildStandalonePlayerOSX via {unity_exe}") |
|
|
|
print(f"Running BuildStandalonePlayer via {unity_exe}") |
|
|
|
|
|
|
|
# enum values from https://docs.unity3d.com/2019.4/Documentation/ScriptReference/BuildTarget.html |
|
|
|
build_target_to_enum = { |
|
|
|
"mac": "StandaloneOSX", |
|
|
|
"osx": "StandaloneOSX", |
|
|
|
"linux": "StandaloneLinux64", |
|
|
|
} |
|
|
|
|
|
|
|
test_args = [ |
|
|
|
unity_exe, |
|
|
|
|
|
|
os.makedirs(os.path.dirname(output_path), exist_ok=True) |
|
|
|
if scene_path is not None: |
|
|
|
test_args += ["--mlagents-build-scene-path", scene_path] |
|
|
|
if build_target is not None: |
|
|
|
test_args += ["--mlagents-build-target", build_target_to_enum[build_target]] |
|
|
|
print(f"{' '.join(test_args)} ...") |
|
|
|
|
|
|
|
timeout = 30 * 60 # 30 minutes, just in case |
|
|
|
|
|
|
if output_path is None and res.returncode == 0: |
|
|
|
exe_name = "testPlayer.app" if platform == "darwin" else "testPlayer" |
|
|
|
os.path.join(base_path, "Project", "testPlayer.app"), |
|
|
|
os.path.join(get_base_output_path(), "testPlayer.app"), |
|
|
|
os.path.join(base_path, "Project", exe_name), |
|
|
|
os.path.join(get_base_output_path(), exe_name), |
|
|
|
) |
|
|
|
|
|
|
|
# Print if we fail or want verbosity. |
|
|
|
|
|
|
file_path = os.path.join(root, filename) |
|
|
|
if os.access(file_path, os.X_OK): |
|
|
|
exes.append(file_path) |
|
|
|
# Also check the input path |
|
|
|
if os.access(root_dir, os.X_OK): |
|
|
|
exes.append(root_dir) |
|
|
|
) -> str: |
|
|
|
) -> None: |
|
|
|
Set up the virtual environment, and return the venv path. |
|
|
|
Install the necessary packages for the venv |
|
|
|
# Use a different venv path for different versions |
|
|
|
venv_path = "venv" |
|
|
|
if mlagents_python_version: |
|
|
|
venv_path += "_" + mlagents_python_version |
|
|
|
|
|
|
|
# Set up the venv and install mlagents |
|
|
|
subprocess.check_call(f"python -m venv {venv_path}", shell=True) |
|
|
|
if platform != "darwin": |
|
|
|
raise RuntimeError("Yamato can only run tensorflow on mac platforms!") |
|
|
|
pip_commands += [ |
|
|
|
f"mlagents=={mlagents_python_version}", |
|
|
|
f"gym-unity=={mlagents_python_version}", |
|
|
|
|
|
|
pip_commands += ["-e ./ml-agents-envs", "-e ./ml-agents", "-e ./gym-unity"] |
|
|
|
if extra_packages: |
|
|
|
pip_commands += extra_packages |
|
|
|
|
|
|
|
print(f'Running "python3 -m pip install -q {cmd} {pip_index_url}"') |
|
|
|
f"source {venv_path}/bin/activate; python -m pip install -q {cmd} {pip_index_url}", |
|
|
|
shell=True, |
|
|
|
f"python3 -m pip install -q {cmd} {pip_index_url}", shell=True |
|
|
|
return venv_path |
|
|
|
|
|
|
|
|
|
|
|
def checkout_csharp_version(csharp_version): |
|
|
|