Skip to content

Commit

Permalink
Merge pull request #376 from multiversx/remove-rust-autoinstall
Browse files Browse the repository at this point in the history
Throw error if Rust is not installed for contract operations: new, build, clean
  • Loading branch information
popenta authored Dec 14, 2023
2 parents 88fdd75 + 1f3d15a commit e79c3d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
shell: bash
run: |
python3 -m multiversx_sdk_cli.cli deps install testwallets
python3 -m multiversx_sdk_cli.cli deps install rust
- name: Run unit tests
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- name: Setup test dependencies
run: |
python3 -m multiversx_sdk_cli.cli deps install testwallets
python3 -m multiversx_sdk_cli.cli deps install rust
- name: Run unit tests
run: |
export PYTHONPATH=.
Expand Down
5 changes: 5 additions & 0 deletions multiversx_sdk_cli/cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
trigger_contract_verification
from multiversx_sdk_cli.contracts import SmartContract, query_contract
from multiversx_sdk_cli.cosign_transaction import cosign_transaction
from multiversx_sdk_cli.dependency_checker import check_if_rust_is_installed
from multiversx_sdk_cli.docker import is_docker_installed, run_docker
from multiversx_sdk_cli.errors import DockerMissingError, NoWalletProvided
from multiversx_sdk_cli.interfaces import IAddress
Expand Down Expand Up @@ -279,11 +280,13 @@ def get_project_paths(args: Any) -> List[Path]:


def clean(args: Any):
check_if_rust_is_installed()
project_path = args.path
projects.clean_project(Path(project_path))


def build(args: Any):
check_if_rust_is_installed()
project_paths = [Path(args.path)]
arg_list = cli_shared.convert_args_object_to_args_list(args)

Expand All @@ -292,11 +295,13 @@ def build(args: Any):


def do_report(args: Any):
check_if_rust_is_installed()
args_dict = args.__dict__
projects.do_report(args, args_dict)


def run_tests(args: Any):
check_if_rust_is_installed()
project_paths = get_project_paths(args)
for project in project_paths:
projects.run_tests(project, args)
Expand Down
11 changes: 11 additions & 0 deletions multiversx_sdk_cli/dependency_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from multiversx_sdk_cli import config, errors, ux
from multiversx_sdk_cli.dependencies.modules import Rust


def check_if_rust_is_installed():
RUST_MODULE_KEY = "rust"
rust_module = Rust(RUST_MODULE_KEY)
if not rust_module.is_installed(""):
tag = config.get_dependency_tag(RUST_MODULE_KEY)
ux.show_critical_error("Rust is not installed on your machine. Run `mxpy deps install rust --overwrite` and try again.")
raise errors.DependencyMissing(RUST_MODULE_KEY, tag)
4 changes: 2 additions & 2 deletions multiversx_sdk_cli/projects/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Union

from multiversx_sdk_cli import myprocess
from multiversx_sdk_cli.dependencies.install import install_module
from multiversx_sdk_cli.dependency_checker import check_if_rust_is_installed

logger = logging.getLogger("projects.templates")

Expand Down Expand Up @@ -33,7 +33,7 @@ def create_from_template(self) -> None:

def _ensure_dependencies_installed(self):
logger.info("Checking if the necessarry dependencies are installed.")
install_module("rust")
check_if_rust_is_installed()

def _prepare_args_to_list_templates(self) -> List[str]:
args = ["sc-meta", "templates"]
Expand Down

0 comments on commit e79c3d6

Please sign in to comment.