mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
generate zip doesn't need to run openpype
This commit is contained in:
parent
4fe35c671a
commit
ee43e3af34
6 changed files with 87 additions and 64 deletions
|
|
@ -473,7 +473,15 @@ class BootstrapRepos:
|
|||
|
||||
"""
|
||||
# get filtered list of file in Pype repository
|
||||
openpype_list = self._filter_dir(openpype_path, self.zip_filter)
|
||||
# openpype_list = self._filter_dir(openpype_path, self.zip_filter)
|
||||
openpype_list = []
|
||||
for f in self.openpype_filter:
|
||||
if (openpype_path / f).is_dir():
|
||||
openpype_list += self._filter_dir(
|
||||
openpype_path / f, self.zip_filter)
|
||||
else:
|
||||
openpype_list.append(openpype_path / f)
|
||||
|
||||
openpype_files = len(openpype_list)
|
||||
|
||||
openpype_inc = 98.0 / float(openpype_files)
|
||||
|
|
|
|||
|
|
@ -224,17 +224,6 @@ def launch(app, project, asset, task,
|
|||
PypeCommands().run_application(app, project, asset, task, tools, arguments)
|
||||
|
||||
|
||||
@main.command()
|
||||
@click.option("-p", "--path", help="Path to zip file", default=None)
|
||||
def generate_zip(path):
|
||||
"""Generate Pype zip from current sources.
|
||||
|
||||
If PATH is not provided, it will create zip file in user data dir.
|
||||
|
||||
"""
|
||||
PypeCommands().generate_zip(path)
|
||||
|
||||
|
||||
@main.command(
|
||||
context_settings=dict(
|
||||
ignore_unknown_options=True,
|
||||
|
|
|
|||
|
|
@ -119,26 +119,3 @@ class PypeCommands:
|
|||
def validate_jsons(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def generate_zip(out_path: str):
|
||||
"""Generate zip file from current sources.
|
||||
|
||||
Args:
|
||||
out_path (str): Path to generated zip file.
|
||||
|
||||
"""
|
||||
from igniter import bootstrap_repos
|
||||
|
||||
# create zip file
|
||||
bs = bootstrap_repos.BootstrapRepos()
|
||||
if out_path:
|
||||
out_path = Path(out_path)
|
||||
bs.data_dir = out_path.parent
|
||||
|
||||
print(f">>> Creating zip in {bs.data_dir} ...")
|
||||
repo_file = bs.create_version_from_live_code()
|
||||
if not repo_file:
|
||||
print("!!! Error while creating zip file.")
|
||||
exit(1)
|
||||
|
||||
print(f">>> Created {repo_file}")
|
||||
|
|
|
|||
|
|
@ -64,34 +64,15 @@ if (-not $openpype_version) {
|
|||
}
|
||||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Detecting host Python ... " -NoNewline
|
||||
if (-not (Get-Command "python" -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "!!! Python not detected" -ForegroundColor red
|
||||
Exit-WithCode 1
|
||||
}
|
||||
$version_command = @'
|
||||
import sys
|
||||
print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))
|
||||
'@
|
||||
|
||||
$p = & python -c $version_command
|
||||
$env:PYTHON_VERSION = $p
|
||||
$m = $p -match '(\d+)\.(\d+)'
|
||||
if(-not $m) {
|
||||
Write-Host "!!! Cannot determine version" -ForegroundColor red
|
||||
Exit-WithCode 1
|
||||
}
|
||||
# We are supporting python 3.6 and up
|
||||
if(($matches[1] -lt 3) -or ($matches[2] -lt 7)) {
|
||||
Write-Host "FAILED Version [ $p ] is old and unsupported" -ForegroundColor red
|
||||
Exit-WithCode 1
|
||||
}
|
||||
Write-Host "OK [ $p ]" -ForegroundColor green
|
||||
Write-Host "Cleaning cache files ... " -NoNewline
|
||||
Get-ChildItem $openpype_root -Filter "*.pyc" -Force -Recurse | Remove-Item -Force
|
||||
Get-ChildItem $openpype_root -Filter "*.pyo" -Force -Recurse | Remove-Item -Force
|
||||
Get-ChildItem $openpype_root -Filter "__pycache__" -Force -Recurse | Remove-Item -Force -Recurse
|
||||
Write-Host "OK" -ForegroundColor green
|
||||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Generating zip from current sources ..."
|
||||
Write-Host "... " -NoNewline -ForegroundColor Magenta
|
||||
Write-Host "arguments: " -NoNewline -ForegroundColor Gray
|
||||
Write-Host $ARGS -ForegroundColor White
|
||||
& poetry run python "$($openpype_root)\start.py" generate-zip $ARGS
|
||||
Set-Location -Path $current_dir
|
||||
$env:PYTHONPATH="$($openpype_root);$($env:PYTHONPATH)"
|
||||
$env:OPENPYPE_ROOT="$($openpype_root)"
|
||||
& poetry run python "$($openpype_root)\tools\create_zip.py" $ARGS
|
||||
Set-Location -Path $current_dir
|
||||
|
|
|
|||
66
tools/create_zip.py
Normal file
66
tools/create_zip.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Create OpenPype version from live sources."""
|
||||
from igniter import bootstrap_repos
|
||||
import click
|
||||
import enlighten
|
||||
import blessed
|
||||
from pathlib2 import Path
|
||||
|
||||
|
||||
term = blessed.Terminal()
|
||||
manager = enlighten.get_manager()
|
||||
last_increment = 0
|
||||
|
||||
|
||||
@click.group(invoke_without_command=True)
|
||||
@click.option("--path", required=False,
|
||||
help="path where to put version",
|
||||
type=click.Path(exists=True))
|
||||
def main(path):
|
||||
# create zip file
|
||||
|
||||
progress_bar = enlighten.Counter(
|
||||
total=100, desc="OpenPype ZIP", units="%", color="green")
|
||||
|
||||
def progress(inc: int):
|
||||
"""Progress handler."""
|
||||
global last_increment
|
||||
progress_bar.update(incr=inc - last_increment)
|
||||
last_increment = inc
|
||||
|
||||
bs = bootstrap_repos.BootstrapRepos(progress_callback=progress)
|
||||
if path:
|
||||
out_path = Path(path)
|
||||
bs.data_dir = out_path.parent
|
||||
|
||||
_print(f"Creating zip in {bs.data_dir} ...")
|
||||
repo_file = bs.create_version_from_live_code()
|
||||
if not repo_file:
|
||||
_print("Error while creating zip file.", 1)
|
||||
exit(1)
|
||||
|
||||
_print(f"Created {repo_file}")
|
||||
|
||||
|
||||
def _print(msg: str, message_type: int = 0) -> None:
|
||||
"""Print message to console.
|
||||
|
||||
Args:
|
||||
msg (str): message to print
|
||||
message_type (int): type of message (0 info, 1 error, 2 note)
|
||||
|
||||
"""
|
||||
if message_type == 0:
|
||||
header = term.aquamarine3(">>> ")
|
||||
elif message_type == 1:
|
||||
header = term.orangered2("!!! ")
|
||||
elif message_type == 2:
|
||||
header = term.tan1("... ")
|
||||
else:
|
||||
header = term.darkolivegreen3("--- ")
|
||||
|
||||
print("{}{}".format(header, msg))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -123,7 +123,9 @@ main () {
|
|||
pushd "$openpype_root" > /dev/null || return > /dev/null
|
||||
|
||||
echo -e "${BIGreen}>>>${RST} Generating zip from current sources ..."
|
||||
poetry run python3 "$openpype_root/start.py" generate-zip "$@"
|
||||
PYTHONPATH="$openpype_root:$PYTHONPATH"
|
||||
OPENPYPE_ROOT="$openpype_root"
|
||||
poetry run python3 "$openpype_root/tools/create_zip.py" "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue