|
1 | | -use std::fs; |
2 | 1 | use std::io::Write; |
3 | 2 | use std::path::PathBuf; |
4 | 3 | use std::process::{Command, Output, Stdio}; |
5 | | -use std::sync::LazyLock; |
6 | 4 |
|
| 5 | +use apollo_infra_utils::cairo0_compiler::verify_cairo0_compiler_deps; |
7 | 6 | use apollo_infra_utils::cairo_compiler_version::cairo1_compiler_version; |
8 | | -use apollo_infra_utils::path::{project_path, resolve_project_relative_path}; |
| 7 | +use apollo_infra_utils::path::project_path; |
9 | 8 | use tempfile::NamedTempFile; |
10 | 9 | use tracing::info; |
11 | 10 |
|
12 | | -static CAIRO0_PIP_REQUIREMENTS_FILE: LazyLock<PathBuf> = |
13 | | - LazyLock::new(|| resolve_project_relative_path("scripts/requirements.txt").unwrap()); |
14 | | - |
15 | 11 | pub enum CompilationArtifacts { |
16 | 12 | Cairo0 { casm: Vec<u8> }, |
17 | 13 | Cairo1 { casm: Vec<u8>, sierra: Vec<u8> }, |
@@ -145,38 +141,3 @@ fn starknet_sierra_compile(path: String, version: &String) -> Vec<u8> { |
145 | 141 | let casm_output = run_and_verify_output(&mut sierra_compile_command); |
146 | 142 | casm_output.stdout |
147 | 143 | } |
148 | | - |
149 | | -/// Verifies that the required dependencies are available before compiling; panics if unavailable. |
150 | | -fn verify_cairo0_compiler_deps() { |
151 | | - // Python compiler. Verify correct version. |
152 | | - let cairo_lang_version_output = |
153 | | - Command::new("sh").arg("-c").arg("pip freeze | grep cairo-lang").output().unwrap().stdout; |
154 | | - let cairo_lang_version_untrimmed = String::from_utf8(cairo_lang_version_output).unwrap(); |
155 | | - let cairo_lang_version = |
156 | | - cairo_lang_version_untrimmed.trim().split("==").nth(1).unwrap_or_else(|| { |
157 | | - panic!("Unexpected cairo-lang version format '{cairo_lang_version_untrimmed}'.") |
158 | | - }); |
159 | | - let requirements_contents = fs::read_to_string(&*CAIRO0_PIP_REQUIREMENTS_FILE).unwrap(); |
160 | | - let expected_cairo_lang_version = requirements_contents |
161 | | - .lines() |
162 | | - .find(|line| line.starts_with("cairo-lang")) |
163 | | - .unwrap_or_else(|| { |
164 | | - panic!("Could not find cairo-lang in {:?}.", *CAIRO0_PIP_REQUIREMENTS_FILE) |
165 | | - }) |
166 | | - .trim() |
167 | | - .split("==") |
168 | | - .nth(1) |
169 | | - .unwrap_or_else(|| { |
170 | | - panic!( |
171 | | - "Malformed cairo-lang dependency (expected 'cairo-lang==X') in {:?}.", |
172 | | - *CAIRO0_PIP_REQUIREMENTS_FILE |
173 | | - ) |
174 | | - }); |
175 | | - |
176 | | - assert_eq!( |
177 | | - expected_cairo_lang_version, cairo_lang_version, |
178 | | - "cairo-lang version {expected_cairo_lang_version} not found (installed version: \ |
179 | | - {cairo_lang_version}). Please run:\npip3.9 install -r {:?}\nthen rerun the test.", |
180 | | - *CAIRO0_PIP_REQUIREMENTS_FILE |
181 | | - ); |
182 | | -} |
0 commit comments