Skip to content

Commit

Permalink
Install sc-meta when installing rust
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Sep 25, 2023
1 parent c597e34 commit 485bfaf
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 30 deletions.
24 changes: 10 additions & 14 deletions multiversx_sdk_cli/dependencies/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def install(self, tag: str, overwrite: bool) -> None:
return

self._do_install(tag)
self._install_sc_meta()
self._post_install(tag)

def _do_install(self, tag: str) -> None:
Expand All @@ -291,6 +292,11 @@ def _do_install(self, tag: str) -> None:

myprocess.run_process(args)

def _install_sc_meta(self):
logger.info("Installing multiversx-sc-meta")
args = ["cargo", "install", "multiversx-sc-meta"]
myprocess.run_process(args)

def _get_installer_url(self) -> str:
if workstation.is_windows():
return "https://win.rustup.rs"
Expand All @@ -315,23 +321,13 @@ def _is_installed_and_set_to_nightly(self) -> bool:
if not is_rust_installed:
return is_rust_installed
else:
if self._is_the_correct_rust_version_installed():
return True
else:
return False

def _is_the_correct_rust_version_installed(self) -> bool:
args = ["mxpy", "deps", "check", "rust"]
already_installed_rust_version = myprocess.run_process(args)
self._recommend_default_rust_version()
return True

def _recommend_default_rust_version(self):
module = dependencies.get_module_by_key("rust")
default_tag: str = config.get_dependency_tag(module.key)

Check warning on line 329 in multiversx_sdk_cli/dependencies/modules.py

View workflow job for this annotation

GitHub Actions / runner / mypy

[mypy] reported by reviewdog 🐶 By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] Raw Output: /home/runner/work/mx-sdk-py-cli/mx-sdk-py-cli/multiversx_sdk_cli/dependencies/modules.py:329:9: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]

if default_tag in already_installed_rust_version:
return True

show_warning("The rust version you have installed does not match the version we recommand. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.")
return False
show_warning(f"We recommend using rust {default_tag}. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.")

def get_directory(self, tag: str) -> Path:
tools_folder = workstation.get_tools_folder()
Expand Down
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/tests/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PROXY="${PROXY:-http://localhost:7950}"
CHAIN_ID="${CHAIN_ID:-localnet}"
TestUser=./testdata/testUser.pem
TestUser2=./testdata/testUser2.pem
RUST_VERSION="nightly-2023-04-24"
RUST_VERSION="nightly-2023-05-26"

cleanSandbox() {
rm -rf ${SANDBOX}
Expand Down
45 changes: 45 additions & 0 deletions multiversx_sdk_cli/tests/test_cli_deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import shutil

from multiversx_sdk_cli.cli import main
from multiversx_sdk_cli.config import get_dependency_tag


def test_deps_install_rust():
default_tag = get_dependency_tag("rust")
return_code = main(["deps", "install", "rust", "--tag", default_tag])
if return_code:
assert False
else:
assert True


def test_deps_install_vmtools():
return_code = main(["deps", "install", "vmtools"])
if return_code:
assert False
else:
assert True


def test_deps_check_rust():
return_code = main(["deps", "check", "rust"])
if return_code:
assert False
else:
assert True


def test_check_sc_meta():
which_sc_meta = shutil.which("sc-meta")
if which_sc_meta:
assert True
elif which_sc_meta is None:
assert False


def test_deps_check_vmtools():
return_code = main(["deps", "check", "vmtools"])
if return_code:
assert False
else:
assert True
15 changes: 0 additions & 15 deletions multiversx_sdk_cli/tests/test_cli_deps.sh

This file was deleted.

0 comments on commit 485bfaf

Please sign in to comment.