mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #5822 from ynput/enhancement/create_ayon_addons_output_dir
Chore: updating create ayon addon script
This commit is contained in:
commit
5ad7e15700
1 changed files with 79 additions and 12 deletions
|
|
@ -3,6 +3,7 @@ import sys
|
|||
import re
|
||||
import json
|
||||
import shutil
|
||||
import argparse
|
||||
import zipfile
|
||||
import platform
|
||||
import collections
|
||||
|
|
@ -184,9 +185,12 @@ def create_openpype_package(
|
|||
|
||||
addon_output_dir = output_dir / "openpype" / addon_version
|
||||
private_dir = addon_output_dir / "private"
|
||||
if addon_output_dir.exists():
|
||||
shutil.rmtree(str(addon_output_dir))
|
||||
|
||||
# Make sure dir exists
|
||||
addon_output_dir.mkdir(parents=True)
|
||||
private_dir.mkdir(parents=True)
|
||||
addon_output_dir.mkdir(parents=True, exist_ok=True)
|
||||
private_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Copy version
|
||||
shutil.copy(str(version_path), str(addon_output_dir))
|
||||
|
|
@ -268,22 +272,37 @@ def create_addon_package(
|
|||
)
|
||||
|
||||
|
||||
def main(create_zip=True, keep_source=False):
|
||||
def main(
|
||||
output_dir=None,
|
||||
skip_zip=True,
|
||||
keep_source=False,
|
||||
clear_output_dir=False,
|
||||
addons=None,
|
||||
):
|
||||
current_dir = Path(os.path.dirname(os.path.abspath(__file__)))
|
||||
root_dir = current_dir.parent
|
||||
output_dir = current_dir / "packages"
|
||||
print("Package creation started...")
|
||||
create_zip = not skip_zip
|
||||
|
||||
# Make sure package dir is empty
|
||||
if output_dir.exists():
|
||||
if output_dir:
|
||||
output_dir = Path(output_dir)
|
||||
else:
|
||||
output_dir = current_dir / "packages"
|
||||
|
||||
if output_dir.exists() and clear_output_dir:
|
||||
shutil.rmtree(str(output_dir))
|
||||
# Make sure output dir is created
|
||||
output_dir.mkdir(parents=True)
|
||||
|
||||
print("Package creation started...")
|
||||
print(f"Output directory: {output_dir}")
|
||||
|
||||
# Make sure output dir is created
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
for addon_dir in current_dir.iterdir():
|
||||
if not addon_dir.is_dir():
|
||||
continue
|
||||
|
||||
if addons and addon_dir.name not in addons:
|
||||
continue
|
||||
|
||||
server_dir = addon_dir / "server"
|
||||
if not server_dir.exists():
|
||||
continue
|
||||
|
|
@ -303,6 +322,54 @@ def main(create_zip=True, keep_source=False):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
create_zip = "--skip-zip" not in sys.argv
|
||||
keep_sources = "--keep-sources" in sys.argv
|
||||
main(create_zip, keep_sources)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--skip-zip",
|
||||
dest="skip_zip",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Skip zipping server package and create only"
|
||||
" server folder structure."
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
"--keep-sources",
|
||||
dest="keep_sources",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Keep folder structure when server package is created."
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output",
|
||||
dest="output_dir",
|
||||
default=None,
|
||||
help=(
|
||||
"Directory path where package will be created"
|
||||
" (Will be purged if already exists!)"
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--clear-output-dir",
|
||||
dest="clear_output_dir",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Clear output directory before package creation."
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--addon",
|
||||
dest="addons",
|
||||
action="append",
|
||||
help="Limit addon creation to given addon name",
|
||||
)
|
||||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
main(
|
||||
args.output_dir,
|
||||
args.skip_zip,
|
||||
args.keep_sources,
|
||||
args.clear_output_dir,
|
||||
args.addons,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue