Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target
*/.vscode/*
*.DS_Store
tmp_venv/*
sequencer_venv/*
.vscode/settings.json
/data
/logs
Expand Down
21 changes: 18 additions & 3 deletions crates/apollo_infra_utils/src/cairo0_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ use crate::path::resolve_project_relative_path;
static PIP_REQUIREMENTS_FILE: LazyLock<PathBuf> =
LazyLock::new(|| resolve_project_relative_path("scripts/requirements.txt").unwrap());

static ENTER_VENV_INSTRUCTIONS: LazyLock<String> = 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.
Expand All @@ -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
Expand All @@ -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
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down