diff --git a/.gitignore b/.gitignore index ca68adfce12..5484ec08468 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ target */.vscode/* *.DS_Store tmp_venv/* +sequencer_venv/* .vscode/settings.json /data /logs diff --git a/crates/apollo_infra_utils/src/cairo0_compiler.rs b/crates/apollo_infra_utils/src/cairo0_compiler.rs index bc346327988..eaf971d63bb 100644 --- a/crates/apollo_infra_utils/src/cairo0_compiler.rs +++ b/crates/apollo_infra_utils/src/cairo0_compiler.rs @@ -9,6 +9,16 @@ use crate::path::resolve_project_relative_path; static PIP_REQUIREMENTS_FILE: LazyLock = LazyLock::new(|| resolve_project_relative_path("scripts/requirements.txt").unwrap()); +static ENTER_VENV_INSTRUCTIONS: LazyLock = LazyLock::new(|| { + format!( + r#" +python3 -m venv sequencer_venv +. sequencer_venv/bin/activate +pip install -r {:#?}"#, + *PIP_REQUIREMENTS_FILE + ) +}); + /// Verifies that the required Cairo0 compiler is available; panics if unavailable. pub fn verify_cairo0_compiler_deps() { // Python compiler. Verify correct version. @@ -17,7 +27,11 @@ pub fn verify_cairo0_compiler_deps() { let cairo_lang_version_untrimmed = String::from_utf8(cairo_lang_version_output).unwrap(); let cairo_lang_version = cairo_lang_version_untrimmed.trim().split("==").nth(1).unwrap_or_else(|| { - panic!("Unexpected cairo-lang version format '{cairo_lang_version_untrimmed}'.") + panic!( + "Unexpected cairo-lang version format '{cairo_lang_version_untrimmed}'. Are you \ + in a venv? If not, run:\n{}", + *ENTER_VENV_INSTRUCTIONS + ) }); let requirements_contents = fs::read_to_string(&*PIP_REQUIREMENTS_FILE).unwrap(); let expected_cairo_lang_version = requirements_contents @@ -37,7 +51,8 @@ pub fn verify_cairo0_compiler_deps() { assert_eq!( expected_cairo_lang_version, cairo_lang_version, "cairo-lang version {expected_cairo_lang_version} not found (installed version: \ - {cairo_lang_version}). Please run:\npip3.9 install -r {:?}\nthen rerun the test.", - *PIP_REQUIREMENTS_FILE + {cairo_lang_version}). Run the following commands (enter a python venv and install \ + dependencies) and retry:\n{}", + *ENTER_VENV_INSTRUCTIONS ); } diff --git a/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs b/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs index b2e2827f165..f70b2e88f2b 100644 --- a/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs @@ -51,13 +51,8 @@ pub struct Cairo1FeatureContractMetadata { pub sierra_path: String, } -// To fix Cairo0 feature contracts, first enter a python venv and install the requirements: -// ``` -// python -m venv tmp_venv -// . tmp_venv/bin/activate -// pip install -r scripts/requirements.txt -// ``` -// Then, run the FIX_COMMAND above. +// To fix Cairo0 feature contracts, first enter a python venv and install the requirements (see +// `ENTER_VENV_INSTRUCTIONS` for how to do this). Then, run the FIX_COMMAND above. // To fix Cairo1 feature contracts, first clone the Cairo repo and checkout the required tag. // The repo should be located next to the sequencer repo: