diff --git a/igniter/__init__.py b/igniter/__init__.py index 12f3b49457..9b2816a767 100644 --- a/igniter/__init__.py +++ b/igniter/__init__.py @@ -7,6 +7,7 @@ from Qt.QtCore import Signal # noqa from .install_dialog import InstallDialog from .bootstrap_repos import BootstrapRepos +from .version import __version__ as version RESULT = 0 @@ -18,18 +19,19 @@ def get_result(res: int): RESULT = res -def run(): +def open_dialog(): """Show Igniter dialog.""" app = QtWidgets.QApplication(sys.argv) d = InstallDialog() d.finished.connect(get_result) - d.show() - app.exec_() + d.open() + app.exec() return RESULT __all__ = [ "InstallDialog", "BootstrapRepos", - "run" + "open_dialog", + "version" ] diff --git a/igniter/__main__.py b/igniter/__main__.py index d56cc893a0..b453d29d5f 100644 --- a/igniter/__main__.py +++ b/igniter/__main__.py @@ -21,7 +21,6 @@ app = QtWidgets.QApplication(sys.argv) d = InstallDialog() d.finished.connect(get_result) -d.show() -app.exec_() -print(RESULT) +d.open() +app.exec() sys.exit(RESULT) diff --git a/igniter/bootstrap_repos.py b/igniter/bootstrap_repos.py index ccf40bfafe..58d59afe88 100644 --- a/igniter/bootstrap_repos.py +++ b/igniter/bootstrap_repos.py @@ -337,6 +337,10 @@ class BootstrapRepos: else: version = self.get_version(repo_dir) + if not version: + self._print("Pype not found.", LOG_ERROR) + return + # create destination directory if not self.data_dir.exists(): self.data_dir.mkdir(parents=True) diff --git a/igniter/install_dialog.py b/igniter/install_dialog.py index f7bbc90fa3..9f9f921ac2 100644 --- a/igniter/install_dialog.py +++ b/igniter/install_dialog.py @@ -7,7 +7,7 @@ from Qt import QtCore, QtGui, QtWidgets # noqa from Qt.QtGui import QValidator # noqa from Qt.QtCore import QTimer # noqa -from .install_thread import InstallThread +from .install_thread import InstallThread, InstallResult from .tools import ( validate_path_string, validate_mongo_connection, @@ -107,11 +107,15 @@ class InstallDialog(QtWidgets.QDialog): self.pype_path_label = QtWidgets.QLabel( """This is Path to studio location where Pype 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.

- Leave it empty if you want to use Pype version that come with this - installation. + Leave it empty if you want to install Pype version that comes with + this installation. +

+

+ If you want to just try Pype without installing, hit the middle + button that states "run without installation".

""" ) @@ -465,6 +469,17 @@ class InstallDialog(QtWidgets.QDialog): else: self._mongo.set_valid() + if self._pype_run_ready: + self.done(3) + return + + if self.path != "": + valid, reason = validate_path_string(self.path) + + if not valid: + self.update_console(f"!!! {reason}", True) + return + self._disable_buttons() self._install_thread = InstallThread( self.install_result_callback_handler, self) @@ -475,9 +490,9 @@ class InstallDialog(QtWidgets.QDialog): self._install_thread.set_mongo(self._mongo.get_mongo_url()) self._install_thread.start() - def install_result_callback_handler(self, status): + def install_result_callback_handler(self, result: InstallResult): """Change button behaviour based on installation outcome.""" - self.update_console(f"--- {status}") + status = result.status if status >= 0: self.install_button.setText("Run installed Pype") self._pype_run_ready = True @@ -607,7 +622,7 @@ class MongoValidator(QValidator): QValidator.State.Invalid, "need mongodb schema", mongo) return self._return_state( - QValidator.State.Intermediate, "", mongo) + QValidator.State.Intermediate, "", mongo) class PathValidator(MongoValidator): diff --git a/igniter/tools.py b/igniter/tools.py index bd9b4577a0..5e071bbc18 100644 --- a/igniter/tools.py +++ b/igniter/tools.py @@ -176,7 +176,7 @@ def validate_path_string(path: str) -> (bool, str): if not path: return False, "empty string" - if Path(path).exists(): + if not Path(path).exists(): return False, "path doesn't exists" if not Path(path).is_dir(): @@ -251,6 +251,6 @@ def get_pype_path_from_db(url: str) -> Union[str, None]: col = db.settings global_settings = col.find_one( - {"type": "global_settings"}, {"data": 1}).get("data") + {"type": "global_settings"}, {"data": 1}).get("data", {}) return global_settings.get("pype_path", {}).get(platform.system().lower()) diff --git a/start.py b/start.py index 0bcbaff9e1..72c9fe969c 100644 --- a/start.py +++ b/start.py @@ -176,6 +176,7 @@ def run(arguments: list, env: dict = None) -> int: interpreter.extend(arguments) + print("|".join(interpreter)) p = subprocess.Popen(interpreter, env=env) p.wait() print(f">>> done [{p.returncode}]") @@ -276,8 +277,12 @@ def _process_arguments() -> tuple: # this is helper to run igniter before anything else if "igniter" in sys.argv: import igniter - igniter.run() + return_code = igniter.open_dialog() + # this is when we want to run Pype without installing anything. + # or we are ready to run. + if return_code not in [2, 3]: + sys.exit(return_code) return use_version, use_staging @@ -372,29 +377,41 @@ def _find_frozen_pype(use_version: str = None, pype_version = None pype_versions = bootstrap.find_pype(include_zips=True, staging=use_staging) - try: - # use latest one found (last in the list is latest) - pype_version = pype_versions[-1] - except IndexError: - # no pype version found, run Igniter and ask for them. - print('*** No Pype versions found.') - print("--- launching setup UI ...") - return_code = run(["igniter"]) - if return_code != 0: - raise RuntimeError("igniter crashed.") - print('>>> Finding Pype again ...') - pype_versions = bootstrap.find_pype(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] except IndexError: - print("!!! Something is wrong and we didn't found it again.") - pype_versions = None + # no pype version found, run Igniter and ask for them. + print('*** No Pype 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 + + print('>>> Finding Pype again ...') + pype_versions = bootstrap.find_pype(staging=use_staging) + try: + pype_version = pype_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: # no Pype versions found anyway, lets use then the one # shipped with frozen Pype - print("*** Still no luck finding Pype.") - print("*** We'll try to use the one coming with Pype installation.") + if not os.getenv("PYPE_TRYOUT"): + print("*** Still no luck finding Pype.") + print(("*** We'll try to use the one coming " + "with Pype installation.")) version_path = _bootstrap_from_code(use_version) pype_version = PypeVersion( version=BootstrapRepos.get_version(version_path), diff --git a/tools/build_dependencies.py b/tools/build_dependencies.py index 0125de5211..ada786e96f 100644 --- a/tools/build_dependencies.py +++ b/tools/build_dependencies.py @@ -95,11 +95,16 @@ libs_dir = build_dir / "lib" to_delete = [] _print("Finding duplicates ...") +deps_items = list(deps_dir.iterdir()) for d in libs_dir.iterdir(): - if (deps_dir / d.name) in deps_dir.iterdir(): + if (deps_dir / d.name) in deps_items: to_delete.append(d) _print(f"found {d}", 3) +# add pype and igniter in libs too +to_delete.append(libs_dir / "pype") +to_delete.append(libs_dir / "igniter") + # delete duplicates _print(f"Deleting {len(to_delete)} duplicates ...") for d in to_delete: