Skip to content

Commit

Permalink
Merge pull request #372 from multiversx/merge-main-11-12
Browse files Browse the repository at this point in the history
Merge main into feat/next
  • Loading branch information
popenta authored Dec 11, 2023
2 parents eb5dadd + e29fe6e commit 03234a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
28 changes: 27 additions & 1 deletion multiversx_sdk_cli/dependencies/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(apply_correction=overwrite)

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:
Expand All @@ -289,6 +292,29 @@ def install(self, overwrite: bool) -> None:
self._install_wasm_opt()
self._install_twiggy()

def _check_install_env(self, apply_correction: bool = True):
"""
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)
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()
Expand Down
6 changes: 3 additions & 3 deletions multiversx_sdk_cli/projects/templates.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -35,15 +35,15 @@ 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:
args.extend(["--tag", self.tag])

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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "multiversx-sdk-cli"
version = "9.0.0"
version = "9.1.0"
authors = [
{ name="MultiversX" },
]
Expand Down

0 comments on commit 03234a9

Please sign in to comment.