From a9549d865fc6a9d68e98ad584bcc9455ed6cfade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 27 Nov 2023 11:04:09 +0200 Subject: [PATCH 1/5] Fix mypy adnotations (issues with older Python). --- multiversx_sdk_cli/projects/templates.py | 6 +++--- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/multiversx_sdk_cli/projects/templates.py b/multiversx_sdk_cli/projects/templates.py index bfd9fdb2..dcf57185 100644 --- a/multiversx_sdk_cli/projects/templates.py +++ b/multiversx_sdk_cli/projects/templates.py @@ -1,6 +1,6 @@ import logging from pathlib import Path -from typing import Union +from typing import List, Union from multiversx_sdk_cli import myprocess from multiversx_sdk_cli.dependencies.install import install_module @@ -35,7 +35,7 @@ def _ensure_dependencies_installed(self): logger.info("Checking if the necessarry dependencies are installed.") install_module("rust") - def _prepare_args_to_list_templates(self) -> list[str]: + def _prepare_args_to_list_templates(self) -> List[str]: args = ["sc-meta", "templates"] if self.tag: @@ -43,7 +43,7 @@ def _prepare_args_to_list_templates(self) -> list[str]: return args - def _prepare_args_to_create_new_contract_from_template(self) -> list[str]: + def _prepare_args_to_create_new_contract_from_template(self) -> List[str]: args = ["sc-meta", "new", "--template", self.template, "--path", str(self.path)] if self.name: diff --git a/pyproject.toml b/pyproject.toml index 1b9477cb..2d4cab4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "multiversx-sdk-cli" -version = "9.0.0" +version = "9.0.1" authors = [ { name="MultiversX" }, ] From 66a9f267ab8b80f80e271a3ae195e69a2219efea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 27 Nov 2023 12:07:56 +0200 Subject: [PATCH 2/5] Add extra warn messages when installing Rust. --- multiversx_sdk_cli/dependencies/modules.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/multiversx_sdk_cli/dependencies/modules.py b/multiversx_sdk_cli/dependencies/modules.py index 7c7832b5..c51f646b 100644 --- a/multiversx_sdk_cli/dependencies/modules.py +++ b/multiversx_sdk_cli/dependencies/modules.py @@ -273,10 +273,13 @@ def is_installed(self, tag: str) -> bool: return all(dependency is not None for dependency in dependencies) def install(self, overwrite: bool) -> None: + self._check_install_env() + module = dependencies.get_module_by_key("rust") tag: str = config.get_dependency_tag(module.key) - show_warning(f"We recommend using rust {tag}. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.") + if not overwrite: + show_warning(f"We recommend using rust {tag}. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.") logger.info(f"install: key={self.key}, tag={tag}, overwrite={overwrite}") if overwrite: @@ -289,6 +292,18 @@ def install(self, overwrite: bool) -> None: self._install_wasm_opt() self._install_twiggy() + def _check_install_env(self): + current_cargo_home = os.environ.get("CARGO_HOME", None) + current_rustup_home = os.environ.get("RUSTUP_HOME", None) + + # https://rust-lang.github.io/rustup/installation/index.html#choosing-where-to-install + if current_cargo_home: + show_warning(f"""CARGO_HOME variable is set to: {current_cargo_home}. +This may cause problems with the installation.""") + if current_rustup_home: + show_warning(f"""RUSTUP_HOME variable is set to: {current_rustup_home}. +This may cause problems with the installation of rust.""") + def _install_rust(self, tag: str) -> None: installer_url = self._get_installer_url() installer_path = self._get_installer_path() From 8b7d750e53470e177cb7f61dd1cf41fdab40b23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 27 Nov 2023 12:10:06 +0200 Subject: [PATCH 3/5] Bump version. --- multiversx_sdk_cli/dependencies/modules.py | 6 ++++-- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/multiversx_sdk_cli/dependencies/modules.py b/multiversx_sdk_cli/dependencies/modules.py index c51f646b..3202240c 100644 --- a/multiversx_sdk_cli/dependencies/modules.py +++ b/multiversx_sdk_cli/dependencies/modules.py @@ -293,10 +293,12 @@ def install(self, overwrite: bool) -> None: self._install_twiggy() def _check_install_env(self): + """ + See https://rust-lang.github.io/rustup/installation/index.html#choosing-where-to-install. + """ + current_cargo_home = os.environ.get("CARGO_HOME", None) current_rustup_home = os.environ.get("RUSTUP_HOME", None) - - # https://rust-lang.github.io/rustup/installation/index.html#choosing-where-to-install if current_cargo_home: show_warning(f"""CARGO_HOME variable is set to: {current_cargo_home}. This may cause problems with the installation.""") diff --git a/pyproject.toml b/pyproject.toml index 2d4cab4f..933044e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "multiversx-sdk-cli" -version = "9.0.1" +version = "9.0.2" authors = [ { name="MultiversX" }, ] From 12d51b42c923180c35f61535485ad74a002fef5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 27 Nov 2023 13:05:09 +0200 Subject: [PATCH 4/5] Fix after review. --- multiversx_sdk_cli/dependencies/modules.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/multiversx_sdk_cli/dependencies/modules.py b/multiversx_sdk_cli/dependencies/modules.py index 3202240c..3db26eff 100644 --- a/multiversx_sdk_cli/dependencies/modules.py +++ b/multiversx_sdk_cli/dependencies/modules.py @@ -273,7 +273,7 @@ def is_installed(self, tag: str) -> bool: return all(dependency is not None for dependency in dependencies) def install(self, overwrite: bool) -> None: - self._check_install_env() + self._check_install_env(apply_correction=overwrite) module = dependencies.get_module_by_key("rust") tag: str = config.get_dependency_tag(module.key) @@ -292,7 +292,7 @@ def install(self, overwrite: bool) -> None: self._install_wasm_opt() self._install_twiggy() - def _check_install_env(self): + def _check_install_env(self, apply_correction: bool = True): """ See https://rust-lang.github.io/rustup/installation/index.html#choosing-where-to-install. """ @@ -302,10 +302,19 @@ def _check_install_env(self): if current_cargo_home: show_warning(f"""CARGO_HOME variable is set to: {current_cargo_home}. This may cause problems with the installation.""") + + if apply_correction: + show_warning(f"CARGO_HOME will be temporarily unset.") + os.environ["CARGO_HOME"] = "" + if current_rustup_home: show_warning(f"""RUSTUP_HOME variable is set to: {current_rustup_home}. This may cause problems with the installation of rust.""") + if apply_correction: + show_warning(f"RUSTUP_HOME will be temporarily unset.") + os.environ["RUSTUP_HOME"] = "" + def _install_rust(self, tag: str) -> None: installer_url = self._get_installer_url() installer_path = self._get_installer_path() From e29fe6e7896e636dd6aaa430a15eb27e0e5287d9 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 11 Dec 2023 13:59:30 +0200 Subject: [PATCH 5/5] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 933044e8..a4f9d6ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "multiversx-sdk-cli" -version = "9.0.2" +version = "9.1.0" authors = [ { name="MultiversX" }, ]