From 33df862d1df6250a4f7d3bf09e11f55ab7421a34 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Mon, 17 May 2021 18:08:15 +0200 Subject: [PATCH] clean zips files, fix shared version location --- igniter/bootstrap_repos.py | 10 ++++++---- start.py | 17 ++++++++++++++++- tools/build.ps1 | 4 +++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/igniter/bootstrap_repos.py b/igniter/bootstrap_repos.py index 8421e42c87..0a1534bb99 100644 --- a/igniter/bootstrap_repos.py +++ b/igniter/bootstrap_repos.py @@ -622,7 +622,7 @@ class BootstrapRepos: " not implemented yet.")) dir_to_search = self.data_dir - + user_versions = self.get_openpype_versions(self.data_dir, staging) # if we have openpype_path specified, search only there. if openpype_path: dir_to_search = openpype_path @@ -642,6 +642,7 @@ class BootstrapRepos: pass openpype_versions = self.get_openpype_versions(dir_to_search, staging) + openpype_versions += user_versions # remove zip file version if needed. if not include_zips: @@ -754,12 +755,13 @@ class BootstrapRepos: destination = self.data_dir / version.path.stem if destination.exists(): + assert destination.is_dir() try: - destination.unlink() - except OSError: + shutil.rmtree(destination) + except OSError as e: msg = f"!!! Cannot remove already existing {destination}" self._print(msg, LOG_ERROR, exc_info=True) - return None + raise e destination.mkdir(parents=True) diff --git a/start.py b/start.py index 4b8893a3d5..660d0c9006 100644 --- a/start.py +++ b/start.py @@ -427,6 +427,13 @@ def _find_frozen_openpype(use_version: str = None, path=Path(os.environ["OPENPYPE_ROOT"])) if local_version not in openpype_versions: openpype_versions.append(local_version) + openpype_versions.sort() + # if latest is currently running, ditch whole list + # and run from current without installing it. + if local_version == openpype_versions[-1]: + os.environ["OPENPYPE_TRYOUT"] = "1" + openpype_versions = [] + else: print("!!! Warning: cannot determine current running version.") @@ -502,7 +509,15 @@ def _find_frozen_openpype(use_version: str = None, if openpype_version.path.is_file(): print(">>> Extracting zip file ...") - version_path = bootstrap.extract_openpype(openpype_version) + try: + version_path = bootstrap.extract_openpype(openpype_version) + except OSError as e: + print("!!! failed: {}".format(str(e))) + sys.exit(1) + else: + # cleanup zip after extraction + os.unlink(openpype_version.path) + openpype_version.path = version_path _initialize_environment(openpype_version) diff --git a/tools/build.ps1 b/tools/build.ps1 index 566e40cb55..5c392c355c 100644 --- a/tools/build.ps1 +++ b/tools/build.ps1 @@ -164,6 +164,7 @@ Write-Host "OK" -ForegroundColor green Write-Host ">>> " -NoNewline -ForegroundColor green Write-Host "Building OpenPype ..." +$startTime = (Get-Date).Millisecond $out = & poetry run python setup.py build 2>&1 if ($LASTEXITCODE -ne 0) @@ -182,7 +183,8 @@ Write-Host ">>> " -NoNewline -ForegroundColor green Write-Host "restoring current directory" Set-Location -Path $current_dir +$endTime = (Get-Date).Millisecond Write-Host "*** " -NoNewline -ForegroundColor Cyan -Write-Host "All done. You will find OpenPype and build log in " -NoNewLine +Write-Host "All done in $($endTime - $startTime) secs. You will find OpenPype and build log in " -NoNewLine Write-Host "'.\build'" -NoNewline -ForegroundColor Green Write-Host " directory."