Skip to content

Commit f8d0a42

Browse files
chore(apollo_infra_utils): explicit instructions in verify_cairo0_compiler_deps
1 parent 29e0073 commit f8d0a42

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ target
1818
*/.vscode/*
1919
*.DS_Store
2020
tmp_venv/*
21+
sequencer_venv/*
2122
.vscode/settings.json
2223
/data
2324
/logs

crates/apollo_infra_utils/src/cairo0_compiler.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ use crate::path::resolve_project_relative_path;
99
static PIP_REQUIREMENTS_FILE: LazyLock<PathBuf> =
1010
LazyLock::new(|| resolve_project_relative_path("scripts/requirements.txt").unwrap());
1111

12+
static ENTER_VENV_INSTRUCTIONS: LazyLock<String> = LazyLock::new(|| {
13+
format!(
14+
r#"
15+
python3 -m venv sequencer_venv
16+
. sequencer_venv/bin/activate
17+
pip install -r {:#?}"#,
18+
*PIP_REQUIREMENTS_FILE
19+
)
20+
});
21+
1222
/// Verifies that the required Cairo0 compiler is available; panics if unavailable.
1323
pub fn verify_cairo0_compiler_deps() {
1424
// Python compiler. Verify correct version.
@@ -17,7 +27,11 @@ pub fn verify_cairo0_compiler_deps() {
1727
let cairo_lang_version_untrimmed = String::from_utf8(cairo_lang_version_output).unwrap();
1828
let cairo_lang_version =
1929
cairo_lang_version_untrimmed.trim().split("==").nth(1).unwrap_or_else(|| {
20-
panic!("Unexpected cairo-lang version format '{cairo_lang_version_untrimmed}'.")
30+
panic!(
31+
"Unexpected cairo-lang version format '{cairo_lang_version_untrimmed}'. Are you \
32+
in a venv? If not, run:\n{}",
33+
*ENTER_VENV_INSTRUCTIONS
34+
)
2135
});
2236
let requirements_contents = fs::read_to_string(&*PIP_REQUIREMENTS_FILE).unwrap();
2337
let expected_cairo_lang_version = requirements_contents
@@ -37,7 +51,8 @@ pub fn verify_cairo0_compiler_deps() {
3751
assert_eq!(
3852
expected_cairo_lang_version, cairo_lang_version,
3953
"cairo-lang version {expected_cairo_lang_version} not found (installed version: \
40-
{cairo_lang_version}). Please run:\npip3.9 install -r {:?}\nthen rerun the test.",
41-
*PIP_REQUIREMENTS_FILE
54+
{cairo_lang_version}). Run the following commands (enter a python venv and install \
55+
dependencies) and retry:\n{}",
56+
*ENTER_VENV_INSTRUCTIONS
4257
);
4358
}

crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ pub struct Cairo1FeatureContractMetadata {
5151
pub sierra_path: String,
5252
}
5353

54-
// To fix Cairo0 feature contracts, first enter a python venv and install the requirements:
55-
// ```
56-
// python -m venv tmp_venv
57-
// . tmp_venv/bin/activate
58-
// pip install -r scripts/requirements.txt
59-
// ```
60-
// Then, run the FIX_COMMAND above.
54+
// To fix Cairo0 feature contracts, first enter a python venv and install the requirements (see
55+
// `ENTER_VENV_INSTRUCTIONS` for how to do this). Then, run the FIX_COMMAND above.
6156

6257
// To fix Cairo1 feature contracts, first clone the Cairo repo and checkout the required tag.
6358
// The repo should be located next to the sequencer repo:

0 commit comments

Comments
 (0)