rename done in igniter

This commit is contained in:
Ondrej Samohel 2021-04-01 16:51:44 +02:00
parent 2e5aa101e2
commit eb829e2ed3
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
9 changed files with 422 additions and 408 deletions

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Bootstrap Pype repositories.""" """Bootstrap OpenPype repositories."""
import functools import functools
import logging as log import logging as log
import os import os
@ -14,8 +14,8 @@ from zipfile import ZipFile, BadZipFile
from appdirs import user_data_dir from appdirs import user_data_dir
from speedcopy import copyfile from speedcopy import copyfile
from .user_settings import PypeSettingsRegistry from .user_settings import OpenPypeSettingsRegistry
from .tools import get_pype_path_from_db from .tools import get_openpype_path_from_db
LOG_INFO = 0 LOG_INFO = 0
@ -24,8 +24,8 @@ LOG_ERROR = 3
@functools.total_ordering @functools.total_ordering
class PypeVersion: class OpenPypeVersion:
"""Class for storing information about Pype version. """Class for storing information about OpenPype version.
Attributes: Attributes:
major (int): [1].2.3-client-variant major (int): [1].2.3-client-variant
@ -33,7 +33,7 @@ class PypeVersion:
subversion (int): 1.2.[3]-client-variant subversion (int): 1.2.[3]-client-variant
client (str): 1.2.3-[client]-variant client (str): 1.2.3-[client]-variant
variant (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 major = 0
@ -191,37 +191,37 @@ class PypeVersion:
@staticmethod @staticmethod
def version_in_str(string: str) -> Tuple: def version_in_str(string: str) -> Tuple:
"""Find Pype version in given string. """Find OpenPype version in given string.
Args: Args:
string (str): string to search. string (str): string to search.
Returns: Returns:
tuple: True/False and PypeVersion if found. tuple: True/False and OpenPypeVersion if found.
""" """
try: try:
result = PypeVersion._decompose_version(string) result = OpenPypeVersion._decompose_version(string)
except ValueError: except ValueError:
return False, None return False, None
return True, PypeVersion(major=result[0], return True, OpenPypeVersion(major=result[0],
minor=result[1], minor=result[1],
subversion=result[2], subversion=result[2],
variant=result[3], variant=result[3],
client=result[4]) client=result[4])
class BootstrapRepos: class BootstrapRepos:
"""Class for bootstrapping local Pype installation. """Class for bootstrapping local OpenPype installation.
Attributes: 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, live_repo_dir (Path): path to repos directory if running live,
otherwise `None`. otherwise `None`.
registry (PypeSettingsRegistry): Pype registry object. registry (OpenPypeSettingsRegistry): OpenPype registry object.
zip_filter (list): List of files to exclude from zip zip_filter (list): List of files to exclude from zip
pype_filter (list): list of top level directories not to include in openpype_filter (list): list of top level directories not to
zip in Pype repository. include in zip in OpenPype repository.
""" """
@ -236,12 +236,12 @@ class BootstrapRepos:
""" """
# vendor and app used to construct user data dir # vendor and app used to construct user data dir
self._vendor = "pypeclub" self._vendor = "pypeclub"
self._app = "pype" self._app = "openpype"
self._log = log.getLogger(str(__class__)) self._log = log.getLogger(str(__class__))
self.data_dir = Path(user_data_dir(self._app, self._vendor)) self.data_dir = Path(user_data_dir(self._app, self._vendor))
self.registry = PypeSettingsRegistry() self.registry = OpenPypeSettingsRegistry()
self.zip_filter = [".pyc", "__pycache__"] self.zip_filter = [".pyc", "__pycache__"]
self.pype_filter = [ self.openpype_filter = [
"build", "docs", "tests", "repos", "tools", "venv" "build", "docs", "tests", "repos", "tools", "venv"
] ]
self._message = message self._message = message
@ -262,11 +262,11 @@ class BootstrapRepos:
@staticmethod @staticmethod
def get_version_path_from_list(version: str, version_list: list) -> Path: 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: Args:
version (str): Version string to look for (1.2.4-staging) 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: Returns:
Path: Path to given version. Path: Path to given version.
@ -278,31 +278,32 @@ class BootstrapRepos:
@staticmethod @staticmethod
def get_local_live_version() -> str: def get_local_live_version() -> str:
"""Get version of local Pype.""" """Get version of local OpenPype."""
version = {} 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: with open(path, "r") as fp:
exec(fp.read(), version) exec(fp.read(), version)
return version["__version__"] return version["__version__"]
@staticmethod @staticmethod
def get_version(repo_dir: Path) -> Union[str, None]: 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 Note: in frozen OpenPype installed in user data dir, this must point
one level deeper as it is `pype-version-v3.0.0/pype/pype/version.py` one level deeper as it is:
`openpype-version-v3.0.0/openpype/version.py`
Args: Args:
repo_dir (Path): Path to Pype repo. repo_dir (Path): Path to OpenPype repo.
Returns: Returns:
str: version string. str: version string.
None: if Pype is not found. None: if OpenPype is not found.
""" """
# try to find version # 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(): if not version_file.exists():
return None return None
@ -313,22 +314,22 @@ class BootstrapRepos:
return version['__version__'] return version['__version__']
def create_version_from_live_code( def create_version_from_live_code(
self, repo_dir: Path = None) -> Union[PypeVersion, None]: self, repo_dir: Path = None) -> Union[OpenPypeVersion, None]:
"""Copy zip created from Pype repositories to user data dir. """Copy zip created from OpenPype repositories to user data dir.
This detect Pype version either in local "live" Pype repository This detect OpenPype version either in local "live" OpenPype
or in user provided path. Then it will zip it in temporary directory repository or in user provided path. Then it will zip it in temporary
and finally it will move it to destination which is user data directory and finally it will move it to destination which is user
directory. Existing files will be replaced. data directory. Existing files will be replaced.
Args: Args:
repo_dir (Path, optional): Path to Pype repository. repo_dir (Path, optional): Path to OpenPype repository.
Returns: Returns:
Path: path of installed repository file. 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 # version and use it as a source. Otherwise repo_dir is user
# entered location. # entered location.
if not repo_dir: if not repo_dir:
@ -338,7 +339,7 @@ class BootstrapRepos:
version = self.get_version(repo_dir) version = self.get_version(repo_dir)
if not version: if not version:
self._print("Pype not found.", LOG_ERROR) self._print("OpenPype not found.", LOG_ERROR)
return return
# create destination directory # create destination directory
@ -348,20 +349,20 @@ class BootstrapRepos:
# create zip inside temporary directory. # create zip inside temporary directory.
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
temp_zip = \ 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._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): if not os.path.exists(temp_zip):
self._print("make archive failed.", LOG_ERROR) self._print("make archive failed.", LOG_ERROR)
return None return None
destination = self._move_zip_to_data_dir(temp_zip) 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]: 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: Args:
zip_file (Path): Path to zip file. zip_file (Path): Path to zip file.
@ -404,16 +405,16 @@ class BootstrapRepos:
result.append(item) result.append(item)
return result return result
def create_version_from_frozen_code(self) -> Union[None, PypeVersion]: def create_version_from_frozen_code(self) -> Union[None, OpenPypeVersion]:
"""Create Pype version from *frozen* code distributed by installer. """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 without setting up whole infrastructure but is strongly discouraged
in studio setup as this use local version independent of others in studio setup as this use local version independent of others
that can be out of date. that can be out of date.
Returns: Returns:
:class:`PypeVersion` zip file to be installed. :class:`OpenPypeVersion` zip file to be installed.
""" """
frozen_root = Path(sys.executable).parent frozen_root = Path(sys.executable).parent
@ -421,24 +422,24 @@ class BootstrapRepos:
repo_list = self._filter_dir( repo_list = self._filter_dir(
repo_dir, self.zip_filter) repo_dir, self.zip_filter)
# from frozen code we need igniter, pype, schema vendor # from frozen code we need igniter, openpype, schema vendor
pype_list = self._filter_dir( openpype_list = self._filter_dir(
frozen_root / "pype", self.zip_filter) frozen_root / "openpype", self.zip_filter)
pype_list += self._filter_dir( openpype_list += self._filter_dir(
frozen_root / "igniter", self.zip_filter) frozen_root / "igniter", self.zip_filter)
pype_list += self._filter_dir( openpype_list += self._filter_dir(
frozen_root / "schema", self.zip_filter) frozen_root / "schema", self.zip_filter)
pype_list += self._filter_dir( openpype_list += self._filter_dir(
frozen_root / "vendor", self.zip_filter) frozen_root / "vendor", self.zip_filter)
pype_list.append(frozen_root / "README.md") openpype_list.append(frozen_root / "README.md")
pype_list.append(frozen_root / "LICENSE") openpype_list.append(frozen_root / "LICENSE")
version = self.get_version(frozen_root) version = self.get_version(frozen_root)
# create zip inside temporary directory. # create zip inside temporary directory.
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
temp_zip = \ 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._print(f"creating zip: {temp_zip}")
with ZipFile(temp_zip, "w") as zip_file: with ZipFile(temp_zip, "w") as zip_file:
@ -453,43 +454,44 @@ class BootstrapRepos:
arc_name = file.relative_to(repo_dir) arc_name = file.relative_to(repo_dir)
zip_file.write(file, arc_name) zip_file.write(file, arc_name)
pype_inc = 48.0 / float(len(pype_list)) openpype_inc = 48.0 / float(len(openpype_list))
file: Path file: Path
for file in pype_list: for file in openpype_list:
progress += pype_inc progress += openpype_inc
self._progress_callback(int(progress)) self._progress_callback(int(progress))
arc_name = file.relative_to(frozen_root.parent) arc_name = file.relative_to(frozen_root.parent)
# we need to replace first part of path which starts with # we need to replace first part of path which starts with
# something like `exe.win/linux....` with `pype` as this # something like `exe.win/linux....` with `openpype` as this
# is expected by Pype in zip archive. # is expected by OpenPype in zip archive.
arc_name = Path("pype").joinpath(*arc_name.parts[1:]) arc_name = Path("openpype").joinpath(*arc_name.parts[1:])
zip_file.write(file, arc_name) zip_file.write(file, arc_name)
destination = self._move_zip_to_data_dir(temp_zip) 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, self,
zip_path: Path, include_dir: Path, zip_path: Path, include_dir: Path,
include_pype: bool = True) -> None: include_openpype: bool = True) -> None:
"""Pack repositories and Pype into zip. """Pack repositories and OpenPype into zip.
We are using :mod:`zipfile` instead :meth:`shutil.make_archive` We are using :mod:`zipfile` instead :meth:`shutil.make_archive`
because we need to decide what file and directories to include in zip 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 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: Args:
zip_path (str): path to zip file. zip_path (str): path to zip file.
include_dir (Path): repo directories to include. 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() include_dir = include_dir.resolve()
pype_list = [] openpype_list = []
# get filtered list of files in repositories (repos directory) # get filtered list of files in repositories (repos directory)
repo_list = self._filter_dir(include_dir, self.zip_filter) repo_list = self._filter_dir(include_dir, self.zip_filter)
# count them # count them
@ -497,13 +499,13 @@ class BootstrapRepos:
# there must be some files, otherwise `include_dir` path is wrong # there must be some files, otherwise `include_dir` path is wrong
assert repo_files != 0, f"No repositories to include in {include_dir}" assert repo_files != 0, f"No repositories to include in {include_dir}"
pype_inc = 0 openpype_inc = 0
if include_pype: if include_openpype:
# get filtered list of file in Pype repository # get filtered list of file in Pype repository
pype_list = self._filter_dir(include_dir.parent, self.zip_filter) openpype_list = self._filter_dir(include_dir.parent, self.zip_filter)
pype_files = len(pype_list) openpype_files = len(openpype_list)
repo_inc = 48.0 / float(repo_files) repo_inc = 48.0 / float(repo_files)
pype_inc = 48.0 / float(pype_files) openpype_inc = 48.0 / float(openpype_files)
else: else:
repo_inc = 98.0 / float(repo_files) repo_inc = 98.0 / float(repo_files)
@ -518,15 +520,15 @@ class BootstrapRepos:
arc_name = file.relative_to(include_dir) arc_name = file.relative_to(include_dir)
zip_file.write(file, arc_name) zip_file.write(file, arc_name)
# add pype itself # add openpype itself
if include_pype: if include_openpype:
pype_root = include_dir.parent.resolve() openpype_root = include_dir.parent.resolve()
# generate list of filtered paths # 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 file: Path
for file in pype_list: for file in openpype_list:
progress += pype_inc progress += openpype_inc
self._progress_callback(int(progress)) self._progress_callback(int(progress))
# if file resides in filtered path, skip it # if file resides in filtered path, skip it
@ -545,7 +547,8 @@ class BootstrapRepos:
self._print(f"- processing {processed_path}") self._print(f"- processing {processed_path}")
zip_file.write(file, zip_file.write(file,
"pype" / file.relative_to(pype_root)) "openpype" / file.relative_to(
openpype_root))
# test if zip is ok # test if zip is ok
zip_file.testzip() zip_file.testzip()
@ -616,49 +619,49 @@ class BootstrapRepos:
os.environ["PYTHONPATH"] = os.pathsep.join(paths) os.environ["PYTHONPATH"] = os.pathsep.join(paths)
def find_pype( def find_openpype(
self, self,
pype_path: Union[Path, str] = None, openpype_path: Union[Path, str] = None,
staging: bool = False, staging: bool = False,
include_zips: bool = False) -> Union[List[PypeVersion], None]: include_zips: bool = False) -> Union[List[OpenPypeVersion], None]:
"""Get ordered dict of detected Pype version. """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 1) First we test for ``OPENPYPE_PATH`` environment variable
2) We try to find ``pypePath`` in registry setting 2) We try to find ``openPypePath`` in registry setting
3) We use user data directory 3) We use user data directory
Args: Args:
pype_path (Path or str, optional): Try to find Pype on the given openpype_path (Path or str, optional): Try to find OpenPype on
path or url. the given path or url.
staging (bool, optional): Filter only staging version, skip them staging (bool, optional): Filter only staging version, skip them
otherwise. otherwise.
include_zips (bool, optional): If set True it will try to find 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: 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. Key is version, value is path to zip file.
None: if Pype is not found. None: if OpenPype is not found.
Todo: Todo:
implement git/url support as Pype location, so it would be implement git/url support as OpenPype location, so it would be
possible to enter git url, Pype would check it out and if it is possible to enter git url, OpenPype would check it out and if it is
ok install it as normal version. 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( raise NotImplementedError(
("Finding Pype in non-filesystem locations is" ("Finding OpenPype in non-filesystem locations is"
" not implemented yet.")) " not implemented yet."))
dir_to_search = self.data_dir dir_to_search = self.data_dir
# if we have pype_path specified, search only there. # if we have openpype_path specified, search only there.
if pype_path: if openpype_path:
dir_to_search = pype_path dir_to_search = openpype_path
else: else:
if os.getenv("PYPE_PATH"): if os.getenv("PYPE_PATH"):
if Path(os.getenv("PYPE_PATH")).exists(): if Path(os.getenv("PYPE_PATH")).exists():
@ -666,7 +669,7 @@ class BootstrapRepos:
else: else:
try: try:
registry_dir = Path( registry_dir = Path(
str(self.registry.get_item("pypePath"))) str(self.registry.get_item("openPypePath")))
if registry_dir.exists(): if registry_dir.exists():
dir_to_search = registry_dir dir_to_search = registry_dir
@ -674,22 +677,22 @@ class BootstrapRepos:
# nothing found in registry, we'll use data dir # nothing found in registry, we'll use data dir
pass 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. # remove zip file version if needed.
if not include_zips: if not include_zips:
pype_versions = [ openpype_versions = [
v for v in pype_versions if v.path.suffix != ".zip" 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]: def process_entered_location(self, location: str) -> Union[Path, None]:
"""Process user entered location string. """Process user entered location string.
It decides if location string is mongodb url or path. It decides if location string is mongodb url or path.
If it is mongodb url, it will connect and load ``PYPE_PATH`` from If it is mongodb url, it will connect and load ``OPENPYPE_PATH`` from
there and use it as path to Pype. In it is _not_ mongodb url, it 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 is assumed we have a path, this is tested and zip file is
produced and installed using :meth:`create_version_from_live_code`. produced and installed using :meth:`create_version_from_live_code`.
@ -697,51 +700,52 @@ class BootstrapRepos:
location (str): User entered location. location (str): User entered location.
Returns: Returns:
Path: to Pype zip produced from this location. Path: to OpenPype zip produced from this location.
None: Zipping failed. None: Zipping failed.
""" """
pype_path = None openpype_path = None
# try to get pype path from mongo. # try to get OpenPype path from mongo.
if location.startswith("mongodb"): if location.startswith("mongodb"):
pype_path = get_pype_path_from_db(location) pype_path = get_openpype_path_from_db(location)
if not pype_path: if not openpype_path:
self._print("cannot find PYPE_PATH in settings.") self._print("cannot find PYPE_PATH in settings.")
return None return None
# if not successful, consider location to be fs path. # if not successful, consider location to be fs path.
if not pype_path: if not openpype_path:
pype_path = Path(location) openpype_path = Path(location)
# test if this path does exist. # test if this path does exist.
if not pype_path.exists(): if not openpype_path.exists():
self._print(f"{pype_path} doesn't exists.") self._print(f"{openpype_path} doesn't exists.")
return None return None
# test if entered path isn't user data dir # 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) self._print("cannot point to user data dir", LOG_ERROR)
return None return None
# find pype zip files in location. There can be # find openpype zip files in location. There can be
# either "live" Pype repository, or multiple zip files or even # either "live" OpenPype repository, or multiple zip files or even
# multiple pype version directories. This process looks into zip # multiple OpenPype version directories. This process looks into zip
# files and directories and tries to parse `version.py` file. # 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: 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]} ]") self._print(f"latest version found is [ {versions[-1]} ]")
return self.install_version(versions[-1]) return self.install_version(versions[-1])
# if we got here, it means that location is "live" Pype repository. # if we got here, it means that location is "live"
# we'll create zip from it and move it to user data dir. # OpenPype repository. We'll create zip from it and move it to user
live_pype = self.create_version_from_live_code(pype_path) # data dir.
if not live_pype.path.exists(): live_openpype = self.create_version_from_live_code(openpype_path)
self._print(f"installing zip {live_pype} failed.", LOG_ERROR) if not live_openpype.path.exists():
self._print(f"installing zip {live_openpype} failed.", LOG_ERROR)
return None return None
# install it # install it
return self.install_version(live_pype) return self.install_version(live_openpype)
def _print(self, def _print(self,
message: str, message: str,
@ -769,11 +773,11 @@ class BootstrapRepos:
return return
self._log.info(message, exc_info=exc_info) self._log.info(message, exc_info=exc_info)
def extract_pype(self, version: PypeVersion) -> Union[Path, None]: def extract_openpype(self, version: OpenPypeVersion) -> Union[Path, None]:
"""Extract zipped Pype version to user data directory. """Extract zipped OpenPype version to user data directory.
Args: Args:
version (PypeVersion): Version of Pype. version (OpenPypeVersion): Version of OpenPype.
Returns: Returns:
Path: path to extracted version. Path: path to extracted version.
@ -819,40 +823,41 @@ class BootstrapRepos:
is_inside = path.resolve().relative_to( is_inside = path.resolve().relative_to(
self.data_dir) self.data_dir)
except ValueError: 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 # inside user data dir
pass pass
return is_inside return is_inside
def install_version(self, def install_version(self,
pype_version: PypeVersion, openpype_version: OpenPypeVersion,
force: bool = False) -> Path: force: bool = False) -> Path:
"""Install Pype version to user data directory. """Install OpenPype version to user data directory.
Args: Args:
pype_version (PypeVersion): Pype version to install. oepnpype_version (OpenPypeVersion): OpenPype version to install.
force (bool, optional): Force overwrite existing version. force (bool, optional): Force overwrite existing version.
Returns: Returns:
Path: Path to installed Pype. Path: Path to installed OpenPype.
Raises: Raises:
PypeVersionExists: If not forced and this version already exist OpenPypeVersionExists: If not forced and this version already exist
in user data directory. in user data directory.
PypeVersionInvalid: If version to install is invalid. OpenPypeVersionInvalid: If version to install is invalid.
PypeVersionIOError: If copying or zipping fail. OpenPypeVersionIOError: If copying or zipping fail.
""" """
if self.is_inside_user_data(pype_version.path) and not pype_version.path.is_file(): # noqa if self.is_inside_user_data(openpype_version.path) and not pype_version.path.is_file(): # noqa
raise PypeVersionExists("Pype already inside user data dir") raise OpenPypeVersionExists(
"OpenPype already inside user data dir")
# determine destination directory name # determine destination directory name
# for zip file strip suffix, in case of dir use whole dir name # for zip file strip suffix, in case of dir use whole dir name
if pype_version.path.is_dir(): if openpype_version.path.is_dir():
dir_name = pype_version.path.name dir_name = openpype_version.path.name
else: else:
dir_name = pype_version.path.stem dir_name = openpype_version.path.stem
destination = self.data_dir / dir_name destination = self.data_dir / dir_name
@ -864,82 +869,83 @@ class BootstrapRepos:
self._print( self._print(
f"cannot remove already existing {destination}", f"cannot remove already existing {destination}",
LOG_ERROR, exc_info=True) LOG_ERROR, exc_info=True)
raise PypeVersionIOError( raise OpenPypeVersionIOError(
f"cannot remove existing {destination}") from e f"cannot remove existing {destination}") from e
elif destination.exists() and not force: elif destination.exists() and not force:
raise PypeVersionExists(f"{destination} already exist.") raise OpenPypeVersionExists(f"{destination} already exist.")
else: else:
# create destination parent directories even if they don't exist. # create destination parent directories even if they don't exist.
destination.mkdir(parents=True) destination.mkdir(parents=True)
# version is directory # version is directory
if pype_version.path.is_dir(): if openpype_version.path.is_dir():
# create zip inside temporary directory. # create zip inside temporary directory.
self._print("Creating zip from directory ...") self._print("Creating zip from directory ...")
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
temp_zip = \ 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._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): if not os.path.exists(temp_zip):
self._print("make archive failed.", LOG_ERROR) self._print("make archive failed.", LOG_ERROR)
raise PypeVersionIOError("Zip creation failed.") raise OpenPypeVersionIOError("Zip creation failed.")
# set zip as version source # 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) # check if file is zip (by extension)
if pype_version.path.suffix.lower() != ".zip": if openpype_version.path.suffix.lower() != ".zip":
raise PypeVersionInvalid("Invalid file format") 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: try:
# copy file to destination # copy file to destination
self._print("Copying zip 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( copyfile(
pype_version.path.as_posix(), openpype_version.path.as_posix(),
_destination_zip.as_posix()) _destination_zip.as_posix())
except OSError as e: except OSError as e:
self._print( self._print(
"cannot copy version to user data directory", LOG_ERROR, "cannot copy version to user data directory", LOG_ERROR,
exc_info=True) exc_info=True)
raise PypeVersionIOError(( raise OpenPypeVersionIOError((
f"can't copy version {pype_version.path.as_posix()} " f"can't copy version {openpype_version.path.as_posix()} "
f"to destination {destination.parent.as_posix()}")) from e f"to destination {destination.parent.as_posix()}")) from e
# extract zip there # extract zip there
self._print("extracting zip to destination ...") 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) zip_ref.extractall(destination)
return destination return destination
def _is_pype_in_dir(self, def _is_openpype_in_dir(self,
dir_item: Path, dir_item: Path,
detected_version: PypeVersion) -> bool: detected_version: OpenPypeVersion) -> bool:
"""Test if path item is Pype version matching detected version. """Test if path item is OpenPype version matching detected version.
If item is directory that might (based on it's name) If item is directory that might (based on it's name)
contain Pype version, check if it really does contain contain OpenPype version, check if it really does contain
Pype and that their versions matches. OpenPype and that their versions matches.
Args: Args:
dir_item (Path): Directory to test. dir_item (Path): Directory to test.
detected_version (PypeVersion): Pype version detected from name. detected_version (OpenPypeVersion): OpenPype version detected
from name.
Returns: Returns:
True if it is valid Pype version, False otherwise. True if it is valid OpenPype version, False otherwise.
""" """
try: try:
# add one 'pype' level as inside dir there should # add one 'openpype' level as inside dir there should
# be many other repositories. # be many other repositories.
version_str = BootstrapRepos.get_version( version_str = BootstrapRepos.get_version(
dir_item / "pype") dir_item / "openpype")
version_check = PypeVersion(version=version_str) version_check = OpenPypeVersion(version=version_str)
except ValueError: except ValueError:
self._print( self._print(
f"cannot determine version from {dir_item}", True) f"cannot determine version from {dir_item}", True)
@ -955,21 +961,21 @@ class BootstrapRepos:
return False return False
return True return True
def _is_pype_in_zip(self, def _is_openpype_in_zip(self,
zip_item: Path, zip_item: Path,
detected_version: PypeVersion) -> bool: detected_version: OpenPypeVersion) -> bool:
"""Test if zip path is Pype version matching detected version. """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 inside it. If there is none, or it is different from
version specified in file name, skip it. version specified in file name, skip it.
Args: Args:
zip_item (Path): Zip file to test. zip_item (Path): Zip file to test.
detected_version (PypeVersion): Pype version detected from name. detected_version (OpenPypeVersion): Pype version detected from name.
Returns: Returns:
True if it is valid Pype version, False otherwise. True if it is valid OpenPype version, False otherwise.
""" """
# skip non-zip files # skip non-zip files
@ -979,10 +985,10 @@ class BootstrapRepos:
try: try:
with ZipFile(zip_item, "r") as zip_file: with ZipFile(zip_item, "r") as zip_file:
with zip_file.open( with zip_file.open(
"pype/pype/version.py") as version_file: "openpype/version.py") as version_file:
zip_version = {} zip_version = {}
exec(version_file.read(), zip_version) exec(version_file.read(), zip_version)
version_check = PypeVersion( version_check = OpenPypeVersion(
version=zip_version["__version__"]) version=zip_version["__version__"])
version_main = version_check.get_main_version() # noqa: E501 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) self._print(f"{zip_item} is not a zip file", True)
return False return False
except KeyError: except KeyError:
self._print("Zip does not contain Pype", True) self._print("Zip does not contain OpenPype", True)
return False return False
return True return True
def get_pype_versions(self, pype_dir: Path, staging: bool = False) -> list: def get_openpype_versions(self,
"""Get all detected Pype versions in directory. openpype_dir: Path,
staging: bool = False) -> list:
"""Get all detected OpenPype versions in directory.
Args: Args:
pype_dir (Path): Directory to scan. openpype_dir (Path): Directory to scan.
staging (bool, optional): Find staging versions if True. staging (bool, optional): Find staging versions if True.
Returns: Returns:
list of PypeVersion list of OpenPypeVersion
Throws: Throws:
ValueError: if invalid path is specified. 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") raise ValueError("specified directory is invalid")
_pype_versions = [] _openpype_versions = []
# iterate over directory in first level and find all that might # iterate over directory in first level and find all that might
# contain Pype. # contain OpenPype.
for item in pype_dir.iterdir(): for item in openpype_dir.iterdir():
# if file, strip extension, in case of dir not. # if file, strip extension, in case of dir not.
name = item.name if item.is_dir() else item.stem 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]: if result[0]:
detected_version: PypeVersion detected_version: OpenPypeVersion
detected_version = result[1] 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 item, detected_version
): ):
continue 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 item, detected_version
): ):
continue continue
detected_version.path = item detected_version.path = item
if staging and detected_version.is_staging(): 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(): 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): class OpenPypeVersionExists(Exception):
"""Exception for handling existing Pype version.""" """Exception for handling existing OpenPype version."""
pass pass
class PypeVersionInvalid(Exception): class OpenPypeVersionInvalid(Exception):
"""Exception for handling invalid Pype version.""" """Exception for handling invalid OpenPype version."""
pass pass
class PypeVersionIOError(Exception): class OpenPypeVersionIOError(Exception):
"""Exception for handling IO errors in Pype version.""" """Exception for handling IO errors in OpenPype version."""
pass pass

View file

@ -11,9 +11,9 @@ from .install_thread import InstallThread, InstallResult
from .tools import ( from .tools import (
validate_path_string, validate_path_string,
validate_mongo_connection, 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__ from .version import __version__
@ -42,7 +42,7 @@ class InstallDialog(QtWidgets.QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
super(InstallDialog, self).__init__(parent) super(InstallDialog, self).__init__(parent)
self.registry = PypeSettingsRegistry() self.registry = OpenPypeSettingsRegistry()
self.mongo_url = "" self.mongo_url = ""
try: try:
@ -50,7 +50,8 @@ class InstallDialog(QtWidgets.QDialog):
except ValueError: except ValueError:
pass pass
self.setWindowTitle(f"Pype Igniter {__version__} - Pype installation") self.setWindowTitle(
f"OpenPype Igniter {__version__} - OpenPype installation")
self._icon_path = os.path.join( self._icon_path = os.path.join(
os.path.dirname(__file__), 'openpype_icon.png') os.path.dirname(__file__), 'openpype_icon.png')
icon = QtGui.QIcon(self._icon_path) icon = QtGui.QIcon(self._icon_path)
@ -81,7 +82,7 @@ class InstallDialog(QtWidgets.QDialog):
os.path.join( os.path.join(
os.path.dirname(__file__), 'RobotoMono-Regular.ttf') os.path.dirname(__file__), 'RobotoMono-Regular.ttf')
) )
self._pype_run_ready = False self._openpype_run_ready = False
self._init_ui() self._init_ui()
@ -97,35 +98,35 @@ class InstallDialog(QtWidgets.QDialog):
# Main info # Main info
# -------------------------------------------------------------------- # --------------------------------------------------------------------
self.main_label = QtWidgets.QLabel( self.main_label = QtWidgets.QLabel(
"""Welcome to <b>Pype</b> """Welcome to <b>OpenPype</b>
<p> <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. this is as easy as setting one or two things.
<p> <p>
""") """)
self.main_label.setWordWrap(True) self.main_label.setWordWrap(True)
self.main_label.setStyleSheet("color: rgb(200, 200, 200);") self.main_label.setStyleSheet("color: rgb(200, 200, 200);")
# Pype path info # OpenPype path info
# -------------------------------------------------------------------- # --------------------------------------------------------------------
self.pype_path_label = QtWidgets.QLabel( self.openpype_path_label = QtWidgets.QLabel(
"""This is <b>Path to studio location</b> where Pype versions """This is <b>Path to studio location</b> where OpenPype versions
are stored. It will be pre-filled if your MongoDB connection is are stored. It will be pre-filled if your MongoDB connection is
already set and your studio defined this location. already set and your studio defined this location.
<p> <p>
Leave it empty if you want to install Pype version that comes with Leave it empty if you want to install OpenPype version that
this installation. comes with this installation.
</p> </p>
<p> <p>
If you want to just try Pype without installing, hit the middle If you want to just try OpenPype without installing, hit the
button that states "run without installation". middle button that states "run without installation".
</p> </p>
""" """
) )
self.pype_path_label.setWordWrap(True) self.openpype_path_label.setWordWrap(True)
self.pype_path_label.setStyleSheet("color: rgb(150, 150, 150);") self.openpype_path_label.setStyleSheet("color: rgb(150, 150, 150);")
# Path/Url box | Select button # Path/Url box | Select button
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -135,7 +136,7 @@ class InstallDialog(QtWidgets.QDialog):
input_layout.setContentsMargins(0, 10, 0, 10) input_layout.setContentsMargins(0, 10, 0, 10)
self.user_input = FocusHandlingLineEdit() 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.textChanged.connect(self._path_changed)
self.user_input.setStyleSheet( self.user_input.setStyleSheet(
("color: rgb(233, 233, 233);" ("color: rgb(233, 233, 233);"
@ -148,7 +149,7 @@ class InstallDialog(QtWidgets.QDialog):
self._btn_select = QtWidgets.QPushButton("Select") self._btn_select = QtWidgets.QPushButton("Select")
self._btn_select.setToolTip( self._btn_select.setToolTip(
"Select Pype repository" "Select OpenPype repository"
) )
self._btn_select.setStyleSheet( self._btn_select.setStyleSheet(
("color: rgb(64, 64, 64);" ("color: rgb(64, 64, 64);"
@ -282,13 +283,13 @@ class InstallDialog(QtWidgets.QDialog):
# -------------------------------------------------------------------- # --------------------------------------------------------------------
bottom_widget = QtWidgets.QWidget() bottom_widget = QtWidgets.QWidget()
bottom_layout = QtWidgets.QHBoxLayout() bottom_layout = QtWidgets.QHBoxLayout()
pype_logo_label = QtWidgets.QLabel("pype logo") openpype_logo_label = QtWidgets.QLabel("openpype logo")
pype_logo = QtGui.QPixmap(self._icon_path) openpype_logo = QtGui.QPixmap(self._icon_path)
# pype_logo.scaled( # openpype_logo.scaled(
# pype_logo_label.width(), # openpype_logo_label.width(),
# pype_logo_label.height(), QtCore.Qt.KeepAspectRatio) # openpype_logo_label.height(), QtCore.Qt.KeepAspectRatio)
pype_logo_label.setPixmap(pype_logo) openpype_logo_label.setPixmap(openpype_logo)
pype_logo_label.setContentsMargins(10, 0, 0, 10) openpype_logo_label.setContentsMargins(10, 0, 0, 10)
# install button - - - - - - - - - - - - - - - - - - - - - - - - - - - # install button - - - - - - - - - - - - - - - - - - - - - - - - - - -
self.install_button = QtWidgets.QPushButton("Install") self.install_button = QtWidgets.QPushButton("Install")
@ -298,7 +299,7 @@ class InstallDialog(QtWidgets.QDialog):
"padding: 0.5em;") "padding: 0.5em;")
) )
self.install_button.setMinimumSize(64, 24) 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) self.install_button.clicked.connect(self._on_ok_clicked)
# run from current button - - - - - - - - - - - - - - - - - - - - - - # run from current button - - - - - - - - - - - - - - - - - - - - - -
@ -325,7 +326,7 @@ class InstallDialog(QtWidgets.QDialog):
bottom_layout.setContentsMargins(0, 10, 10, 0) bottom_layout.setContentsMargins(0, 10, 10, 0)
bottom_layout.setAlignment(QtCore.Qt.AlignVCenter) 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.addStretch(1)
bottom_layout.addWidget(self.install_button, 0, QtCore.Qt.AlignVCenter) bottom_layout.addWidget(self.install_button, 0, QtCore.Qt.AlignVCenter)
bottom_layout.addWidget(self.run_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 # add all to main
main.addWidget(self.main_label, 0) 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.addLayout(input_layout, 0)
main.addWidget(self.mongo_label, 0) main.addWidget(self.mongo_label, 0)
main.addWidget(self._mongo, 0) main.addWidget(self._mongo, 0)
@ -418,9 +419,9 @@ class InstallDialog(QtWidgets.QDialog):
self.setLayout(main) 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: 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) self.user_input.setText(self.path)
def _on_select_clicked(self): def _on_select_clicked(self):
@ -473,7 +474,7 @@ class InstallDialog(QtWidgets.QDialog):
else: else:
self._mongo.set_valid() self._mongo.set_valid()
if self._pype_run_ready: if self._openpype_run_ready:
self.done(3) self.done(3)
return return
@ -498,8 +499,8 @@ class InstallDialog(QtWidgets.QDialog):
"""Change button behaviour based on installation outcome.""" """Change button behaviour based on installation outcome."""
status = result.status status = result.status
if status >= 0: if status >= 0:
self.install_button.setText("Run installed Pype") self.install_button.setText("Run installed OpenPype")
self._pype_run_ready = True self._openpype_run_ready = True
def _update_progress(self, progress: int): def _update_progress(self, progress: int):
self._progress_bar.setValue(progress) self._progress_bar.setValue(progress)
@ -636,7 +637,7 @@ class PathValidator(MongoValidator):
"""Validate path to be accepted by Igniter. """Validate path to be accepted by Igniter.
Args: Args:
path (str): path to Pype. path (str): path to OpenPype.
pos (int): current position. pos (int): current position.
Returns: Returns:
@ -646,7 +647,7 @@ class PathValidator(MongoValidator):
""" """
# allow empty path as that will use current version coming with # allow empty path as that will use current version coming with
# Pype Igniter # OpenPype Igniter
if len(path) == 0: if len(path) == 0:
return self._return_state( return self._return_state(
QValidator.State.Acceptable, "Use version with Igniter", path) QValidator.State.Acceptable, "Use version with Igniter", path)

View file

@ -8,10 +8,10 @@ from Qt.QtCore import QThread, Signal, QObject # noqa
from .bootstrap_repos import ( from .bootstrap_repos import (
BootstrapRepos, BootstrapRepos,
PypeVersionInvalid, OpenPypeVersionInvalid,
PypeVersionIOError, OpenPypeVersionIOError,
PypeVersionExists, OpenPypeVersionExists,
PypeVersion OpenPypeVersion
) )
from .tools import validate_mongo_connection from .tools import validate_mongo_connection
@ -26,9 +26,9 @@ class InstallResult(QObject):
class InstallThread(QThread): class InstallThread(QThread):
"""Install Worker thread. """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, (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 If path contains plain repositories, they are zipped and installed to
user data dir. user data dir.
@ -49,19 +49,19 @@ class InstallThread(QThread):
def run(self): def run(self):
"""Thread entry point. """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 or copy them from location specified by user or retrieved from
database. 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( bs = BootstrapRepos(
progress_callback=self.set_progress, message=self.message) progress_callback=self.set_progress, message=self.message)
local_version = bs.get_local_live_version() 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 # zip content of `repos`, copy it to user data dir and append
# version to it. # version to it.
if not self._path: if not self._path:
@ -71,7 +71,8 @@ class InstallThread(QThread):
if not os.getenv("PYPE_MONGO"): if not os.getenv("PYPE_MONGO"):
# try to get it from settings registry # try to get it from settings registry
try: try:
self._mongo = bs.registry.get_secure_item("pypeMongo") self._mongo = bs.registry.get_secure_item(
"openPypeMongo")
except ValueError: except ValueError:
self.message.emit( self.message.emit(
"!!! We need MongoDB URL to proceed.", True) "!!! We need MongoDB URL to proceed.", True)
@ -81,33 +82,34 @@ class InstallThread(QThread):
self._mongo = os.getenv("PYPE_MONGO") self._mongo = os.getenv("PYPE_MONGO")
else: else:
self.message.emit("Saving mongo connection string ...", False) 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 os.environ["PYPE_MONGO"] = self._mongo
self.message.emit( 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) detected = bs.find_pype(include_zips=True)
if detected: if detected:
if PypeVersion( if OpenPypeVersion(
version=local_version, path=Path()) < detected[-1]: version=local_version, path=Path()) < detected[-1]:
self.message.emit(( self.message.emit((
f"Latest installed version {detected[-1]} is newer " f"Latest installed version {detected[-1]} is newer "
f"then currently running {local_version}" f"then currently running {local_version}"
), False) ), False)
self.message.emit("Skipping Pype install ...", False) self.message.emit("Skipping OpenPype install ...", False)
if detected[-1].path.suffix.lower() == ".zip": if detected[-1].path.suffix.lower() == ".zip":
bs.extract_pype(detected[-1]) bs.extract_openpype(detected[-1])
self.finished.emit(InstallResult(0)) self.finished.emit(InstallResult(0))
return 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(( self.message.emit((
f"Latest installed version is the same as " f"Latest installed version is the same as "
f"currently running {local_version}" f"currently running {local_version}"
), False) ), False)
self.message.emit("Skipping Pype install ...", False) self.message.emit("Skipping OpenPype install ...", False)
self.finished.emit(InstallResult(0)) self.finished.emit(InstallResult(0))
return return
@ -118,17 +120,17 @@ class InstallThread(QThread):
else: else:
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
self.message.emit("None detected.", True) 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) "installer."), False)
pype_version = bs.create_version_from_frozen_code() openpype_version = bs.create_version_from_frozen_code()
if not pype_version: if not openpype_version:
self.message.emit( self.message.emit(
f"!!! Install failed - {pype_version}", True) f"!!! Install failed - {openpype_version}", True)
self.finished.emit(InstallResult(-1)) self.finished.emit(InstallResult(-1))
return return
self.message.emit(f"Using: {pype_version}", False) self.message.emit(f"Using: {openpype_version}", False)
bs.install_version(pype_version) bs.install_version(openpype_version)
self.message.emit(f"Installed as {pype_version}", False) self.message.emit(f"Installed as {openpype_version}", False)
self.progress.emit(100) self.progress.emit(100)
self.finished.emit(InstallResult(1)) self.finished.emit(InstallResult(1))
return return
@ -136,38 +138,38 @@ class InstallThread(QThread):
self.message.emit("None detected.", False) self.message.emit("None detected.", False)
self.message.emit( 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() local_openpype = bs.create_version_from_live_code()
if not local_pype: if not local_openpype:
self.message.emit( self.message.emit(
f"!!! Install failed - {local_pype}", True) f"!!! Install failed - {local_openpype}", True)
self.finished.emit(InstallResult(-1)) self.finished.emit(InstallResult(-1))
return return
try: try:
bs.install_version(local_pype) bs.install_version(local_openpype)
except (PypeVersionExists, except (OpenPypeVersionExists,
PypeVersionInvalid, OpenPypeVersionInvalid,
PypeVersionIOError) as e: OpenPypeVersionIOError) as e:
self.message.emit(f"Installed failed: ", True) self.message.emit(f"Installed failed: ", True)
self.message.emit(str(e), True) self.message.emit(str(e), True)
self.finished.emit(InstallResult(-1)) self.finished.emit(InstallResult(-1))
return return
self.message.emit(f"Installed as {local_pype}", False) self.message.emit(f"Installed as {local_openpype}", False)
self.progress.emit(100) self.progress.emit(100)
return return
else: else:
# if we have mongo connection string, validate it, set it to # 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 self._mongo:
if not validate_mongo_connection(self._mongo): if not validate_mongo_connection(self._mongo):
self.message.emit( self.message.emit(
f"!!! invalid mongo url {self._mongo}", True) f"!!! invalid mongo url {self._mongo}", True)
self.finished.emit(InstallResult(-1)) self.finished.emit(InstallResult(-1))
return return
bs.registry.set_secure_item("pypeMongo", self._mongo) bs.registry.set_secure_item("openPypeMongo", self._mongo)
os.environ["PYPE_MONGO"] = self._mongo os.environ["PYPE_MONGO"] = self._mongo
self.message.emit(f"processing {self._path}", True) self.message.emit(f"processing {self._path}", True)

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Pype terminal animation.""" """OpenPype terminal animation."""
import blessed import blessed
from pathlib import Path from pathlib import Path
from time import sleep from time import sleep
@ -15,7 +15,7 @@ except AttributeError:
def play_animation(): def play_animation():
"""Play ASCII art Pype animation.""" """Play ASCII art OpenPype animation."""
if NO_TERMINAL: if NO_TERMINAL:
return return
print(term.home + term.clear) print(term.home + term.clear)

View file

@ -2,7 +2,7 @@
"""Tools used in **Igniter** GUI. """Tools used in **Igniter** GUI.
Functions ``compose_url()`` and ``decompose_url()`` are the same as in 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. version is decided.
""" """
@ -163,7 +163,7 @@ def validate_mongo_string(mongo: str) -> (bool, str):
def validate_path_string(path: 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: Args:
path (str): Path to validate. path (str): Path to validate.
@ -187,10 +187,10 @@ def validate_path_string(path: str) -> (bool, str):
return True, "valid path" 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. """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`. There we expect document type `global_settings`.
Args: Args:
@ -215,7 +215,7 @@ def get_pype_global_settings(url: str) -> dict:
# Create mongo connection # Create mongo connection
client = MongoClient(**mongo_kwargs) client = MongoClient(**mongo_kwargs)
# Access settings collection # Access settings collection
col = client["pype"]["settings"] col = client["openpype"]["settings"]
# Query global settings # Query global settings
global_settings = col.find_one({"type": "global_settings"}) or {} global_settings = col.find_one({"type": "global_settings"}) or {}
# Close Mongo connection # Close Mongo connection
@ -228,22 +228,22 @@ def get_pype_global_settings(url: str) -> dict:
return global_settings.get("data") or {} return global_settings.get("data") or {}
def get_pype_path_from_db(url: str) -> Union[str, None]: def get_openpype_path_from_db(url: str) -> Union[str, None]:
"""Get Pype path from global settings. """Get OpenPype path from global settings.
Args: Args:
url (str): mongodb url. url (str): mongodb url.
Returns: 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 = ( paths = (
global_settings global_settings
.get("pype_path", {}) .get("openpype_path", {})
.get(platform.system().lower()) .get(platform.system().lower())
) or [] ) 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): if paths and isinstance(paths, str):
paths = [paths] paths = [paths]

View file

@ -118,7 +118,7 @@ class ASettingRegistry():
"""Delete item from settings. """Delete item from settings.
Note: Note:
see :meth:`pype.lib.user_settings.ARegistrySettings.delete_item` see :meth:`openpype.lib.user_settings.ARegistrySettings.delete_item`
""" """
pass pass
@ -216,7 +216,7 @@ class IniSettingRegistry(ASettingRegistry):
if not os.path.exists(self._registry_file): if not os.path.exists(self._registry_file):
with open(self._registry_file, mode="w") as cfg: with open(self._registry_file, mode="w") as cfg:
print("# Settings registry", 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") now = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
print("# {}".format(now), cfg) print("# {}".format(now), cfg)
@ -350,7 +350,7 @@ class IniSettingRegistry(ASettingRegistry):
"""Delete item from default section. """Delete item from default section.
Note: 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) self.delete_item_from_section("MAIN", name)
@ -367,7 +367,7 @@ class JSONSettingRegistry(ASettingRegistry):
now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") now = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
header = { header = {
"__metadata__": { "__metadata__": {
"pype-version": os.getenv("PYPE_VERSION", "N/A"), "openpype-version": os.getenv("PYPE_VERSION", "N/A"),
"generated": now "generated": now
}, },
"registry": {} "registry": {}
@ -385,7 +385,7 @@ class JSONSettingRegistry(ASettingRegistry):
"""Get item value from registry json. """Get item value from registry json.
Note: Note:
See :meth:`pype.lib.JSONSettingRegistry.get_item` See :meth:`openpype.lib.JSONSettingRegistry.get_item`
""" """
with open(self._registry_file, mode="r") as cfg: with open(self._registry_file, mode="r") as cfg:
@ -418,7 +418,7 @@ class JSONSettingRegistry(ASettingRegistry):
"""Set item value to registry json. """Set item value to registry json.
Note: Note:
See :meth:`pype.lib.JSONSettingRegistry.set_item` See :meth:`openpype.lib.JSONSettingRegistry.set_item`
""" """
with open(self._registry_file, "r+") as cfg: with open(self._registry_file, "r+") as cfg:
@ -450,8 +450,8 @@ class JSONSettingRegistry(ASettingRegistry):
json.dump(data, cfg, indent=4) json.dump(data, cfg, indent=4)
class PypeSettingsRegistry(JSONSettingRegistry): class OpenPypeSettingsRegistry(JSONSettingRegistry):
"""Class handling Pype general settings registry. """Class handling OpenPype general settings registry.
Attributes: Attributes:
vendor (str): Name used for path construction. vendor (str): Name used for path construction.
@ -461,6 +461,7 @@ class PypeSettingsRegistry(JSONSettingRegistry):
def __init__(self): def __init__(self):
self.vendor = "pypeclub" self.vendor = "pypeclub"
self.product = "pype" self.product = "openpype"
path = appdirs.user_data_dir(self.product, self.vendor) 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

View file

@ -53,7 +53,7 @@ excludes = []
bin_includes = [] bin_includes = []
include_files = [ include_files = [
"igniter", "igniter",
"openpype", "pype",
"repos", "repos",
"schema", "schema",
"vendor", "vendor",
@ -78,7 +78,7 @@ build_options = dict(
optimize=0 optimize=0
) )
icon_path = openpype_root / "igniter" / "pype.ico" icon_path = openpype_root / "igniter" / "openpype.ico"
executables = [ executables = [
Executable("start.py", base=None, Executable("start.py", base=None,

216
start.py
View file

@ -114,15 +114,15 @@ if getattr(sys, 'frozen', False):
import igniter # noqa: E402 import igniter # noqa: E402
from igniter import BootstrapRepos # noqa: E402 from igniter import BootstrapRepos # noqa: E402
from igniter.tools import get_pype_path_from_db # noqa 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() bootstrap = BootstrapRepos()
silent_commands = ["run", "igniter", "standalonepublisher", silent_commands = ["run", "igniter", "standalonepublisher",
"extractenvironments"] "extractenvironments"]
def set_pype_global_environments() -> None: def set_openpype_global_environments() -> None:
"""Set global pype's environments.""" """Set global OpenPype's environments."""
import acre import acre
from pype.settings import get_environments from pype.settings import get_environments
@ -148,13 +148,13 @@ def set_pype_global_environments() -> None:
def run(arguments: list, env: dict = None) -> int: def run(arguments: list, env: dict = None) -> int:
"""Use correct executable to run stuff. """Use correct executable to run stuff.
This passing arguments to correct Pype executable. If Pype is run from This passing arguments to correct OpenPype executable. If OpenPype is run
live sources, executable will be `python` in virtual environment. from live sources, executable will be `python` in virtual environment.
If running from frozen code, executable will be `pype`. Its equivalent in If running from frozen code, executable will be `openpype_console` or
live code is `python start.py`. `openpype_gui`. Its equivalent in live code is `python start.py`.
Args: Args:
arguments (list): Argument list to pass Pype. arguments (list): Argument list to pass OpenPype.
env (dict, optional): Dictionary containing environment. env (dict, optional): Dictionary containing environment.
Returns: Returns:
@ -183,7 +183,7 @@ def set_avalon_environments():
""" """
from pype import PACKAGE_DIR from pype import PACKAGE_DIR
# Path to pype's schema # Path to OpenPype's schema
schema_path = os.path.join( schema_path = os.path.join(
os.path.dirname(PACKAGE_DIR), os.path.dirname(PACKAGE_DIR),
"schema" "schema"
@ -194,22 +194,22 @@ def set_avalon_environments():
or os.environ["PYPE_MONGO"] or os.environ["PYPE_MONGO"]
) )
os.environ.update({ os.environ.update({
# Mongo url (use same as pype has) # Mongo url (use same as OpenPype has)
"AVALON_MONGO": avalon_mongo_url, "AVALON_MONGO": avalon_mongo_url,
"AVALON_SCHEMA": schema_path, "AVALON_SCHEMA": schema_path,
# Mongo DB name where avalon docs are stored # Mongo DB name where avalon docs are stored
"AVALON_DB": "avalon", "AVALON_DB": "avalon",
# Name of config # Name of config
"AVALON_CONFIG": "pype", "AVALON_CONFIG": "openpype",
"AVALON_LABEL": "Pype" "AVALON_LABEL": "OpenPype"
}) })
def set_modules_environments(): 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 from pype.modules import ModulesManager
@ -270,7 +270,7 @@ def _process_arguments() -> tuple:
import igniter import igniter
return_code = igniter.open_dialog() 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. # or we are ready to run.
if return_code not in [2, 3]: if return_code not in [2, 3]:
sys.exit(return_code) sys.exit(return_code)
@ -292,11 +292,12 @@ def _determine_mongodb() -> str:
""" """
pype_mongo = os.getenv("PYPE_MONGO", None) openpype_mongo = os.getenv("PYPE_MONGO", None)
if not pype_mongo: if not openpype_mongo:
# try system keyring # try system keyring
try: try:
pype_mongo = bootstrap.registry.get_secure_item("pypeMongo") openpype_mongo = bootstrap.registry.get_secure_item(
"openPypeMongo")
except ValueError: except ValueError:
print("*** No DB connection string specified.") print("*** No DB connection string specified.")
print("--- launching setup UI ...") print("--- launching setup UI ...")
@ -304,34 +305,34 @@ def _determine_mongodb() -> str:
igniter.open_dialog() igniter.open_dialog()
try: try:
pype_mongo = bootstrap.registry.get_secure_item("pypeMongo") openpype_mongo = bootstrap.registry.get_secure_item(
"openPypeMongo")
except ValueError: except ValueError:
raise RuntimeError("missing mongodb url") raise RuntimeError("missing mongodb url")
return pype_mongo return openpype_mongo
def _initialize_environment(pype_version: PypeVersion) -> None: def _initialize_environment(openpype_version: OpenPypeVersion) -> None:
version_path = pype_version.path version_path = openpype_version.path
os.environ["PYPE_VERSION"] = pype_version.version os.environ["PYPE_VERSION"] = openpype_version.version
# set PYPE_ROOT to point to currently used Pype version. # set OPENPYPE_ROOT to point to currently used OpenPype version.
os.environ["PYPE_ROOT"] = os.path.normpath(version_path.as_posix()) os.environ["PYPE_ROOT"] = os.path.normpath(version_path.as_posix())
# inject version to Python environment (sys.path, ...) # 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) bootstrap.add_paths_from_directory(version_path)
# Additional sys paths related to PYPE_ROOT directory # Additional sys paths related to OPENPYPE_ROOT directory
# TODO move additional paths to `boot` part when PYPE_ROOT will point # TODO move additional paths to `boot` part when OPENPYPE_ROOT will point
# to same hierarchy from code and from frozen pype # to same hierarchy from code and from frozen OpenPype
additional_paths = [ additional_paths = [
# add pype tools # add OpenPype tools
os.path.join(os.environ["PYPE_ROOT"], "pype", "pype", "tools"), os.path.join(os.environ["PYPE_ROOT"], "openpype", "tools"),
# add common pype vendor # add common OpenPype vendor
# (common for multiple Python interpreter versions) # (common for multiple Python interpreter versions)
os.path.join( os.path.join(
os.environ["PYPE_ROOT"], os.environ["PYPE_ROOT"],
"pype", "openpype",
"pype",
"vendor", "vendor",
"python", "python",
"common" "common"
@ -346,12 +347,12 @@ def _initialize_environment(pype_version: PypeVersion) -> None:
os.environ["PYTHONPATH"] = os.pathsep.join(split_paths) os.environ["PYTHONPATH"] = os.pathsep.join(split_paths)
def _find_frozen_pype(use_version: str = None, def _find_frozen_openpype(use_version: str = None,
use_staging: bool = False) -> Path: use_staging: bool = False) -> Path:
"""Find Pype to run from frozen code. """Find OpenPype to run from frozen code.
This will process and modify environment variables: This will process and modify environment variables:
``PYTHONPATH``, ``PYPE_VERSION``, ``PYPE_ROOT`` ``PYTHONPATH``, ``OPENPYPE_VERSION``, ``OPENPYPE_ROOT``
Args: Args:
use_version (str, optional): Try to use specified version. 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. Path: Path to version to be used.
Raises: 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). (if requested).
""" """
pype_version = None openpype_version = None
pype_versions = bootstrap.find_pype(include_zips=True, openpype_versions = bootstrap.find_openpype(include_zips=True,
staging=use_staging) staging=use_staging)
if not os.getenv("PYPE_TRYOUT"): if not os.getenv("PYPE_TRYOUT"):
try: try:
# use latest one found (last in the list is latest) # use latest one found (last in the list is latest)
pype_version = pype_versions[-1] openpype_version = openpype_versions[-1]
except IndexError: except IndexError:
# no pype version found, run Igniter and ask for them. # no OpenPype version found, run Igniter and ask for them.
print('*** No Pype versions found.') print('*** No OpenPype versions found.')
print("--- launching setup UI ...") print("--- launching setup UI ...")
import igniter import igniter
return_code = igniter.open_dialog() return_code = igniter.open_dialog()
if return_code == 2: if return_code == 2:
os.environ["PYPE_TRYOUT"] = "1" os.environ["PYPE_TRYOUT"] = "1"
if return_code == 3: if return_code == 3:
# run Pype after installation # run OpenPype after installation
print('>>> Finding Pype again ...') print('>>> Finding OpenPype again ...')
pype_versions = bootstrap.find_pype(staging=use_staging) openpype_versions = bootstrap.find_openpype(
staging=use_staging)
try: try:
pype_version = pype_versions[-1] openpype_version = openpype_versions[-1]
except IndexError: except IndexError:
print(("!!! Something is wrong and we didn't " print(("!!! Something is wrong and we didn't "
"found it again.")) "found it again."))
pype_versions = None
sys.exit(1) sys.exit(1)
elif return_code != 2: elif return_code != 2:
print(f" . finished ({return_code})") print(f" . finished ({return_code})")
sys.exit(return_code) sys.exit(return_code)
if not pype_versions: if not openpype_versions:
# no Pype versions found anyway, lets use then the one # no Pype versions found anyway, lets use then the one
# shipped with frozen Pype # shipped with frozen OpenPype
if not os.getenv("PYPE_TRYOUT"): 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 " print(("*** We'll try to use the one coming "
"with Pype installation.")) "with OpenPype installation."))
version_path = _bootstrap_from_code(use_version) version_path = _bootstrap_from_code(use_version)
pype_version = PypeVersion( openpype_version = OpenPypeVersion(
version=BootstrapRepos.get_version(version_path), version=BootstrapRepos.get_version(version_path),
path=version_path) path=version_path)
_initialize_environment(pype_version) _initialize_environment(openpype_version)
return version_path return version_path
# get path of version specified in `--use-version` # get path of version specified in `--use-version`
version_path = BootstrapRepos.get_version_path_from_list( version_path = BootstrapRepos.get_version_path_from_list(
use_version, pype_versions) use_version, openpype_versions)
if not version_path: if not version_path:
if use_version is not None: if use_version is not None:
if not pype_version: if not openpype_version:
... ...
else: else:
print(("!!! Specified version was not found, using " print(("!!! Specified version was not found, using "
"latest available")) "latest available"))
# specified version was not found so use latest detected. # specified version was not found so use latest detected.
version_path = pype_version.path version_path = openpype_version.path
print(f">>> Using version [ {pype_version} ]") print(f">>> Using version [ {openpype_version} ]")
print(f" From {version_path}") print(f" From {version_path}")
# test if latest detected is installed (in user data dir) # test if latest detected is installed (in user data dir)
is_inside = False is_inside = False
try: try:
is_inside = pype_version.path.resolve().relative_to( is_inside = openpype_version.path.resolve().relative_to(
bootstrap.data_dir) bootstrap.data_dir)
except ValueError: except ValueError:
# if relative path cannot be calculated, Pype version is not # 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: if not is_inside:
# install latest version to user data dir # install latest version to user data dir
version_path = bootstrap.install_version( 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 ...") print(">>> Extracting zip file ...")
version_path = bootstrap.extract_pype(pype_version) version_path = bootstrap.extract_openpype(openpype_version)
pype_version.path = version_path openpype_version.path = version_path
_initialize_environment(pype_version) _initialize_environment(openpype_version)
return version_path return version_path
def _bootstrap_from_code(use_version): 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: Args:
use_version: (str): specific version to use. 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` # run through repos and add them to `sys.path` and `PYTHONPATH`
# set root # set root
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
pype_root = os.path.normpath( openpype_root = os.path.normpath(
os.path.dirname(sys.executable)) 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}") print(f" - running version: {local_version}")
assert local_version assert local_version
else: else:
pype_root = os.path.normpath( openpype_root = os.path.normpath(
os.path.dirname( os.path.dirname(
os.path.dirname( os.path.dirname(
os.path.realpath(igniter.__file__)))) os.path.realpath(igniter.__file__))))
# get current version of Pype # get current version of OpenPype
local_version = bootstrap.get_local_live_version() local_version = bootstrap.get_local_live_version()
os.environ["PYPE_VERSION"] = local_version os.environ["PYPE_VERSION"] = local_version
if use_version and use_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( version_path = BootstrapRepos.get_version_path_from_list(
use_version, pype_versions) use_version, openpype_versions)
if version_path: if version_path:
# use specified # use specified
bootstrap.add_paths_from_directory(version_path) bootstrap.add_paths_from_directory(version_path)
os.environ["PYPE_VERSION"] = use_version os.environ["PYPE_VERSION"] = use_version
else: else:
version_path = pype_root version_path = openpype_root
os.environ["PYPE_ROOT"] = pype_root os.environ["PYPE_ROOT"] = openpype_root
repos = os.listdir(os.path.join(pype_root, "repos")) repos = os.listdir(os.path.join(openpype_root, "repos"))
repos = [os.path.join(pype_root, "repos", repo) for repo in repos] repos = [os.path.join(openpype_root, "repos", repo) for repo in repos]
# add self to python paths # add self to python paths
repos.insert(0, pype_root) repos.insert(0, openpype_root)
for repo in repos: for repo in repos:
sys.path.insert(0, repo) 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. # in case when we are running without any version installed.
if not getattr(sys, 'frozen', False): if not getattr(sys, 'frozen', False):
split_paths.append(site.getsitepackages()[-1]) split_paths.append(site.getsitepackages()[-1])
# TODO move additional paths to `boot` part when PYPE_ROOT will point # TODO move additional paths to `boot` part when OPENPYPE_ROOT will point
# to same hierarchy from code and from frozen pype # to same hierarchy from code and from frozen OpenPype
additional_paths = [ additional_paths = [
# add pype tools # add OpenPype tools
os.path.join(os.environ["PYPE_ROOT"], "pype", "tools"), os.path.join(os.environ["PYPE_ROOT"], "openpype", "tools"),
# add common pype vendor # add common OpenPype vendor
# (common for multiple Python interpreter versions) # (common for multiple Python interpreter versions)
os.path.join( os.path.join(
os.environ["PYPE_ROOT"], "pype", "vendor", "python", "common" os.environ["PYPE_ROOT"], "openpype", "vendor", "python", "common"
) )
] ]
for path in additional_paths: for path in additional_paths:
@ -526,7 +527,7 @@ def _bootstrap_from_code(use_version):
def boot(): def boot():
"""Bootstrap Pype.""" """Bootstrap OpenPype."""
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# Play animation # Play animation
@ -549,38 +550,39 @@ def boot():
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
try: try:
pype_mongo = _determine_mongodb() openpype_mongo = _determine_mongodb()
except RuntimeError as e: except RuntimeError as e:
# without mongodb url we are done for. # without mongodb url we are done for.
print(f"!!! {e}") print(f"!!! {e}")
sys.exit(1) 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. # determined.
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
os.environ["PYPE_ROOT"] = os.path.dirname(sys.executable) os.environ["PYPE_ROOT"] = os.path.dirname(sys.executable)
else: else:
os.environ["PYPE_ROOT"] = os.path.dirname(__file__) os.environ["PYPE_ROOT"] = os.path.dirname(__file__)
# Get Pype path from database and set it to environment so Pype can # Get OpenPype path from database and set it to environment so OpenPype
# find its versions there and bootstrap them. # can find its versions there and bootstrap them.
pype_path = get_pype_path_from_db(pype_mongo) openpype_path = get_pype_path_from_db(openpype_mongo)
if not os.getenv("PYPE_PATH") and pype_path: if not os.getenv("PYPE_PATH") and openpype_path:
os.environ["PYPE_PATH"] = pype_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): 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: try:
version_path = _find_frozen_pype(use_version, use_staging) version_path = _find_frozen_openpype(use_version, use_staging)
except RuntimeError as e: except RuntimeError as e:
# no version to run # no version to run
print(f"!!! {e}") print(f"!!! {e}")
@ -589,7 +591,7 @@ def boot():
version_path = _bootstrap_from_code(use_version) version_path = _bootstrap_from_code(use_version)
# set this to point either to `python` from venv in case of live code # 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 os.environ["PYPE_EXECUTABLE"] = sys.executable
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
@ -598,7 +600,7 @@ def boot():
os.environ["PYPE_REPOS_ROOT"] = os.path.join( os.environ["PYPE_REPOS_ROOT"] = os.path.join(
os.environ["PYPE_ROOT"], "repos") 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 # specific version
modules_to_del = [ modules_to_del = [
sys.modules.pop(module_name) sys.modules.pop(module_name)
@ -618,8 +620,8 @@ def boot():
# Avalon environments must be set before avalon module is imported # Avalon environments must be set before avalon module is imported
print(" - for Avalon ...") print(" - for Avalon ...")
set_avalon_environments() set_avalon_environments()
print(" - global Pype ...") print(" - global OpenPype ...")
set_pype_global_environments() set_openpype_global_environments()
print(" - for modules ...") print(" - for modules ...")
set_modules_environments() set_modules_environments()
@ -629,7 +631,7 @@ def boot():
assert version_path, "Version path not defined." assert version_path, "Version path not defined."
info = get_info() info = get_info()
info.insert(0, f">>> Using Pype from [ {version_path} ]") info.insert(0, f">>> Using OpenPype from [ {version_path} ]")
t_width = 20 t_width = 20
try: try:
@ -638,7 +640,7 @@ def boot():
# running without terminal # running without terminal
pass pass
_header = f"*** Pype [{__version__}] " _header = f"*** OpenPype [{__version__}] "
info.insert(0, _header + "-" * (t_width - len(_header))) info.insert(0, _header + "-" * (t_width - len(_header)))
for i in info: for i in info:
@ -650,7 +652,7 @@ def boot():
cli.main(obj={}, prog_name="pype") cli.main(obj={}, prog_name="pype")
except Exception: # noqa except Exception: # noqa
exc_info = sys.exc_info() exc_info = sys.exc_info()
print("!!! Pype crashed:") print("!!! OpenPype crashed:")
traceback.print_exception(*exc_info) traceback.print_exception(*exc_info)
sys.exit(1) sys.exit(1)
@ -664,10 +666,10 @@ def get_info() -> list:
inf = [] inf = []
if not getattr(sys, 'frozen', False): if not getattr(sys, 'frozen', False):
inf.append(("Pype variant", "staging")) inf.append(("OpenPype variant", "staging"))
else: else:
inf.append(("Pype variant", "production")) inf.append(("OpenPype variant", "production"))
inf.append(("Running pype from", os.environ.get('PYPE_ROOT'))) inf.append(("Running OpenPype from", os.environ.get('PYPE_ROOT')))
inf.append(("Using mongodb", components["host"])) inf.append(("Using mongodb", components["host"]))
if os.environ.get("FTRACK_SERVER"): if os.environ.get("FTRACK_SERVER"):