diff --git a/igniter/bootstrap_repos.py b/igniter/bootstrap_repos.py index de70dfde66..151597e505 100644 --- a/igniter/bootstrap_repos.py +++ b/igniter/bootstrap_repos.py @@ -211,7 +211,7 @@ class OpenPypeVersion(semver.VersionInfo): if not m: return None version = OpenPypeVersion.parse(string[m.start():m.end()]) - if "staging" in m.group("buildmetadata"): + if "staging" in string[m.start():m.end()]: version.staging = True return version @@ -570,6 +570,8 @@ class BootstrapRepos: and string with reason as second. """ + if os.getenv("OPENPYPE_DONT_VALIDATE_VERSION"): + return True, "Disabled validation" if not path.exists(): return False, "Path doesn't exist" @@ -614,7 +616,7 @@ class BootstrapRepos: files_in_zip = zip_file.namelist() files_in_zip.remove("checksums") files_in_zip = set(files_in_zip) - files_in_checksum = set([file[1] for file in checksums]) + files_in_checksum = {file[1] for file in checksums} diff = files_in_zip.difference(files_in_checksum) if diff: return False, f"Missing files {diff}" @@ -638,7 +640,7 @@ class BootstrapRepos: ] files_in_dir.remove("checksums") files_in_dir = set(files_in_dir) - files_in_checksum = set([file[1] for file in checksums]) + files_in_checksum = {file[1] for file in checksums} for file in checksums: file_name = file[1] diff --git a/openpype/tools/repack_version.py b/openpype/tools/repack_version.py index 9388563f63..9ce788c5e5 100644 --- a/openpype/tools/repack_version.py +++ b/openpype/tools/repack_version.py @@ -94,6 +94,8 @@ class VersionRepacker: return self._print(f"Detected version is {version}") + # replace version in version.py + self._replace_version(version, self.version_path) self._print("Recalculating checksums ...", 2) checksums = [] @@ -115,14 +117,13 @@ class VersionRepacker: total=len(checksums), desc="Zipping directory", nits="%", color=(56, 211, 159)) - with ZipFile(self.zip_path, "w") as zip_file: - checksums = [] + zip_filename = self.zip_path / f"openpype-v{version}.zip" + with ZipFile(zip_filename, "w") as zip_file: for item in checksums: - - processed_path = item[0] - self._print(f"- processing {processed_path}") - + if item[1].as_posix() == "checksums": + progress_bar.update() + continue zip_file.write(item[2], item[1]) progress_bar.update() @@ -135,6 +136,28 @@ class VersionRepacker: zip_file.writestr("checksums", checksums_str) # test if zip is ok zip_file.testzip() + self._print(f"All done, you can find new zip here: {zip_filename}") + + @staticmethod + def _replace_version(version: OpenPypeVersion, path: Path): + """Replace version in version.py. + + Args: + version (OpenPypeVersion): OpenPype version to set + path (Path): Path to unzipped version. + + """ + with open(path / "openpype" / "version.py", "r") as op_version_file: + replacement = "" + + for line in op_version_file: + stripped_line = line.strip() + if stripped_line.strip().startswith("__version__ ="): + line = f'__version__ = "{version}"\n' + replacement += line + + with open(path / "openpype" / "version.py", "w") as op_version_file: + op_version_file.write(replacement) if __name__ == '__main__': diff --git a/website/docs/admin_openpype_commands.md b/website/docs/admin_openpype_commands.md index 7a46ee7906..0831cf4f5a 100644 --- a/website/docs/admin_openpype_commands.md +++ b/website/docs/admin_openpype_commands.md @@ -32,7 +32,10 @@ For more information [see here](admin_use#run-openpype). | Command | Description | Arguments | | --- | --- |: --- :| -| tray | Launch OpenPype Tray. | [📑](#tray-arguments) +| contextselection | Open Context selection dialog. | | +| module | Run command line arguments for modules. | | +| repack-version | Tool to re-create version zip. | [📑](#repack-version-arguments) | +| tray | Launch OpenPype Tray. | [📑](#tray-arguments) | eventserver | This should be ideally used by system service (such as systemd or upstart on linux and window service). | [📑](#eventserver-arguments) | | launch | Launch application in Pype environment. | [📑](#launch-arguments) | | publish | Pype takes JSON from provided path and use it to publish data in it. | [📑](#publish-arguments) | @@ -156,4 +159,10 @@ openpypeconsole settings `standalonepublisher` has no command-line arguments. ```shell openpype_console standalonepublisher -``` \ No newline at end of file +``` + +### `repack-version` arguments {#repack-version-arguments} +Takes path to unzipped and possibly modified OpenPype version. Files will be +zipped, checksums recalculated and version will be determined by folder name +(and written to `version.py`). +