mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
rename done in igniter
This commit is contained in:
parent
2e5aa101e2
commit
eb829e2ed3
9 changed files with 422 additions and 408 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Bootstrap Pype repositories."""
|
||||
"""Bootstrap OpenPype repositories."""
|
||||
import functools
|
||||
import logging as log
|
||||
import os
|
||||
|
|
@ -14,8 +14,8 @@ from zipfile import ZipFile, BadZipFile
|
|||
from appdirs import user_data_dir
|
||||
from speedcopy import copyfile
|
||||
|
||||
from .user_settings import PypeSettingsRegistry
|
||||
from .tools import get_pype_path_from_db
|
||||
from .user_settings import OpenPypeSettingsRegistry
|
||||
from .tools import get_openpype_path_from_db
|
||||
|
||||
|
||||
LOG_INFO = 0
|
||||
|
|
@ -24,8 +24,8 @@ LOG_ERROR = 3
|
|||
|
||||
|
||||
@functools.total_ordering
|
||||
class PypeVersion:
|
||||
"""Class for storing information about Pype version.
|
||||
class OpenPypeVersion:
|
||||
"""Class for storing information about OpenPype version.
|
||||
|
||||
Attributes:
|
||||
major (int): [1].2.3-client-variant
|
||||
|
|
@ -33,7 +33,7 @@ class PypeVersion:
|
|||
subversion (int): 1.2.[3]-client-variant
|
||||
client (str): 1.2.3-[client]-variant
|
||||
variant (str): 1.2.3-client-[variant]
|
||||
path (str): path to Pype
|
||||
path (str): path to OpenPype
|
||||
|
||||
"""
|
||||
major = 0
|
||||
|
|
@ -191,37 +191,37 @@ class PypeVersion:
|
|||
|
||||
@staticmethod
|
||||
def version_in_str(string: str) -> Tuple:
|
||||
"""Find Pype version in given string.
|
||||
"""Find OpenPype version in given string.
|
||||
|
||||
Args:
|
||||
string (str): string to search.
|
||||
|
||||
Returns:
|
||||
tuple: True/False and PypeVersion if found.
|
||||
tuple: True/False and OpenPypeVersion if found.
|
||||
|
||||
"""
|
||||
try:
|
||||
result = PypeVersion._decompose_version(string)
|
||||
result = OpenPypeVersion._decompose_version(string)
|
||||
except ValueError:
|
||||
return False, None
|
||||
return True, PypeVersion(major=result[0],
|
||||
minor=result[1],
|
||||
subversion=result[2],
|
||||
variant=result[3],
|
||||
client=result[4])
|
||||
return True, OpenPypeVersion(major=result[0],
|
||||
minor=result[1],
|
||||
subversion=result[2],
|
||||
variant=result[3],
|
||||
client=result[4])
|
||||
|
||||
|
||||
class BootstrapRepos:
|
||||
"""Class for bootstrapping local Pype installation.
|
||||
"""Class for bootstrapping local OpenPype installation.
|
||||
|
||||
Attributes:
|
||||
data_dir (Path): local Pype installation directory.
|
||||
data_dir (Path): local OpenPype installation directory.
|
||||
live_repo_dir (Path): path to repos directory if running live,
|
||||
otherwise `None`.
|
||||
registry (PypeSettingsRegistry): Pype registry object.
|
||||
registry (OpenPypeSettingsRegistry): OpenPype registry object.
|
||||
zip_filter (list): List of files to exclude from zip
|
||||
pype_filter (list): list of top level directories not to include in
|
||||
zip in Pype repository.
|
||||
openpype_filter (list): list of top level directories not to
|
||||
include in zip in OpenPype repository.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -236,12 +236,12 @@ class BootstrapRepos:
|
|||
"""
|
||||
# vendor and app used to construct user data dir
|
||||
self._vendor = "pypeclub"
|
||||
self._app = "pype"
|
||||
self._app = "openpype"
|
||||
self._log = log.getLogger(str(__class__))
|
||||
self.data_dir = Path(user_data_dir(self._app, self._vendor))
|
||||
self.registry = PypeSettingsRegistry()
|
||||
self.registry = OpenPypeSettingsRegistry()
|
||||
self.zip_filter = [".pyc", "__pycache__"]
|
||||
self.pype_filter = [
|
||||
self.openpype_filter = [
|
||||
"build", "docs", "tests", "repos", "tools", "venv"
|
||||
]
|
||||
self._message = message
|
||||
|
|
@ -262,11 +262,11 @@ class BootstrapRepos:
|
|||
|
||||
@staticmethod
|
||||
def get_version_path_from_list(version: str, version_list: list) -> Path:
|
||||
"""Get path for specific version in list of Pype versions.
|
||||
"""Get path for specific version in list of OpenPype versions.
|
||||
|
||||
Args:
|
||||
version (str): Version string to look for (1.2.4-staging)
|
||||
version_list (list of PypeVersion): list of version to search.
|
||||
version_list (list of OpenPypeVersion): list of version to search.
|
||||
|
||||
Returns:
|
||||
Path: Path to given version.
|
||||
|
|
@ -278,31 +278,32 @@ class BootstrapRepos:
|
|||
|
||||
@staticmethod
|
||||
def get_local_live_version() -> str:
|
||||
"""Get version of local Pype."""
|
||||
"""Get version of local OpenPype."""
|
||||
|
||||
version = {}
|
||||
path = Path(os.path.dirname(__file__)).parent / "pype" / "version.py"
|
||||
path = Path(os.path.dirname(__file__)).parent / "openpype" / "version.py"
|
||||
with open(path, "r") as fp:
|
||||
exec(fp.read(), version)
|
||||
return version["__version__"]
|
||||
|
||||
@staticmethod
|
||||
def get_version(repo_dir: Path) -> Union[str, None]:
|
||||
"""Get version of Pype in given directory.
|
||||
"""Get version of OpenPype in given directory.
|
||||
|
||||
Note: in frozen Pype installed in user data dir, this must point
|
||||
one level deeper as it is `pype-version-v3.0.0/pype/pype/version.py`
|
||||
Note: in frozen OpenPype installed in user data dir, this must point
|
||||
one level deeper as it is:
|
||||
`openpype-version-v3.0.0/openpype/version.py`
|
||||
|
||||
Args:
|
||||
repo_dir (Path): Path to Pype repo.
|
||||
repo_dir (Path): Path to OpenPype repo.
|
||||
|
||||
Returns:
|
||||
str: version string.
|
||||
None: if Pype is not found.
|
||||
None: if OpenPype is not found.
|
||||
|
||||
"""
|
||||
# try to find version
|
||||
version_file = Path(repo_dir) / "pype" / "version.py"
|
||||
version_file = Path(repo_dir) / "openpype" / "version.py"
|
||||
if not version_file.exists():
|
||||
return None
|
||||
|
||||
|
|
@ -313,22 +314,22 @@ class BootstrapRepos:
|
|||
return version['__version__']
|
||||
|
||||
def create_version_from_live_code(
|
||||
self, repo_dir: Path = None) -> Union[PypeVersion, None]:
|
||||
"""Copy zip created from Pype repositories to user data dir.
|
||||
self, repo_dir: Path = None) -> Union[OpenPypeVersion, None]:
|
||||
"""Copy zip created from OpenPype repositories to user data dir.
|
||||
|
||||
This detect Pype version either in local "live" Pype repository
|
||||
or in user provided path. Then it will zip it in temporary directory
|
||||
and finally it will move it to destination which is user data
|
||||
directory. Existing files will be replaced.
|
||||
This detect OpenPype version either in local "live" OpenPype
|
||||
repository or in user provided path. Then it will zip it in temporary
|
||||
directory and finally it will move it to destination which is user
|
||||
data directory. Existing files will be replaced.
|
||||
|
||||
Args:
|
||||
repo_dir (Path, optional): Path to Pype repository.
|
||||
repo_dir (Path, optional): Path to OpenPype repository.
|
||||
|
||||
Returns:
|
||||
Path: path of installed repository file.
|
||||
|
||||
"""
|
||||
# if repo dir is not set, we detect local "live" Pype repository
|
||||
# if repo dir is not set, we detect local "live" OpenPype repository
|
||||
# version and use it as a source. Otherwise repo_dir is user
|
||||
# entered location.
|
||||
if not repo_dir:
|
||||
|
|
@ -338,7 +339,7 @@ class BootstrapRepos:
|
|||
version = self.get_version(repo_dir)
|
||||
|
||||
if not version:
|
||||
self._print("Pype not found.", LOG_ERROR)
|
||||
self._print("OpenPype not found.", LOG_ERROR)
|
||||
return
|
||||
|
||||
# create destination directory
|
||||
|
|
@ -348,20 +349,20 @@ class BootstrapRepos:
|
|||
# create zip inside temporary directory.
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
temp_zip = \
|
||||
Path(temp_dir) / f"pype-v{version}.zip"
|
||||
Path(temp_dir) / f"openpype-v{version}.zip"
|
||||
self._print(f"creating zip: {temp_zip}")
|
||||
|
||||
self._create_pype_zip(temp_zip, repo_dir)
|
||||
self._create_openpype_zip(temp_zip, repo_dir)
|
||||
if not os.path.exists(temp_zip):
|
||||
self._print("make archive failed.", LOG_ERROR)
|
||||
return None
|
||||
|
||||
destination = self._move_zip_to_data_dir(temp_zip)
|
||||
|
||||
return PypeVersion(version=version, path=destination)
|
||||
return OpenPypeVersion(version=version, path=destination)
|
||||
|
||||
def _move_zip_to_data_dir(self, zip_file) -> Union[None, Path]:
|
||||
"""Move zip with Pype version to user data directory.
|
||||
"""Move zip with OpenPype version to user data directory.
|
||||
|
||||
Args:
|
||||
zip_file (Path): Path to zip file.
|
||||
|
|
@ -404,16 +405,16 @@ class BootstrapRepos:
|
|||
result.append(item)
|
||||
return result
|
||||
|
||||
def create_version_from_frozen_code(self) -> Union[None, PypeVersion]:
|
||||
"""Create Pype version from *frozen* code distributed by installer.
|
||||
def create_version_from_frozen_code(self) -> Union[None, OpenPypeVersion]:
|
||||
"""Create OpenPype version from *frozen* code distributed by installer.
|
||||
|
||||
This should be real edge case for those wanting to try out Pype
|
||||
This should be real edge case for those wanting to try out OpenPype
|
||||
without setting up whole infrastructure but is strongly discouraged
|
||||
in studio setup as this use local version independent of others
|
||||
that can be out of date.
|
||||
|
||||
Returns:
|
||||
:class:`PypeVersion` zip file to be installed.
|
||||
:class:`OpenPypeVersion` zip file to be installed.
|
||||
|
||||
"""
|
||||
frozen_root = Path(sys.executable).parent
|
||||
|
|
@ -421,24 +422,24 @@ class BootstrapRepos:
|
|||
repo_list = self._filter_dir(
|
||||
repo_dir, self.zip_filter)
|
||||
|
||||
# from frozen code we need igniter, pype, schema vendor
|
||||
pype_list = self._filter_dir(
|
||||
frozen_root / "pype", self.zip_filter)
|
||||
pype_list += self._filter_dir(
|
||||
# from frozen code we need igniter, openpype, schema vendor
|
||||
openpype_list = self._filter_dir(
|
||||
frozen_root / "openpype", self.zip_filter)
|
||||
openpype_list += self._filter_dir(
|
||||
frozen_root / "igniter", self.zip_filter)
|
||||
pype_list += self._filter_dir(
|
||||
openpype_list += self._filter_dir(
|
||||
frozen_root / "schema", self.zip_filter)
|
||||
pype_list += self._filter_dir(
|
||||
openpype_list += self._filter_dir(
|
||||
frozen_root / "vendor", self.zip_filter)
|
||||
pype_list.append(frozen_root / "README.md")
|
||||
pype_list.append(frozen_root / "LICENSE")
|
||||
openpype_list.append(frozen_root / "README.md")
|
||||
openpype_list.append(frozen_root / "LICENSE")
|
||||
|
||||
version = self.get_version(frozen_root)
|
||||
|
||||
# create zip inside temporary directory.
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
temp_zip = \
|
||||
Path(temp_dir) / f"pype-v{version}.zip"
|
||||
Path(temp_dir) / f"openpype-v{version}.zip"
|
||||
self._print(f"creating zip: {temp_zip}")
|
||||
|
||||
with ZipFile(temp_zip, "w") as zip_file:
|
||||
|
|
@ -453,43 +454,44 @@ class BootstrapRepos:
|
|||
arc_name = file.relative_to(repo_dir)
|
||||
zip_file.write(file, arc_name)
|
||||
|
||||
pype_inc = 48.0 / float(len(pype_list))
|
||||
openpype_inc = 48.0 / float(len(openpype_list))
|
||||
file: Path
|
||||
for file in pype_list:
|
||||
progress += pype_inc
|
||||
for file in openpype_list:
|
||||
progress += openpype_inc
|
||||
self._progress_callback(int(progress))
|
||||
|
||||
arc_name = file.relative_to(frozen_root.parent)
|
||||
# we need to replace first part of path which starts with
|
||||
# something like `exe.win/linux....` with `pype` as this
|
||||
# is expected by Pype in zip archive.
|
||||
arc_name = Path("pype").joinpath(*arc_name.parts[1:])
|
||||
# something like `exe.win/linux....` with `openpype` as this
|
||||
# is expected by OpenPype in zip archive.
|
||||
arc_name = Path("openpype").joinpath(*arc_name.parts[1:])
|
||||
zip_file.write(file, arc_name)
|
||||
|
||||
destination = self._move_zip_to_data_dir(temp_zip)
|
||||
|
||||
return PypeVersion(version=version, path=destination)
|
||||
return OpenPypeVersion(version=version, path=destination)
|
||||
|
||||
def _create_pype_zip(
|
||||
def _create_poenpype_zip(
|
||||
self,
|
||||
zip_path: Path, include_dir: Path,
|
||||
include_pype: bool = True) -> None:
|
||||
"""Pack repositories and Pype into zip.
|
||||
include_openpype: bool = True) -> None:
|
||||
"""Pack repositories and OpenPype into zip.
|
||||
|
||||
We are using :mod:`zipfile` instead :meth:`shutil.make_archive`
|
||||
because we need to decide what file and directories to include in zip
|
||||
and what not. They are determined by :attr:`zip_filter` on file level
|
||||
and :attr:`pype_filter` on top level directory in Pype repository.
|
||||
and :attr:`openpype_filter` on top level directory in OpenPype
|
||||
repository.
|
||||
|
||||
Args:
|
||||
zip_path (str): path to zip file.
|
||||
include_dir (Path): repo directories to include.
|
||||
include_pype (bool): add Pype module itself.
|
||||
include_openpype (bool): add OpenPype module itself.
|
||||
|
||||
"""
|
||||
include_dir = include_dir.resolve()
|
||||
|
||||
pype_list = []
|
||||
openpype_list = []
|
||||
# get filtered list of files in repositories (repos directory)
|
||||
repo_list = self._filter_dir(include_dir, self.zip_filter)
|
||||
# count them
|
||||
|
|
@ -497,13 +499,13 @@ class BootstrapRepos:
|
|||
|
||||
# there must be some files, otherwise `include_dir` path is wrong
|
||||
assert repo_files != 0, f"No repositories to include in {include_dir}"
|
||||
pype_inc = 0
|
||||
if include_pype:
|
||||
openpype_inc = 0
|
||||
if include_openpype:
|
||||
# get filtered list of file in Pype repository
|
||||
pype_list = self._filter_dir(include_dir.parent, self.zip_filter)
|
||||
pype_files = len(pype_list)
|
||||
openpype_list = self._filter_dir(include_dir.parent, self.zip_filter)
|
||||
openpype_files = len(openpype_list)
|
||||
repo_inc = 48.0 / float(repo_files)
|
||||
pype_inc = 48.0 / float(pype_files)
|
||||
openpype_inc = 48.0 / float(openpype_files)
|
||||
else:
|
||||
repo_inc = 98.0 / float(repo_files)
|
||||
|
||||
|
|
@ -518,15 +520,15 @@ class BootstrapRepos:
|
|||
arc_name = file.relative_to(include_dir)
|
||||
zip_file.write(file, arc_name)
|
||||
|
||||
# add pype itself
|
||||
if include_pype:
|
||||
pype_root = include_dir.parent.resolve()
|
||||
# add openpype itself
|
||||
if include_openpype:
|
||||
openpype_root = include_dir.parent.resolve()
|
||||
# generate list of filtered paths
|
||||
dir_filter = [pype_root / f for f in self.pype_filter]
|
||||
dir_filter = [openpype_root / f for f in self.openpype_filter]
|
||||
|
||||
file: Path
|
||||
for file in pype_list:
|
||||
progress += pype_inc
|
||||
for file in openpype_list:
|
||||
progress += openpype_inc
|
||||
self._progress_callback(int(progress))
|
||||
|
||||
# if file resides in filtered path, skip it
|
||||
|
|
@ -545,7 +547,8 @@ class BootstrapRepos:
|
|||
self._print(f"- processing {processed_path}")
|
||||
|
||||
zip_file.write(file,
|
||||
"pype" / file.relative_to(pype_root))
|
||||
"openpype" / file.relative_to(
|
||||
openpype_root))
|
||||
|
||||
# test if zip is ok
|
||||
zip_file.testzip()
|
||||
|
|
@ -616,49 +619,49 @@ class BootstrapRepos:
|
|||
|
||||
os.environ["PYTHONPATH"] = os.pathsep.join(paths)
|
||||
|
||||
def find_pype(
|
||||
def find_openpype(
|
||||
self,
|
||||
pype_path: Union[Path, str] = None,
|
||||
openpype_path: Union[Path, str] = None,
|
||||
staging: bool = False,
|
||||
include_zips: bool = False) -> Union[List[PypeVersion], None]:
|
||||
"""Get ordered dict of detected Pype version.
|
||||
include_zips: bool = False) -> Union[List[OpenPypeVersion], None]:
|
||||
"""Get ordered dict of detected OpenPype version.
|
||||
|
||||
Resolution order for Pype is following:
|
||||
Resolution order for OpenPype is following:
|
||||
|
||||
1) First we test for ``PYPE_PATH`` environment variable
|
||||
2) We try to find ``pypePath`` in registry setting
|
||||
1) First we test for ``OPENPYPE_PATH`` environment variable
|
||||
2) We try to find ``openPypePath`` in registry setting
|
||||
3) We use user data directory
|
||||
|
||||
Args:
|
||||
pype_path (Path or str, optional): Try to find Pype on the given
|
||||
path or url.
|
||||
openpype_path (Path or str, optional): Try to find OpenPype on
|
||||
the given path or url.
|
||||
staging (bool, optional): Filter only staging version, skip them
|
||||
otherwise.
|
||||
include_zips (bool, optional): If set True it will try to find
|
||||
Pype in zip files in given directory.
|
||||
OpenPype in zip files in given directory.
|
||||
|
||||
Returns:
|
||||
dict of Path: Dictionary of detected Pype version.
|
||||
dict of Path: Dictionary of detected OpenPype version.
|
||||
Key is version, value is path to zip file.
|
||||
|
||||
None: if Pype is not found.
|
||||
None: if OpenPype is not found.
|
||||
|
||||
Todo:
|
||||
implement git/url support as Pype location, so it would be
|
||||
possible to enter git url, Pype would check it out and if it is
|
||||
implement git/url support as OpenPype location, so it would be
|
||||
possible to enter git url, OpenPype would check it out and if it is
|
||||
ok install it as normal version.
|
||||
|
||||
"""
|
||||
if pype_path and not isinstance(pype_path, Path):
|
||||
if openpype_path and not isinstance(openpype_path, Path):
|
||||
raise NotImplementedError(
|
||||
("Finding Pype in non-filesystem locations is"
|
||||
("Finding OpenPype in non-filesystem locations is"
|
||||
" not implemented yet."))
|
||||
|
||||
dir_to_search = self.data_dir
|
||||
|
||||
# if we have pype_path specified, search only there.
|
||||
if pype_path:
|
||||
dir_to_search = pype_path
|
||||
# if we have openpype_path specified, search only there.
|
||||
if openpype_path:
|
||||
dir_to_search = openpype_path
|
||||
else:
|
||||
if os.getenv("PYPE_PATH"):
|
||||
if Path(os.getenv("PYPE_PATH")).exists():
|
||||
|
|
@ -666,7 +669,7 @@ class BootstrapRepos:
|
|||
else:
|
||||
try:
|
||||
registry_dir = Path(
|
||||
str(self.registry.get_item("pypePath")))
|
||||
str(self.registry.get_item("openPypePath")))
|
||||
if registry_dir.exists():
|
||||
dir_to_search = registry_dir
|
||||
|
||||
|
|
@ -674,22 +677,22 @@ class BootstrapRepos:
|
|||
# nothing found in registry, we'll use data dir
|
||||
pass
|
||||
|
||||
pype_versions = self.get_pype_versions(dir_to_search, staging)
|
||||
openpype_versions = self.get_openpype_versions(dir_to_search, staging)
|
||||
|
||||
# remove zip file version if needed.
|
||||
if not include_zips:
|
||||
pype_versions = [
|
||||
v for v in pype_versions if v.path.suffix != ".zip"
|
||||
openpype_versions = [
|
||||
v for v in openpype_versions if v.path.suffix != ".zip"
|
||||
]
|
||||
|
||||
return pype_versions
|
||||
return openpype_versions
|
||||
|
||||
def process_entered_location(self, location: str) -> Union[Path, None]:
|
||||
"""Process user entered location string.
|
||||
|
||||
It decides if location string is mongodb url or path.
|
||||
If it is mongodb url, it will connect and load ``PYPE_PATH`` from
|
||||
there and use it as path to Pype. In it is _not_ mongodb url, it
|
||||
If it is mongodb url, it will connect and load ``OPENPYPE_PATH`` from
|
||||
there and use it as path to OpenPype. In it is _not_ mongodb url, it
|
||||
is assumed we have a path, this is tested and zip file is
|
||||
produced and installed using :meth:`create_version_from_live_code`.
|
||||
|
||||
|
|
@ -697,51 +700,52 @@ class BootstrapRepos:
|
|||
location (str): User entered location.
|
||||
|
||||
Returns:
|
||||
Path: to Pype zip produced from this location.
|
||||
Path: to OpenPype zip produced from this location.
|
||||
None: Zipping failed.
|
||||
|
||||
"""
|
||||
pype_path = None
|
||||
# try to get pype path from mongo.
|
||||
openpype_path = None
|
||||
# try to get OpenPype path from mongo.
|
||||
if location.startswith("mongodb"):
|
||||
pype_path = get_pype_path_from_db(location)
|
||||
if not pype_path:
|
||||
pype_path = get_openpype_path_from_db(location)
|
||||
if not openpype_path:
|
||||
self._print("cannot find PYPE_PATH in settings.")
|
||||
return None
|
||||
|
||||
# if not successful, consider location to be fs path.
|
||||
if not pype_path:
|
||||
pype_path = Path(location)
|
||||
if not openpype_path:
|
||||
openpype_path = Path(location)
|
||||
|
||||
# test if this path does exist.
|
||||
if not pype_path.exists():
|
||||
self._print(f"{pype_path} doesn't exists.")
|
||||
if not openpype_path.exists():
|
||||
self._print(f"{openpype_path} doesn't exists.")
|
||||
return None
|
||||
|
||||
# test if entered path isn't user data dir
|
||||
if self.data_dir == pype_path:
|
||||
if self.data_dir == openpype_path:
|
||||
self._print("cannot point to user data dir", LOG_ERROR)
|
||||
return None
|
||||
|
||||
# find pype zip files in location. There can be
|
||||
# either "live" Pype repository, or multiple zip files or even
|
||||
# multiple pype version directories. This process looks into zip
|
||||
# find openpype zip files in location. There can be
|
||||
# either "live" OpenPype repository, or multiple zip files or even
|
||||
# multiple OpenPype version directories. This process looks into zip
|
||||
# files and directories and tries to parse `version.py` file.
|
||||
versions = self.find_pype(pype_path, include_zips=True)
|
||||
versions = self.find_openpype(openpype_path, include_zips=True)
|
||||
if versions:
|
||||
self._print(f"found Pype in [ {pype_path} ]")
|
||||
self._print(f"found OpenPype in [ {openpype_path} ]")
|
||||
self._print(f"latest version found is [ {versions[-1]} ]")
|
||||
|
||||
return self.install_version(versions[-1])
|
||||
|
||||
# if we got here, it means that location is "live" Pype repository.
|
||||
# we'll create zip from it and move it to user data dir.
|
||||
live_pype = self.create_version_from_live_code(pype_path)
|
||||
if not live_pype.path.exists():
|
||||
self._print(f"installing zip {live_pype} failed.", LOG_ERROR)
|
||||
# if we got here, it means that location is "live"
|
||||
# OpenPype repository. We'll create zip from it and move it to user
|
||||
# data dir.
|
||||
live_openpype = self.create_version_from_live_code(openpype_path)
|
||||
if not live_openpype.path.exists():
|
||||
self._print(f"installing zip {live_openpype} failed.", LOG_ERROR)
|
||||
return None
|
||||
# install it
|
||||
return self.install_version(live_pype)
|
||||
return self.install_version(live_openpype)
|
||||
|
||||
def _print(self,
|
||||
message: str,
|
||||
|
|
@ -769,11 +773,11 @@ class BootstrapRepos:
|
|||
return
|
||||
self._log.info(message, exc_info=exc_info)
|
||||
|
||||
def extract_pype(self, version: PypeVersion) -> Union[Path, None]:
|
||||
"""Extract zipped Pype version to user data directory.
|
||||
def extract_openpype(self, version: OpenPypeVersion) -> Union[Path, None]:
|
||||
"""Extract zipped OpenPype version to user data directory.
|
||||
|
||||
Args:
|
||||
version (PypeVersion): Version of Pype.
|
||||
version (OpenPypeVersion): Version of OpenPype.
|
||||
|
||||
Returns:
|
||||
Path: path to extracted version.
|
||||
|
|
@ -819,40 +823,41 @@ class BootstrapRepos:
|
|||
is_inside = path.resolve().relative_to(
|
||||
self.data_dir)
|
||||
except ValueError:
|
||||
# if relative path cannot be calculated, Pype version is not
|
||||
# if relative path cannot be calculated, OpenPype version is not
|
||||
# inside user data dir
|
||||
pass
|
||||
return is_inside
|
||||
|
||||
def install_version(self,
|
||||
pype_version: PypeVersion,
|
||||
openpype_version: OpenPypeVersion,
|
||||
force: bool = False) -> Path:
|
||||
"""Install Pype version to user data directory.
|
||||
"""Install OpenPype version to user data directory.
|
||||
|
||||
Args:
|
||||
pype_version (PypeVersion): Pype version to install.
|
||||
oepnpype_version (OpenPypeVersion): OpenPype version to install.
|
||||
force (bool, optional): Force overwrite existing version.
|
||||
|
||||
Returns:
|
||||
Path: Path to installed Pype.
|
||||
Path: Path to installed OpenPype.
|
||||
|
||||
Raises:
|
||||
PypeVersionExists: If not forced and this version already exist
|
||||
OpenPypeVersionExists: If not forced and this version already exist
|
||||
in user data directory.
|
||||
PypeVersionInvalid: If version to install is invalid.
|
||||
PypeVersionIOError: If copying or zipping fail.
|
||||
OpenPypeVersionInvalid: If version to install is invalid.
|
||||
OpenPypeVersionIOError: If copying or zipping fail.
|
||||
|
||||
"""
|
||||
|
||||
if self.is_inside_user_data(pype_version.path) and not pype_version.path.is_file(): # noqa
|
||||
raise PypeVersionExists("Pype already inside user data dir")
|
||||
if self.is_inside_user_data(openpype_version.path) and not pype_version.path.is_file(): # noqa
|
||||
raise OpenPypeVersionExists(
|
||||
"OpenPype already inside user data dir")
|
||||
|
||||
# determine destination directory name
|
||||
# for zip file strip suffix, in case of dir use whole dir name
|
||||
if pype_version.path.is_dir():
|
||||
dir_name = pype_version.path.name
|
||||
if openpype_version.path.is_dir():
|
||||
dir_name = openpype_version.path.name
|
||||
else:
|
||||
dir_name = pype_version.path.stem
|
||||
dir_name = openpype_version.path.stem
|
||||
|
||||
destination = self.data_dir / dir_name
|
||||
|
||||
|
|
@ -864,82 +869,83 @@ class BootstrapRepos:
|
|||
self._print(
|
||||
f"cannot remove already existing {destination}",
|
||||
LOG_ERROR, exc_info=True)
|
||||
raise PypeVersionIOError(
|
||||
raise OpenPypeVersionIOError(
|
||||
f"cannot remove existing {destination}") from e
|
||||
elif destination.exists() and not force:
|
||||
raise PypeVersionExists(f"{destination} already exist.")
|
||||
raise OpenPypeVersionExists(f"{destination} already exist.")
|
||||
else:
|
||||
# create destination parent directories even if they don't exist.
|
||||
destination.mkdir(parents=True)
|
||||
|
||||
# version is directory
|
||||
if pype_version.path.is_dir():
|
||||
if openpype_version.path.is_dir():
|
||||
# create zip inside temporary directory.
|
||||
self._print("Creating zip from directory ...")
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
temp_zip = \
|
||||
Path(temp_dir) / f"pype-v{pype_version}.zip"
|
||||
Path(temp_dir) / f"openpype-v{openpype_version}.zip"
|
||||
self._print(f"creating zip: {temp_zip}")
|
||||
|
||||
self._create_pype_zip(temp_zip, pype_version.path)
|
||||
self._create_openpype_zip(temp_zip, openpype_version.path)
|
||||
if not os.path.exists(temp_zip):
|
||||
self._print("make archive failed.", LOG_ERROR)
|
||||
raise PypeVersionIOError("Zip creation failed.")
|
||||
raise OpenPypeVersionIOError("Zip creation failed.")
|
||||
|
||||
# set zip as version source
|
||||
pype_version.path = temp_zip
|
||||
openpype_version.path = temp_zip
|
||||
|
||||
elif pype_version.path.is_file():
|
||||
elif openpype_version.path.is_file():
|
||||
# check if file is zip (by extension)
|
||||
if pype_version.path.suffix.lower() != ".zip":
|
||||
raise PypeVersionInvalid("Invalid file format")
|
||||
if openpype_version.path.suffix.lower() != ".zip":
|
||||
raise OpenPypeVersionInvalid("Invalid file format")
|
||||
|
||||
if not self.is_inside_user_data(pype_version.path):
|
||||
if not self.is_inside_user_data(openpype_version.path):
|
||||
try:
|
||||
# copy file to destination
|
||||
self._print("Copying zip to destination ...")
|
||||
_destination_zip = destination.parent / pype_version.path.name
|
||||
_destination_zip = destination.parent / openpype_version.path.name # noqa: E501
|
||||
copyfile(
|
||||
pype_version.path.as_posix(),
|
||||
openpype_version.path.as_posix(),
|
||||
_destination_zip.as_posix())
|
||||
except OSError as e:
|
||||
self._print(
|
||||
"cannot copy version to user data directory", LOG_ERROR,
|
||||
exc_info=True)
|
||||
raise PypeVersionIOError((
|
||||
f"can't copy version {pype_version.path.as_posix()} "
|
||||
raise OpenPypeVersionIOError((
|
||||
f"can't copy version {openpype_version.path.as_posix()} "
|
||||
f"to destination {destination.parent.as_posix()}")) from e
|
||||
|
||||
# extract zip there
|
||||
self._print("extracting zip to destination ...")
|
||||
with ZipFile(pype_version.path, "r") as zip_ref:
|
||||
with ZipFile(openpype_version.path, "r") as zip_ref:
|
||||
zip_ref.extractall(destination)
|
||||
|
||||
return destination
|
||||
|
||||
def _is_pype_in_dir(self,
|
||||
dir_item: Path,
|
||||
detected_version: PypeVersion) -> bool:
|
||||
"""Test if path item is Pype version matching detected version.
|
||||
def _is_openpype_in_dir(self,
|
||||
dir_item: Path,
|
||||
detected_version: OpenPypeVersion) -> bool:
|
||||
"""Test if path item is OpenPype version matching detected version.
|
||||
|
||||
If item is directory that might (based on it's name)
|
||||
contain Pype version, check if it really does contain
|
||||
Pype and that their versions matches.
|
||||
contain OpenPype version, check if it really does contain
|
||||
OpenPype and that their versions matches.
|
||||
|
||||
Args:
|
||||
dir_item (Path): Directory to test.
|
||||
detected_version (PypeVersion): Pype version detected from name.
|
||||
detected_version (OpenPypeVersion): OpenPype version detected
|
||||
from name.
|
||||
|
||||
Returns:
|
||||
True if it is valid Pype version, False otherwise.
|
||||
True if it is valid OpenPype version, False otherwise.
|
||||
|
||||
"""
|
||||
try:
|
||||
# add one 'pype' level as inside dir there should
|
||||
# add one 'openpype' level as inside dir there should
|
||||
# be many other repositories.
|
||||
version_str = BootstrapRepos.get_version(
|
||||
dir_item / "pype")
|
||||
version_check = PypeVersion(version=version_str)
|
||||
dir_item / "openpype")
|
||||
version_check = OpenPypeVersion(version=version_str)
|
||||
except ValueError:
|
||||
self._print(
|
||||
f"cannot determine version from {dir_item}", True)
|
||||
|
|
@ -955,21 +961,21 @@ class BootstrapRepos:
|
|||
return False
|
||||
return True
|
||||
|
||||
def _is_pype_in_zip(self,
|
||||
zip_item: Path,
|
||||
detected_version: PypeVersion) -> bool:
|
||||
"""Test if zip path is Pype version matching detected version.
|
||||
def _is_openpype_in_zip(self,
|
||||
zip_item: Path,
|
||||
detected_version: OpenPypeVersion) -> bool:
|
||||
"""Test if zip path is OpenPype version matching detected version.
|
||||
|
||||
Open zip file, look inside and parse version from Pype
|
||||
Open zip file, look inside and parse version from OpenPype
|
||||
inside it. If there is none, or it is different from
|
||||
version specified in file name, skip it.
|
||||
|
||||
Args:
|
||||
zip_item (Path): Zip file to test.
|
||||
detected_version (PypeVersion): Pype version detected from name.
|
||||
detected_version (OpenPypeVersion): Pype version detected from name.
|
||||
|
||||
Returns:
|
||||
True if it is valid Pype version, False otherwise.
|
||||
True if it is valid OpenPype version, False otherwise.
|
||||
|
||||
"""
|
||||
# skip non-zip files
|
||||
|
|
@ -979,10 +985,10 @@ class BootstrapRepos:
|
|||
try:
|
||||
with ZipFile(zip_item, "r") as zip_file:
|
||||
with zip_file.open(
|
||||
"pype/pype/version.py") as version_file:
|
||||
"openpype/version.py") as version_file:
|
||||
zip_version = {}
|
||||
exec(version_file.read(), zip_version)
|
||||
version_check = PypeVersion(
|
||||
version_check = OpenPypeVersion(
|
||||
version=zip_version["__version__"])
|
||||
|
||||
version_main = version_check.get_main_version() # noqa: E501
|
||||
|
|
@ -999,70 +1005,72 @@ class BootstrapRepos:
|
|||
self._print(f"{zip_item} is not a zip file", True)
|
||||
return False
|
||||
except KeyError:
|
||||
self._print("Zip does not contain Pype", True)
|
||||
self._print("Zip does not contain OpenPype", True)
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_pype_versions(self, pype_dir: Path, staging: bool = False) -> list:
|
||||
"""Get all detected Pype versions in directory.
|
||||
def get_openpype_versions(self,
|
||||
openpype_dir: Path,
|
||||
staging: bool = False) -> list:
|
||||
"""Get all detected OpenPype versions in directory.
|
||||
|
||||
Args:
|
||||
pype_dir (Path): Directory to scan.
|
||||
openpype_dir (Path): Directory to scan.
|
||||
staging (bool, optional): Find staging versions if True.
|
||||
|
||||
Returns:
|
||||
list of PypeVersion
|
||||
list of OpenPypeVersion
|
||||
|
||||
Throws:
|
||||
ValueError: if invalid path is specified.
|
||||
|
||||
"""
|
||||
if not pype_dir.exists() and not pype_dir.is_dir():
|
||||
if not openpype_dir.exists() and not openpype_dir.is_dir():
|
||||
raise ValueError("specified directory is invalid")
|
||||
|
||||
_pype_versions = []
|
||||
_openpype_versions = []
|
||||
# iterate over directory in first level and find all that might
|
||||
# contain Pype.
|
||||
for item in pype_dir.iterdir():
|
||||
# contain OpenPype.
|
||||
for item in openpype_dir.iterdir():
|
||||
|
||||
# if file, strip extension, in case of dir not.
|
||||
name = item.name if item.is_dir() else item.stem
|
||||
result = PypeVersion.version_in_str(name)
|
||||
result = OpenPypeVersion.version_in_str(name)
|
||||
|
||||
if result[0]:
|
||||
detected_version: PypeVersion
|
||||
detected_version: OpenPypeVersion
|
||||
detected_version = result[1]
|
||||
|
||||
if item.is_dir() and not self._is_pype_in_dir(
|
||||
if item.is_dir() and not self._is_openpype_in_dir(
|
||||
item, detected_version
|
||||
):
|
||||
continue
|
||||
|
||||
if item.is_file() and not self._is_pype_in_zip(
|
||||
if item.is_file() and not self._is_openpype_in_zip(
|
||||
item, detected_version
|
||||
):
|
||||
continue
|
||||
|
||||
detected_version.path = item
|
||||
if staging and detected_version.is_staging():
|
||||
_pype_versions.append(detected_version)
|
||||
_openpype_versions.append(detected_version)
|
||||
|
||||
if not staging and not detected_version.is_staging():
|
||||
_pype_versions.append(detected_version)
|
||||
_openpype_versions.append(detected_version)
|
||||
|
||||
return sorted(_pype_versions)
|
||||
return sorted(_openpype_versions)
|
||||
|
||||
|
||||
class PypeVersionExists(Exception):
|
||||
"""Exception for handling existing Pype version."""
|
||||
class OpenPypeVersionExists(Exception):
|
||||
"""Exception for handling existing OpenPype version."""
|
||||
pass
|
||||
|
||||
|
||||
class PypeVersionInvalid(Exception):
|
||||
"""Exception for handling invalid Pype version."""
|
||||
class OpenPypeVersionInvalid(Exception):
|
||||
"""Exception for handling invalid OpenPype version."""
|
||||
pass
|
||||
|
||||
|
||||
class PypeVersionIOError(Exception):
|
||||
"""Exception for handling IO errors in Pype version."""
|
||||
class OpenPypeVersionIOError(Exception):
|
||||
"""Exception for handling IO errors in OpenPype version."""
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ from .install_thread import InstallThread, InstallResult
|
|||
from .tools import (
|
||||
validate_path_string,
|
||||
validate_mongo_connection,
|
||||
get_pype_path_from_db
|
||||
get_openpype_path_from_db
|
||||
)
|
||||
from .user_settings import PypeSettingsRegistry
|
||||
from .user_settings import OpenPypeSettingsRegistry
|
||||
from .version import __version__
|
||||
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
|
||||
def __init__(self, parent=None):
|
||||
super(InstallDialog, self).__init__(parent)
|
||||
self.registry = PypeSettingsRegistry()
|
||||
self.registry = OpenPypeSettingsRegistry()
|
||||
|
||||
self.mongo_url = ""
|
||||
try:
|
||||
|
|
@ -50,7 +50,8 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
self.setWindowTitle(f"Pype Igniter {__version__} - Pype installation")
|
||||
self.setWindowTitle(
|
||||
f"OpenPype Igniter {__version__} - OpenPype installation")
|
||||
self._icon_path = os.path.join(
|
||||
os.path.dirname(__file__), 'openpype_icon.png')
|
||||
icon = QtGui.QIcon(self._icon_path)
|
||||
|
|
@ -81,7 +82,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
os.path.join(
|
||||
os.path.dirname(__file__), 'RobotoMono-Regular.ttf')
|
||||
)
|
||||
self._pype_run_ready = False
|
||||
self._openpype_run_ready = False
|
||||
|
||||
self._init_ui()
|
||||
|
||||
|
|
@ -97,35 +98,35 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
# Main info
|
||||
# --------------------------------------------------------------------
|
||||
self.main_label = QtWidgets.QLabel(
|
||||
"""Welcome to <b>Pype</b>
|
||||
"""Welcome to <b>OpenPype</b>
|
||||
<p>
|
||||
We've detected <b>Pype</b> is not configured yet. But don't worry,
|
||||
We've detected <b>OpenPype</b> is not configured yet. But don't worry,
|
||||
this is as easy as setting one or two things.
|
||||
<p>
|
||||
""")
|
||||
self.main_label.setWordWrap(True)
|
||||
self.main_label.setStyleSheet("color: rgb(200, 200, 200);")
|
||||
|
||||
# Pype path info
|
||||
# OpenPype path info
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
self.pype_path_label = QtWidgets.QLabel(
|
||||
"""This is <b>Path to studio location</b> where Pype versions
|
||||
self.openpype_path_label = QtWidgets.QLabel(
|
||||
"""This is <b>Path to studio location</b> where OpenPype versions
|
||||
are stored. It will be pre-filled if your MongoDB connection is
|
||||
already set and your studio defined this location.
|
||||
<p>
|
||||
Leave it empty if you want to install Pype version that comes with
|
||||
this installation.
|
||||
Leave it empty if you want to install OpenPype version that
|
||||
comes with this installation.
|
||||
</p>
|
||||
<p>
|
||||
If you want to just try Pype without installing, hit the middle
|
||||
button that states "run without installation".
|
||||
If you want to just try OpenPype without installing, hit the
|
||||
middle button that states "run without installation".
|
||||
</p>
|
||||
"""
|
||||
)
|
||||
|
||||
self.pype_path_label.setWordWrap(True)
|
||||
self.pype_path_label.setStyleSheet("color: rgb(150, 150, 150);")
|
||||
self.openpype_path_label.setWordWrap(True)
|
||||
self.openpype_path_label.setStyleSheet("color: rgb(150, 150, 150);")
|
||||
|
||||
# Path/Url box | Select button
|
||||
# --------------------------------------------------------------------
|
||||
|
|
@ -135,7 +136,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
input_layout.setContentsMargins(0, 10, 0, 10)
|
||||
self.user_input = FocusHandlingLineEdit()
|
||||
|
||||
self.user_input.setPlaceholderText("Path to Pype versions")
|
||||
self.user_input.setPlaceholderText("Path to OpenPype versions")
|
||||
self.user_input.textChanged.connect(self._path_changed)
|
||||
self.user_input.setStyleSheet(
|
||||
("color: rgb(233, 233, 233);"
|
||||
|
|
@ -148,7 +149,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
|
||||
self._btn_select = QtWidgets.QPushButton("Select")
|
||||
self._btn_select.setToolTip(
|
||||
"Select Pype repository"
|
||||
"Select OpenPype repository"
|
||||
)
|
||||
self._btn_select.setStyleSheet(
|
||||
("color: rgb(64, 64, 64);"
|
||||
|
|
@ -282,13 +283,13 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
# --------------------------------------------------------------------
|
||||
bottom_widget = QtWidgets.QWidget()
|
||||
bottom_layout = QtWidgets.QHBoxLayout()
|
||||
pype_logo_label = QtWidgets.QLabel("pype logo")
|
||||
pype_logo = QtGui.QPixmap(self._icon_path)
|
||||
# pype_logo.scaled(
|
||||
# pype_logo_label.width(),
|
||||
# pype_logo_label.height(), QtCore.Qt.KeepAspectRatio)
|
||||
pype_logo_label.setPixmap(pype_logo)
|
||||
pype_logo_label.setContentsMargins(10, 0, 0, 10)
|
||||
openpype_logo_label = QtWidgets.QLabel("openpype logo")
|
||||
openpype_logo = QtGui.QPixmap(self._icon_path)
|
||||
# openpype_logo.scaled(
|
||||
# openpype_logo_label.width(),
|
||||
# openpype_logo_label.height(), QtCore.Qt.KeepAspectRatio)
|
||||
openpype_logo_label.setPixmap(openpype_logo)
|
||||
openpype_logo_label.setContentsMargins(10, 0, 0, 10)
|
||||
|
||||
# install button - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
self.install_button = QtWidgets.QPushButton("Install")
|
||||
|
|
@ -298,7 +299,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
"padding: 0.5em;")
|
||||
)
|
||||
self.install_button.setMinimumSize(64, 24)
|
||||
self.install_button.setToolTip("Install Pype")
|
||||
self.install_button.setToolTip("Install OpenPype")
|
||||
self.install_button.clicked.connect(self._on_ok_clicked)
|
||||
|
||||
# run from current button - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -325,7 +326,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
|
||||
bottom_layout.setContentsMargins(0, 10, 10, 0)
|
||||
bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
|
||||
bottom_layout.addWidget(pype_logo_label, 0, QtCore.Qt.AlignVCenter)
|
||||
bottom_layout.addWidget(openpype_logo_label, 0, QtCore.Qt.AlignVCenter)
|
||||
bottom_layout.addStretch(1)
|
||||
bottom_layout.addWidget(self.install_button, 0, QtCore.Qt.AlignVCenter)
|
||||
bottom_layout.addWidget(self.run_button, 0, QtCore.Qt.AlignVCenter)
|
||||
|
|
@ -405,7 +406,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
)
|
||||
# add all to main
|
||||
main.addWidget(self.main_label, 0)
|
||||
main.addWidget(self.pype_path_label, 0)
|
||||
main.addWidget(self.openpype_path_label, 0)
|
||||
main.addLayout(input_layout, 0)
|
||||
main.addWidget(self.mongo_label, 0)
|
||||
main.addWidget(self._mongo, 0)
|
||||
|
|
@ -418,9 +419,9 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
|
||||
self.setLayout(main)
|
||||
|
||||
# if mongo url is ok, try to get pype path from there
|
||||
# if mongo url is ok, try to get openpype path from there
|
||||
if self._mongo.validate_url() and len(self.path) == 0:
|
||||
self.path = get_pype_path_from_db(self.mongo_url)
|
||||
self.path = get_openpype_path_from_db(self.mongo_url)
|
||||
self.user_input.setText(self.path)
|
||||
|
||||
def _on_select_clicked(self):
|
||||
|
|
@ -473,7 +474,7 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
else:
|
||||
self._mongo.set_valid()
|
||||
|
||||
if self._pype_run_ready:
|
||||
if self._openpype_run_ready:
|
||||
self.done(3)
|
||||
return
|
||||
|
||||
|
|
@ -498,8 +499,8 @@ class InstallDialog(QtWidgets.QDialog):
|
|||
"""Change button behaviour based on installation outcome."""
|
||||
status = result.status
|
||||
if status >= 0:
|
||||
self.install_button.setText("Run installed Pype")
|
||||
self._pype_run_ready = True
|
||||
self.install_button.setText("Run installed OpenPype")
|
||||
self._openpype_run_ready = True
|
||||
|
||||
def _update_progress(self, progress: int):
|
||||
self._progress_bar.setValue(progress)
|
||||
|
|
@ -636,7 +637,7 @@ class PathValidator(MongoValidator):
|
|||
"""Validate path to be accepted by Igniter.
|
||||
|
||||
Args:
|
||||
path (str): path to Pype.
|
||||
path (str): path to OpenPype.
|
||||
pos (int): current position.
|
||||
|
||||
Returns:
|
||||
|
|
@ -646,7 +647,7 @@ class PathValidator(MongoValidator):
|
|||
|
||||
"""
|
||||
# allow empty path as that will use current version coming with
|
||||
# Pype Igniter
|
||||
# OpenPype Igniter
|
||||
if len(path) == 0:
|
||||
return self._return_state(
|
||||
QValidator.State.Acceptable, "Use version with Igniter", path)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ from Qt.QtCore import QThread, Signal, QObject # noqa
|
|||
|
||||
from .bootstrap_repos import (
|
||||
BootstrapRepos,
|
||||
PypeVersionInvalid,
|
||||
PypeVersionIOError,
|
||||
PypeVersionExists,
|
||||
PypeVersion
|
||||
OpenPypeVersionInvalid,
|
||||
OpenPypeVersionIOError,
|
||||
OpenPypeVersionExists,
|
||||
OpenPypeVersion
|
||||
)
|
||||
|
||||
from .tools import validate_mongo_connection
|
||||
|
|
@ -26,9 +26,9 @@ class InstallResult(QObject):
|
|||
class InstallThread(QThread):
|
||||
"""Install Worker thread.
|
||||
|
||||
This class takes care of finding Pype version on user entered path
|
||||
This class takes care of finding OpenPype version on user entered path
|
||||
(or loading this path from database). If nothing is entered by user,
|
||||
Pype will create its zip files from repositories that comes with it.
|
||||
OpenPype will create its zip files from repositories that comes with it.
|
||||
|
||||
If path contains plain repositories, they are zipped and installed to
|
||||
user data dir.
|
||||
|
|
@ -49,19 +49,19 @@ class InstallThread(QThread):
|
|||
def run(self):
|
||||
"""Thread entry point.
|
||||
|
||||
Using :class:`BootstrapRepos` to either install Pype as zip files
|
||||
Using :class:`BootstrapRepos` to either install OpenPype as zip files
|
||||
or copy them from location specified by user or retrieved from
|
||||
database.
|
||||
|
||||
"""
|
||||
self.message.emit("Installing Pype ...", False)
|
||||
self.message.emit("Installing OpenPype ...", False)
|
||||
|
||||
# find local version of Pype
|
||||
# find local version of OpenPype
|
||||
bs = BootstrapRepos(
|
||||
progress_callback=self.set_progress, message=self.message)
|
||||
local_version = bs.get_local_live_version()
|
||||
|
||||
# if user did entered nothing, we install Pype from local version.
|
||||
# if user did entered nothing, we install OpenPype from local version.
|
||||
# zip content of `repos`, copy it to user data dir and append
|
||||
# version to it.
|
||||
if not self._path:
|
||||
|
|
@ -71,7 +71,8 @@ class InstallThread(QThread):
|
|||
if not os.getenv("PYPE_MONGO"):
|
||||
# try to get it from settings registry
|
||||
try:
|
||||
self._mongo = bs.registry.get_secure_item("pypeMongo")
|
||||
self._mongo = bs.registry.get_secure_item(
|
||||
"openPypeMongo")
|
||||
except ValueError:
|
||||
self.message.emit(
|
||||
"!!! We need MongoDB URL to proceed.", True)
|
||||
|
|
@ -81,33 +82,34 @@ class InstallThread(QThread):
|
|||
self._mongo = os.getenv("PYPE_MONGO")
|
||||
else:
|
||||
self.message.emit("Saving mongo connection string ...", False)
|
||||
bs.registry.set_secure_item("pypeMongo", self._mongo)
|
||||
bs.registry.set_secure_item("openPypeMongo", self._mongo)
|
||||
|
||||
os.environ["PYPE_MONGO"] = self._mongo
|
||||
|
||||
self.message.emit(
|
||||
f"Detecting installed Pype versions in {bs.data_dir}", False)
|
||||
f"Detecting installed OpenPype versions in {bs.data_dir}",
|
||||
False)
|
||||
detected = bs.find_pype(include_zips=True)
|
||||
|
||||
if detected:
|
||||
if PypeVersion(
|
||||
if OpenPypeVersion(
|
||||
version=local_version, path=Path()) < detected[-1]:
|
||||
self.message.emit((
|
||||
f"Latest installed version {detected[-1]} is newer "
|
||||
f"then currently running {local_version}"
|
||||
), False)
|
||||
self.message.emit("Skipping Pype install ...", False)
|
||||
self.message.emit("Skipping OpenPype install ...", False)
|
||||
if detected[-1].path.suffix.lower() == ".zip":
|
||||
bs.extract_pype(detected[-1])
|
||||
bs.extract_openpype(detected[-1])
|
||||
self.finished.emit(InstallResult(0))
|
||||
return
|
||||
|
||||
if PypeVersion(version=local_version).get_main_version() == detected[-1].get_main_version(): # noqa
|
||||
if OpenPypeVersion(version=local_version).get_main_version() == detected[-1].get_main_version(): # noqa
|
||||
self.message.emit((
|
||||
f"Latest installed version is the same as "
|
||||
f"currently running {local_version}"
|
||||
), False)
|
||||
self.message.emit("Skipping Pype install ...", False)
|
||||
self.message.emit("Skipping OpenPype install ...", False)
|
||||
self.finished.emit(InstallResult(0))
|
||||
return
|
||||
|
||||
|
|
@ -118,17 +120,17 @@ class InstallThread(QThread):
|
|||
else:
|
||||
if getattr(sys, 'frozen', False):
|
||||
self.message.emit("None detected.", True)
|
||||
self.message.emit(("We will use Pype coming with "
|
||||
self.message.emit(("We will use OpenPype coming with "
|
||||
"installer."), False)
|
||||
pype_version = bs.create_version_from_frozen_code()
|
||||
if not pype_version:
|
||||
openpype_version = bs.create_version_from_frozen_code()
|
||||
if not openpype_version:
|
||||
self.message.emit(
|
||||
f"!!! Install failed - {pype_version}", True)
|
||||
f"!!! Install failed - {openpype_version}", True)
|
||||
self.finished.emit(InstallResult(-1))
|
||||
return
|
||||
self.message.emit(f"Using: {pype_version}", False)
|
||||
bs.install_version(pype_version)
|
||||
self.message.emit(f"Installed as {pype_version}", False)
|
||||
self.message.emit(f"Using: {openpype_version}", False)
|
||||
bs.install_version(openpype_version)
|
||||
self.message.emit(f"Installed as {openpype_version}", False)
|
||||
self.progress.emit(100)
|
||||
self.finished.emit(InstallResult(1))
|
||||
return
|
||||
|
|
@ -136,38 +138,38 @@ class InstallThread(QThread):
|
|||
self.message.emit("None detected.", False)
|
||||
|
||||
self.message.emit(
|
||||
f"We will use local Pype version {local_version}", False)
|
||||
f"We will use local OpenPype version {local_version}", False)
|
||||
|
||||
local_pype = bs.create_version_from_live_code()
|
||||
if not local_pype:
|
||||
local_openpype = bs.create_version_from_live_code()
|
||||
if not local_openpype:
|
||||
self.message.emit(
|
||||
f"!!! Install failed - {local_pype}", True)
|
||||
f"!!! Install failed - {local_openpype}", True)
|
||||
self.finished.emit(InstallResult(-1))
|
||||
return
|
||||
|
||||
try:
|
||||
bs.install_version(local_pype)
|
||||
except (PypeVersionExists,
|
||||
PypeVersionInvalid,
|
||||
PypeVersionIOError) as e:
|
||||
bs.install_version(local_openpype)
|
||||
except (OpenPypeVersionExists,
|
||||
OpenPypeVersionInvalid,
|
||||
OpenPypeVersionIOError) as e:
|
||||
self.message.emit(f"Installed failed: ", True)
|
||||
self.message.emit(str(e), True)
|
||||
self.finished.emit(InstallResult(-1))
|
||||
return
|
||||
|
||||
self.message.emit(f"Installed as {local_pype}", False)
|
||||
self.message.emit(f"Installed as {local_openpype}", False)
|
||||
self.progress.emit(100)
|
||||
return
|
||||
else:
|
||||
# if we have mongo connection string, validate it, set it to
|
||||
# user settings and get PYPE_PATH from there.
|
||||
# user settings and get OPENPYPE_PATH from there.
|
||||
if self._mongo:
|
||||
if not validate_mongo_connection(self._mongo):
|
||||
self.message.emit(
|
||||
f"!!! invalid mongo url {self._mongo}", True)
|
||||
self.finished.emit(InstallResult(-1))
|
||||
return
|
||||
bs.registry.set_secure_item("pypeMongo", self._mongo)
|
||||
bs.registry.set_secure_item("openPypeMongo", self._mongo)
|
||||
os.environ["PYPE_MONGO"] = self._mongo
|
||||
|
||||
self.message.emit(f"processing {self._path}", True)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Pype terminal animation."""
|
||||
"""OpenPype terminal animation."""
|
||||
import blessed
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
|
|
@ -15,7 +15,7 @@ except AttributeError:
|
|||
|
||||
|
||||
def play_animation():
|
||||
"""Play ASCII art Pype animation."""
|
||||
"""Play ASCII art OpenPype animation."""
|
||||
if NO_TERMINAL:
|
||||
return
|
||||
print(term.home + term.clear)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"""Tools used in **Igniter** GUI.
|
||||
|
||||
Functions ``compose_url()`` and ``decompose_url()`` are the same as in
|
||||
``pype.lib`` and they are here to avoid importing pype module before its
|
||||
``openpype.lib`` and they are here to avoid importing OpenPype module before its
|
||||
version is decided.
|
||||
|
||||
"""
|
||||
|
|
@ -163,7 +163,7 @@ def validate_mongo_string(mongo: str) -> (bool, str):
|
|||
|
||||
|
||||
def validate_path_string(path: str) -> (bool, str):
|
||||
"""Validate string if it is path to Pype repository.
|
||||
"""Validate string if it is path to OpenPype repository.
|
||||
|
||||
Args:
|
||||
path (str): Path to validate.
|
||||
|
|
@ -187,10 +187,10 @@ def validate_path_string(path: str) -> (bool, str):
|
|||
return True, "valid path"
|
||||
|
||||
|
||||
def get_pype_global_settings(url: str) -> dict:
|
||||
def get_openpype_global_settings(url: str) -> dict:
|
||||
"""Load global settings from Mongo database.
|
||||
|
||||
We are loading data from database `pype` and collection `settings`.
|
||||
We are loading data from database `openpype` and collection `settings`.
|
||||
There we expect document type `global_settings`.
|
||||
|
||||
Args:
|
||||
|
|
@ -215,7 +215,7 @@ def get_pype_global_settings(url: str) -> dict:
|
|||
# Create mongo connection
|
||||
client = MongoClient(**mongo_kwargs)
|
||||
# Access settings collection
|
||||
col = client["pype"]["settings"]
|
||||
col = client["openpype"]["settings"]
|
||||
# Query global settings
|
||||
global_settings = col.find_one({"type": "global_settings"}) or {}
|
||||
# Close Mongo connection
|
||||
|
|
@ -228,22 +228,22 @@ def get_pype_global_settings(url: str) -> dict:
|
|||
return global_settings.get("data") or {}
|
||||
|
||||
|
||||
def get_pype_path_from_db(url: str) -> Union[str, None]:
|
||||
"""Get Pype path from global settings.
|
||||
def get_openpype_path_from_db(url: str) -> Union[str, None]:
|
||||
"""Get OpenPype path from global settings.
|
||||
|
||||
Args:
|
||||
url (str): mongodb url.
|
||||
|
||||
Returns:
|
||||
path to Pype or None if not found
|
||||
path to OpenPype or None if not found
|
||||
"""
|
||||
global_settings = get_pype_global_settings(url)
|
||||
global_settings = get_openpype_global_settings(url)
|
||||
paths = (
|
||||
global_settings
|
||||
.get("pype_path", {})
|
||||
.get("openpype_path", {})
|
||||
.get(platform.system().lower())
|
||||
) or []
|
||||
# For cases when `pype_path` is a single path
|
||||
# For cases when `openpype_path` is a single path
|
||||
if paths and isinstance(paths, str):
|
||||
paths = [paths]
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class ASettingRegistry():
|
|||
"""Delete item from settings.
|
||||
|
||||
Note:
|
||||
see :meth:`pype.lib.user_settings.ARegistrySettings.delete_item`
|
||||
see :meth:`openpype.lib.user_settings.ARegistrySettings.delete_item`
|
||||
|
||||
"""
|
||||
pass
|
||||
|
|
@ -216,7 +216,7 @@ class IniSettingRegistry(ASettingRegistry):
|
|||
if not os.path.exists(self._registry_file):
|
||||
with open(self._registry_file, mode="w") as cfg:
|
||||
print("# Settings registry", cfg)
|
||||
print("# Generated by Pype {}".format(version), cfg)
|
||||
print("# Generated by OpenPype {}".format(version), cfg)
|
||||
now = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
|
||||
print("# {}".format(now), cfg)
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ class IniSettingRegistry(ASettingRegistry):
|
|||
"""Delete item from default section.
|
||||
|
||||
Note:
|
||||
See :meth:`~pype.lib.IniSettingsRegistry.delete_item_from_section`
|
||||
See :meth:`~openpype.lib.IniSettingsRegistry.delete_item_from_section`
|
||||
|
||||
"""
|
||||
self.delete_item_from_section("MAIN", name)
|
||||
|
|
@ -367,7 +367,7 @@ class JSONSettingRegistry(ASettingRegistry):
|
|||
now = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
|
||||
header = {
|
||||
"__metadata__": {
|
||||
"pype-version": os.getenv("PYPE_VERSION", "N/A"),
|
||||
"openpype-version": os.getenv("PYPE_VERSION", "N/A"),
|
||||
"generated": now
|
||||
},
|
||||
"registry": {}
|
||||
|
|
@ -385,7 +385,7 @@ class JSONSettingRegistry(ASettingRegistry):
|
|||
"""Get item value from registry json.
|
||||
|
||||
Note:
|
||||
See :meth:`pype.lib.JSONSettingRegistry.get_item`
|
||||
See :meth:`openpype.lib.JSONSettingRegistry.get_item`
|
||||
|
||||
"""
|
||||
with open(self._registry_file, mode="r") as cfg:
|
||||
|
|
@ -418,7 +418,7 @@ class JSONSettingRegistry(ASettingRegistry):
|
|||
"""Set item value to registry json.
|
||||
|
||||
Note:
|
||||
See :meth:`pype.lib.JSONSettingRegistry.set_item`
|
||||
See :meth:`openpype.lib.JSONSettingRegistry.set_item`
|
||||
|
||||
"""
|
||||
with open(self._registry_file, "r+") as cfg:
|
||||
|
|
@ -450,8 +450,8 @@ class JSONSettingRegistry(ASettingRegistry):
|
|||
json.dump(data, cfg, indent=4)
|
||||
|
||||
|
||||
class PypeSettingsRegistry(JSONSettingRegistry):
|
||||
"""Class handling Pype general settings registry.
|
||||
class OpenPypeSettingsRegistry(JSONSettingRegistry):
|
||||
"""Class handling OpenPype general settings registry.
|
||||
|
||||
Attributes:
|
||||
vendor (str): Name used for path construction.
|
||||
|
|
@ -461,6 +461,7 @@ class PypeSettingsRegistry(JSONSettingRegistry):
|
|||
|
||||
def __init__(self):
|
||||
self.vendor = "pypeclub"
|
||||
self.product = "pype"
|
||||
self.product = "openpype"
|
||||
path = appdirs.user_data_dir(self.product, self.vendor)
|
||||
super(PypeSettingsRegistry, self).__init__("pype_settings", path)
|
||||
super(OpenPypeSettingsRegistry, self).__init__(
|
||||
"openpype_settings", path)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit de4312416704102a3587802d7a042e75efb99d49
|
||||
Subproject commit 911a29a44d5e6a128f4326deb1155184fe811fd7
|
||||
4
setup.py
4
setup.py
|
|
@ -53,7 +53,7 @@ excludes = []
|
|||
bin_includes = []
|
||||
include_files = [
|
||||
"igniter",
|
||||
"openpype",
|
||||
"pype",
|
||||
"repos",
|
||||
"schema",
|
||||
"vendor",
|
||||
|
|
@ -78,7 +78,7 @@ build_options = dict(
|
|||
optimize=0
|
||||
)
|
||||
|
||||
icon_path = openpype_root / "igniter" / "pype.ico"
|
||||
icon_path = openpype_root / "igniter" / "openpype.ico"
|
||||
|
||||
executables = [
|
||||
Executable("start.py", base=None,
|
||||
|
|
|
|||
216
start.py
216
start.py
|
|
@ -114,15 +114,15 @@ if getattr(sys, 'frozen', False):
|
|||
import igniter # noqa: E402
|
||||
from igniter import BootstrapRepos # noqa: E402
|
||||
from igniter.tools import get_pype_path_from_db # noqa
|
||||
from igniter.bootstrap_repos import PypeVersion # noqa: E402
|
||||
from igniter.bootstrap_repos import OpenPypeVersion # noqa: E402
|
||||
|
||||
bootstrap = BootstrapRepos()
|
||||
silent_commands = ["run", "igniter", "standalonepublisher",
|
||||
"extractenvironments"]
|
||||
|
||||
|
||||
def set_pype_global_environments() -> None:
|
||||
"""Set global pype's environments."""
|
||||
def set_openpype_global_environments() -> None:
|
||||
"""Set global OpenPype's environments."""
|
||||
import acre
|
||||
|
||||
from pype.settings import get_environments
|
||||
|
|
@ -148,13 +148,13 @@ def set_pype_global_environments() -> None:
|
|||
def run(arguments: list, env: dict = None) -> int:
|
||||
"""Use correct executable to run stuff.
|
||||
|
||||
This passing arguments to correct Pype executable. If Pype is run from
|
||||
live sources, executable will be `python` in virtual environment.
|
||||
If running from frozen code, executable will be `pype`. Its equivalent in
|
||||
live code is `python start.py`.
|
||||
This passing arguments to correct OpenPype executable. If OpenPype is run
|
||||
from live sources, executable will be `python` in virtual environment.
|
||||
If running from frozen code, executable will be `openpype_console` or
|
||||
`openpype_gui`. Its equivalent in live code is `python start.py`.
|
||||
|
||||
Args:
|
||||
arguments (list): Argument list to pass Pype.
|
||||
arguments (list): Argument list to pass OpenPype.
|
||||
env (dict, optional): Dictionary containing environment.
|
||||
|
||||
Returns:
|
||||
|
|
@ -183,7 +183,7 @@ def set_avalon_environments():
|
|||
"""
|
||||
from pype import PACKAGE_DIR
|
||||
|
||||
# Path to pype's schema
|
||||
# Path to OpenPype's schema
|
||||
schema_path = os.path.join(
|
||||
os.path.dirname(PACKAGE_DIR),
|
||||
"schema"
|
||||
|
|
@ -194,22 +194,22 @@ def set_avalon_environments():
|
|||
or os.environ["PYPE_MONGO"]
|
||||
)
|
||||
os.environ.update({
|
||||
# Mongo url (use same as pype has)
|
||||
# Mongo url (use same as OpenPype has)
|
||||
"AVALON_MONGO": avalon_mongo_url,
|
||||
|
||||
"AVALON_SCHEMA": schema_path,
|
||||
# Mongo DB name where avalon docs are stored
|
||||
"AVALON_DB": "avalon",
|
||||
# Name of config
|
||||
"AVALON_CONFIG": "pype",
|
||||
"AVALON_LABEL": "Pype"
|
||||
"AVALON_CONFIG": "openpype",
|
||||
"AVALON_LABEL": "OpenPype"
|
||||
})
|
||||
|
||||
|
||||
def set_modules_environments():
|
||||
"""Set global environments for pype modules.
|
||||
"""Set global environments for OpenPype modules.
|
||||
|
||||
This requires to have pype in `sys.path`.
|
||||
This requires to have OpenPype in `sys.path`.
|
||||
"""
|
||||
|
||||
from pype.modules import ModulesManager
|
||||
|
|
@ -270,7 +270,7 @@ def _process_arguments() -> tuple:
|
|||
import igniter
|
||||
return_code = igniter.open_dialog()
|
||||
|
||||
# this is when we want to run Pype without installing anything.
|
||||
# this is when we want to run OpenPype without installing anything.
|
||||
# or we are ready to run.
|
||||
if return_code not in [2, 3]:
|
||||
sys.exit(return_code)
|
||||
|
|
@ -292,11 +292,12 @@ def _determine_mongodb() -> str:
|
|||
|
||||
"""
|
||||
|
||||
pype_mongo = os.getenv("PYPE_MONGO", None)
|
||||
if not pype_mongo:
|
||||
openpype_mongo = os.getenv("PYPE_MONGO", None)
|
||||
if not openpype_mongo:
|
||||
# try system keyring
|
||||
try:
|
||||
pype_mongo = bootstrap.registry.get_secure_item("pypeMongo")
|
||||
openpype_mongo = bootstrap.registry.get_secure_item(
|
||||
"openPypeMongo")
|
||||
except ValueError:
|
||||
print("*** No DB connection string specified.")
|
||||
print("--- launching setup UI ...")
|
||||
|
|
@ -304,34 +305,34 @@ def _determine_mongodb() -> str:
|
|||
igniter.open_dialog()
|
||||
|
||||
try:
|
||||
pype_mongo = bootstrap.registry.get_secure_item("pypeMongo")
|
||||
openpype_mongo = bootstrap.registry.get_secure_item(
|
||||
"openPypeMongo")
|
||||
except ValueError:
|
||||
raise RuntimeError("missing mongodb url")
|
||||
|
||||
return pype_mongo
|
||||
return openpype_mongo
|
||||
|
||||
|
||||
def _initialize_environment(pype_version: PypeVersion) -> None:
|
||||
version_path = pype_version.path
|
||||
os.environ["PYPE_VERSION"] = pype_version.version
|
||||
# set PYPE_ROOT to point to currently used Pype version.
|
||||
def _initialize_environment(openpype_version: OpenPypeVersion) -> None:
|
||||
version_path = openpype_version.path
|
||||
os.environ["PYPE_VERSION"] = openpype_version.version
|
||||
# set OPENPYPE_ROOT to point to currently used OpenPype version.
|
||||
os.environ["PYPE_ROOT"] = os.path.normpath(version_path.as_posix())
|
||||
# inject version to Python environment (sys.path, ...)
|
||||
print(">>> Injecting Pype version to running environment ...")
|
||||
print(">>> Injecting OpenPype version to running environment ...")
|
||||
bootstrap.add_paths_from_directory(version_path)
|
||||
|
||||
# Additional sys paths related to PYPE_ROOT directory
|
||||
# TODO move additional paths to `boot` part when PYPE_ROOT will point
|
||||
# to same hierarchy from code and from frozen pype
|
||||
# Additional sys paths related to OPENPYPE_ROOT directory
|
||||
# TODO move additional paths to `boot` part when OPENPYPE_ROOT will point
|
||||
# to same hierarchy from code and from frozen OpenPype
|
||||
additional_paths = [
|
||||
# add pype tools
|
||||
os.path.join(os.environ["PYPE_ROOT"], "pype", "pype", "tools"),
|
||||
# add common pype vendor
|
||||
# add OpenPype tools
|
||||
os.path.join(os.environ["PYPE_ROOT"], "openpype", "tools"),
|
||||
# add common OpenPype vendor
|
||||
# (common for multiple Python interpreter versions)
|
||||
os.path.join(
|
||||
os.environ["PYPE_ROOT"],
|
||||
"pype",
|
||||
"pype",
|
||||
"openpype",
|
||||
"vendor",
|
||||
"python",
|
||||
"common"
|
||||
|
|
@ -346,12 +347,12 @@ def _initialize_environment(pype_version: PypeVersion) -> None:
|
|||
os.environ["PYTHONPATH"] = os.pathsep.join(split_paths)
|
||||
|
||||
|
||||
def _find_frozen_pype(use_version: str = None,
|
||||
use_staging: bool = False) -> Path:
|
||||
"""Find Pype to run from frozen code.
|
||||
def _find_frozen_openpype(use_version: str = None,
|
||||
use_staging: bool = False) -> Path:
|
||||
"""Find OpenPype to run from frozen code.
|
||||
|
||||
This will process and modify environment variables:
|
||||
``PYTHONPATH``, ``PYPE_VERSION``, ``PYPE_ROOT``
|
||||
``PYTHONPATH``, ``OPENPYPE_VERSION``, ``OPENPYPE_ROOT``
|
||||
|
||||
Args:
|
||||
use_version (str, optional): Try to use specified version.
|
||||
|
|
@ -361,75 +362,75 @@ def _find_frozen_pype(use_version: str = None,
|
|||
Path: Path to version to be used.
|
||||
|
||||
Raises:
|
||||
RuntimeError: If no Pype version are found or no staging version
|
||||
RuntimeError: If no OpenPype version are found or no staging version
|
||||
(if requested).
|
||||
|
||||
"""
|
||||
pype_version = None
|
||||
pype_versions = bootstrap.find_pype(include_zips=True,
|
||||
staging=use_staging)
|
||||
openpype_version = None
|
||||
openpype_versions = bootstrap.find_openpype(include_zips=True,
|
||||
staging=use_staging)
|
||||
if not os.getenv("PYPE_TRYOUT"):
|
||||
try:
|
||||
# use latest one found (last in the list is latest)
|
||||
pype_version = pype_versions[-1]
|
||||
openpype_version = openpype_versions[-1]
|
||||
except IndexError:
|
||||
# no pype version found, run Igniter and ask for them.
|
||||
print('*** No Pype versions found.')
|
||||
# no OpenPype version found, run Igniter and ask for them.
|
||||
print('*** No OpenPype versions found.')
|
||||
print("--- launching setup UI ...")
|
||||
import igniter
|
||||
return_code = igniter.open_dialog()
|
||||
if return_code == 2:
|
||||
os.environ["PYPE_TRYOUT"] = "1"
|
||||
if return_code == 3:
|
||||
# run Pype after installation
|
||||
# run OpenPype after installation
|
||||
|
||||
print('>>> Finding Pype again ...')
|
||||
pype_versions = bootstrap.find_pype(staging=use_staging)
|
||||
print('>>> Finding OpenPype again ...')
|
||||
openpype_versions = bootstrap.find_openpype(
|
||||
staging=use_staging)
|
||||
try:
|
||||
pype_version = pype_versions[-1]
|
||||
openpype_version = openpype_versions[-1]
|
||||
except IndexError:
|
||||
print(("!!! Something is wrong and we didn't "
|
||||
"found it again."))
|
||||
pype_versions = None
|
||||
sys.exit(1)
|
||||
elif return_code != 2:
|
||||
print(f" . finished ({return_code})")
|
||||
sys.exit(return_code)
|
||||
|
||||
if not pype_versions:
|
||||
if not openpype_versions:
|
||||
# no Pype versions found anyway, lets use then the one
|
||||
# shipped with frozen Pype
|
||||
# shipped with frozen OpenPype
|
||||
if not os.getenv("PYPE_TRYOUT"):
|
||||
print("*** Still no luck finding Pype.")
|
||||
print("*** Still no luck finding OpenPype.")
|
||||
print(("*** We'll try to use the one coming "
|
||||
"with Pype installation."))
|
||||
"with OpenPype installation."))
|
||||
version_path = _bootstrap_from_code(use_version)
|
||||
pype_version = PypeVersion(
|
||||
openpype_version = OpenPypeVersion(
|
||||
version=BootstrapRepos.get_version(version_path),
|
||||
path=version_path)
|
||||
_initialize_environment(pype_version)
|
||||
_initialize_environment(openpype_version)
|
||||
return version_path
|
||||
|
||||
# get path of version specified in `--use-version`
|
||||
version_path = BootstrapRepos.get_version_path_from_list(
|
||||
use_version, pype_versions)
|
||||
use_version, openpype_versions)
|
||||
|
||||
if not version_path:
|
||||
if use_version is not None:
|
||||
if not pype_version:
|
||||
if not openpype_version:
|
||||
...
|
||||
else:
|
||||
print(("!!! Specified version was not found, using "
|
||||
"latest available"))
|
||||
# specified version was not found so use latest detected.
|
||||
version_path = pype_version.path
|
||||
print(f">>> Using version [ {pype_version} ]")
|
||||
version_path = openpype_version.path
|
||||
print(f">>> Using version [ {openpype_version} ]")
|
||||
print(f" From {version_path}")
|
||||
|
||||
# test if latest detected is installed (in user data dir)
|
||||
is_inside = False
|
||||
try:
|
||||
is_inside = pype_version.path.resolve().relative_to(
|
||||
is_inside = openpype_version.path.resolve().relative_to(
|
||||
bootstrap.data_dir)
|
||||
except ValueError:
|
||||
# if relative path cannot be calculated, Pype version is not
|
||||
|
|
@ -439,19 +440,19 @@ def _find_frozen_pype(use_version: str = None,
|
|||
if not is_inside:
|
||||
# install latest version to user data dir
|
||||
version_path = bootstrap.install_version(
|
||||
pype_version, force=True)
|
||||
openpype_version, force=True)
|
||||
|
||||
if pype_version.path.is_file():
|
||||
if openpype_version.path.is_file():
|
||||
print(">>> Extracting zip file ...")
|
||||
version_path = bootstrap.extract_pype(pype_version)
|
||||
pype_version.path = version_path
|
||||
version_path = bootstrap.extract_openpype(openpype_version)
|
||||
openpype_version.path = version_path
|
||||
|
||||
_initialize_environment(pype_version)
|
||||
_initialize_environment(openpype_version)
|
||||
return version_path
|
||||
|
||||
|
||||
def _bootstrap_from_code(use_version):
|
||||
"""Bootstrap live code (or the one coming with frozen Pype.
|
||||
"""Bootstrap live code (or the one coming with frozen OpenPype.
|
||||
|
||||
Args:
|
||||
use_version: (str): specific version to use.
|
||||
|
|
@ -463,35 +464,35 @@ def _bootstrap_from_code(use_version):
|
|||
# run through repos and add them to `sys.path` and `PYTHONPATH`
|
||||
# set root
|
||||
if getattr(sys, 'frozen', False):
|
||||
pype_root = os.path.normpath(
|
||||
openpype_root = os.path.normpath(
|
||||
os.path.dirname(sys.executable))
|
||||
local_version = bootstrap.get_version(Path(pype_root))
|
||||
local_version = bootstrap.get_version(Path(openpype_root))
|
||||
print(f" - running version: {local_version}")
|
||||
assert local_version
|
||||
else:
|
||||
pype_root = os.path.normpath(
|
||||
openpype_root = os.path.normpath(
|
||||
os.path.dirname(
|
||||
os.path.dirname(
|
||||
os.path.realpath(igniter.__file__))))
|
||||
# get current version of Pype
|
||||
# get current version of OpenPype
|
||||
local_version = bootstrap.get_local_live_version()
|
||||
|
||||
os.environ["PYPE_VERSION"] = local_version
|
||||
if use_version and use_version != local_version:
|
||||
pype_versions = bootstrap.find_pype(include_zips=True)
|
||||
openpype_versions = bootstrap.find_openpype(include_zips=True)
|
||||
version_path = BootstrapRepos.get_version_path_from_list(
|
||||
use_version, pype_versions)
|
||||
use_version, openpype_versions)
|
||||
if version_path:
|
||||
# use specified
|
||||
bootstrap.add_paths_from_directory(version_path)
|
||||
os.environ["PYPE_VERSION"] = use_version
|
||||
else:
|
||||
version_path = pype_root
|
||||
os.environ["PYPE_ROOT"] = pype_root
|
||||
repos = os.listdir(os.path.join(pype_root, "repos"))
|
||||
repos = [os.path.join(pype_root, "repos", repo) for repo in repos]
|
||||
version_path = openpype_root
|
||||
os.environ["PYPE_ROOT"] = openpype_root
|
||||
repos = os.listdir(os.path.join(openpype_root, "repos"))
|
||||
repos = [os.path.join(openpype_root, "repos", repo) for repo in repos]
|
||||
# add self to python paths
|
||||
repos.insert(0, pype_root)
|
||||
repos.insert(0, openpype_root)
|
||||
for repo in repos:
|
||||
sys.path.insert(0, repo)
|
||||
|
||||
|
|
@ -505,15 +506,15 @@ def _bootstrap_from_code(use_version):
|
|||
# in case when we are running without any version installed.
|
||||
if not getattr(sys, 'frozen', False):
|
||||
split_paths.append(site.getsitepackages()[-1])
|
||||
# TODO move additional paths to `boot` part when PYPE_ROOT will point
|
||||
# to same hierarchy from code and from frozen pype
|
||||
# TODO move additional paths to `boot` part when OPENPYPE_ROOT will point
|
||||
# to same hierarchy from code and from frozen OpenPype
|
||||
additional_paths = [
|
||||
# add pype tools
|
||||
os.path.join(os.environ["PYPE_ROOT"], "pype", "tools"),
|
||||
# add common pype vendor
|
||||
# add OpenPype tools
|
||||
os.path.join(os.environ["PYPE_ROOT"], "openpype", "tools"),
|
||||
# add common OpenPype vendor
|
||||
# (common for multiple Python interpreter versions)
|
||||
os.path.join(
|
||||
os.environ["PYPE_ROOT"], "pype", "vendor", "python", "common"
|
||||
os.environ["PYPE_ROOT"], "openpype", "vendor", "python", "common"
|
||||
)
|
||||
]
|
||||
for path in additional_paths:
|
||||
|
|
@ -526,7 +527,7 @@ def _bootstrap_from_code(use_version):
|
|||
|
||||
|
||||
def boot():
|
||||
"""Bootstrap Pype."""
|
||||
"""Bootstrap OpenPype."""
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Play animation
|
||||
|
|
@ -549,38 +550,39 @@ def boot():
|
|||
# ------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
pype_mongo = _determine_mongodb()
|
||||
openpype_mongo = _determine_mongodb()
|
||||
except RuntimeError as e:
|
||||
# without mongodb url we are done for.
|
||||
print(f"!!! {e}")
|
||||
sys.exit(1)
|
||||
|
||||
os.environ["PYPE_MONGO"] = pype_mongo
|
||||
os.environ["PYPE_MONGO"] = openpype_mongo
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Set environments - load Pype path from database (if set)
|
||||
# Set environments - load OpenPype path from database (if set)
|
||||
# ------------------------------------------------------------------------
|
||||
# set PYPE_ROOT to running location until proper version can be
|
||||
# set OPENPYPE_ROOT to running location until proper version can be
|
||||
# determined.
|
||||
if getattr(sys, 'frozen', False):
|
||||
os.environ["PYPE_ROOT"] = os.path.dirname(sys.executable)
|
||||
else:
|
||||
os.environ["PYPE_ROOT"] = os.path.dirname(__file__)
|
||||
|
||||
# Get Pype path from database and set it to environment so Pype can
|
||||
# find its versions there and bootstrap them.
|
||||
pype_path = get_pype_path_from_db(pype_mongo)
|
||||
if not os.getenv("PYPE_PATH") and pype_path:
|
||||
os.environ["PYPE_PATH"] = pype_path
|
||||
# Get OpenPype path from database and set it to environment so OpenPype
|
||||
# can find its versions there and bootstrap them.
|
||||
openpype_path = get_pype_path_from_db(openpype_mongo)
|
||||
if not os.getenv("PYPE_PATH") and openpype_path:
|
||||
os.environ["PYPE_PATH"] = openpype_path
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Find Pype versions
|
||||
# Find OpenPype versions
|
||||
# ------------------------------------------------------------------------
|
||||
# WARNING Environment PYPE_ROOT may change if frozen pype is executed
|
||||
# WARNING: Environment OPENPYPE_ROOT may change if frozen OpenPype
|
||||
# is executed
|
||||
if getattr(sys, 'frozen', False):
|
||||
# find versions of Pype to be used with frozen code
|
||||
# find versions of OpenPype to be used with frozen code
|
||||
try:
|
||||
version_path = _find_frozen_pype(use_version, use_staging)
|
||||
version_path = _find_frozen_openpype(use_version, use_staging)
|
||||
except RuntimeError as e:
|
||||
# no version to run
|
||||
print(f"!!! {e}")
|
||||
|
|
@ -589,7 +591,7 @@ def boot():
|
|||
version_path = _bootstrap_from_code(use_version)
|
||||
|
||||
# set this to point either to `python` from venv in case of live code
|
||||
# or to `pype` or `pype_console` in case of frozen code
|
||||
# or to `openpype` or `openpype_console` in case of frozen code
|
||||
os.environ["PYPE_EXECUTABLE"] = sys.executable
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
|
|
@ -598,7 +600,7 @@ def boot():
|
|||
os.environ["PYPE_REPOS_ROOT"] = os.path.join(
|
||||
os.environ["PYPE_ROOT"], "repos")
|
||||
|
||||
# delete Pype module and it's submodules from cache so it is used from
|
||||
# delete OpenPype module and it's submodules from cache so it is used from
|
||||
# specific version
|
||||
modules_to_del = [
|
||||
sys.modules.pop(module_name)
|
||||
|
|
@ -618,8 +620,8 @@ def boot():
|
|||
# Avalon environments must be set before avalon module is imported
|
||||
print(" - for Avalon ...")
|
||||
set_avalon_environments()
|
||||
print(" - global Pype ...")
|
||||
set_pype_global_environments()
|
||||
print(" - global OpenPype ...")
|
||||
set_openpype_global_environments()
|
||||
print(" - for modules ...")
|
||||
set_modules_environments()
|
||||
|
||||
|
|
@ -629,7 +631,7 @@ def boot():
|
|||
|
||||
assert version_path, "Version path not defined."
|
||||
info = get_info()
|
||||
info.insert(0, f">>> Using Pype from [ {version_path} ]")
|
||||
info.insert(0, f">>> Using OpenPype from [ {version_path} ]")
|
||||
|
||||
t_width = 20
|
||||
try:
|
||||
|
|
@ -638,7 +640,7 @@ def boot():
|
|||
# running without terminal
|
||||
pass
|
||||
|
||||
_header = f"*** Pype [{__version__}] "
|
||||
_header = f"*** OpenPype [{__version__}] "
|
||||
|
||||
info.insert(0, _header + "-" * (t_width - len(_header)))
|
||||
for i in info:
|
||||
|
|
@ -650,7 +652,7 @@ def boot():
|
|||
cli.main(obj={}, prog_name="pype")
|
||||
except Exception: # noqa
|
||||
exc_info = sys.exc_info()
|
||||
print("!!! Pype crashed:")
|
||||
print("!!! OpenPype crashed:")
|
||||
traceback.print_exception(*exc_info)
|
||||
sys.exit(1)
|
||||
|
||||
|
|
@ -664,10 +666,10 @@ def get_info() -> list:
|
|||
|
||||
inf = []
|
||||
if not getattr(sys, 'frozen', False):
|
||||
inf.append(("Pype variant", "staging"))
|
||||
inf.append(("OpenPype variant", "staging"))
|
||||
else:
|
||||
inf.append(("Pype variant", "production"))
|
||||
inf.append(("Running pype from", os.environ.get('PYPE_ROOT')))
|
||||
inf.append(("OpenPype variant", "production"))
|
||||
inf.append(("Running OpenPype from", os.environ.get('PYPE_ROOT')))
|
||||
inf.append(("Using mongodb", components["host"]))
|
||||
|
||||
if os.environ.get("FTRACK_SERVER"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue