mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #1524 from pypeclub/feature/copy-dependency-progress-bars
This commit is contained in:
commit
25fe34a568
2 changed files with 51 additions and 6 deletions
|
|
@ -164,7 +164,7 @@ Write-Host "OK" -ForegroundColor green
|
|||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Building OpenPype ..."
|
||||
$startTime = (Get-Date).Millisecond
|
||||
$startTime = [int][double]::Parse((Get-Date -UFormat %s))
|
||||
|
||||
$out = & poetry run python setup.py build 2>&1
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
|
|
@ -183,7 +183,7 @@ Write-Host ">>> " -NoNewline -ForegroundColor green
|
|||
Write-Host "restoring current directory"
|
||||
Set-Location -Path $current_dir
|
||||
|
||||
$endTime = (Get-Date).Millisecond
|
||||
$endTime = [int][double]::Parse((Get-Date -UFormat %s))
|
||||
Write-Host "*** " -NoNewline -ForegroundColor Cyan
|
||||
Write-Host "All done in $($endTime - $startTime) secs. You will find OpenPype and build log in " -NoNewLine
|
||||
Write-Host "'.\build'" -NoNewline -ForegroundColor Green
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ import platform
|
|||
from pathlib import Path
|
||||
import shutil
|
||||
import blessed
|
||||
import enlighten
|
||||
import time
|
||||
|
||||
|
||||
term = blessed.Terminal()
|
||||
manager = enlighten.get_manager()
|
||||
|
||||
|
||||
def _print(msg: str, type: int = 0) -> None:
|
||||
|
|
@ -52,6 +54,24 @@ def _print(msg: str, type: int = 0) -> None:
|
|||
print("{}{}".format(header, msg))
|
||||
|
||||
|
||||
def count_folders(path: Path) -> int:
|
||||
"""Recursively count items inside given Path.
|
||||
|
||||
Args:
|
||||
path (Path): Path to count.
|
||||
|
||||
Returns:
|
||||
int: number of items.
|
||||
|
||||
"""
|
||||
cnt = 0
|
||||
for child in path.iterdir():
|
||||
if child.is_dir():
|
||||
cnt += 1
|
||||
cnt += count_folders(child)
|
||||
return cnt
|
||||
|
||||
|
||||
_print("Starting dependency cleanup ...")
|
||||
start_time = time.time_ns()
|
||||
|
||||
|
|
@ -96,30 +116,55 @@ deps_dir = build_dir / "dependencies"
|
|||
|
||||
# copy all files
|
||||
_print("Copying dependencies ...")
|
||||
shutil.copytree(site_pkg.as_posix(), deps_dir.as_posix())
|
||||
|
||||
total_files = count_folders(site_pkg)
|
||||
progress_bar = enlighten.Counter(
|
||||
total=total_files, desc="Processing Dependencies",
|
||||
units="%", color="green")
|
||||
|
||||
|
||||
def _progress(_base, _names):
|
||||
progress_bar.update()
|
||||
return []
|
||||
|
||||
|
||||
shutil.copytree(site_pkg.as_posix(),
|
||||
deps_dir.as_posix(),
|
||||
ignore=_progress)
|
||||
progress_bar.close()
|
||||
# iterate over frozen libs and create list to delete
|
||||
libs_dir = build_dir / "lib"
|
||||
|
||||
to_delete = []
|
||||
_print("Finding duplicates ...")
|
||||
# _print("Finding duplicates ...")
|
||||
deps_items = list(deps_dir.iterdir())
|
||||
item_count = len(list(libs_dir.iterdir()))
|
||||
find_progress_bar = enlighten.Counter(
|
||||
total=item_count, desc="Finding duplicates", units="%", color="yellow")
|
||||
|
||||
for d in libs_dir.iterdir():
|
||||
if (deps_dir / d.name) in deps_items:
|
||||
to_delete.append(d)
|
||||
_print(f"found {d}", 3)
|
||||
# _print(f"found {d}", 3)
|
||||
find_progress_bar.update()
|
||||
|
||||
find_progress_bar.close()
|
||||
# add openpype and igniter in libs too
|
||||
to_delete.append(libs_dir / "openpype")
|
||||
to_delete.append(libs_dir / "igniter")
|
||||
|
||||
# delete duplicates
|
||||
_print(f"Deleting {len(to_delete)} duplicates ...")
|
||||
# _print(f"Deleting {len(to_delete)} duplicates ...")
|
||||
delete_progress_bar = enlighten.Counter(
|
||||
total=len(to_delete), desc="Deleting duplicates", units="%", color="red")
|
||||
for d in to_delete:
|
||||
if d.is_dir():
|
||||
shutil.rmtree(d)
|
||||
else:
|
||||
d.unlink()
|
||||
delete_progress_bar.update()
|
||||
|
||||
delete_progress_bar.close()
|
||||
|
||||
end_time = time.time_ns()
|
||||
total_time = (end_time - start_time) / 1000000000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue