|
| 1 | +use std::env; |
1 | 2 | use std::io::Write; |
2 | 3 | use std::path::{Path, PathBuf}; |
3 | 4 | use std::process::{Command, Output}; |
4 | | -use std::sync::LazyLock; |
5 | | -use std::{env, fs}; |
6 | 5 |
|
| 6 | +use apollo_infra_utils::cairo0_compiler::verify_cairo0_compiler_deps; |
7 | 7 | use apollo_infra_utils::cairo_compiler_version::cairo1_compiler_version; |
8 | 8 | use apollo_infra_utils::compile_time_cargo_manifest_dir; |
9 | | -use apollo_infra_utils::path::resolve_project_relative_path; |
10 | 9 | use tempfile::NamedTempFile; |
11 | 10 |
|
12 | 11 | use crate::contracts::TagAndToolchain; |
13 | 12 |
|
14 | | -static CAIRO0_PIP_REQUIREMENTS_FILE: LazyLock<PathBuf> = |
15 | | - LazyLock::new(|| resolve_project_relative_path("scripts/requirements.txt").unwrap()); |
16 | 13 | const CAIRO1_REPO_RELATIVE_PATH_OVERRIDE_ENV_VAR: &str = "CAIRO1_REPO_RELATIVE_PATH"; |
17 | 14 | const DEFAULT_CAIRO1_REPO_RELATIVE_PATH: &str = "../../../cairo"; |
18 | 15 |
|
@@ -138,35 +135,6 @@ pub fn starknet_compile( |
138 | 135 | sierra_output.stdout |
139 | 136 | } |
140 | 137 |
|
141 | | -/// Verifies that the required dependencies are available before compiling; panics if unavailable. |
142 | | -fn verify_cairo0_compiler_deps() { |
143 | | - // Python compiler. Verify correct version. |
144 | | - let cairo_lang_version_output = |
145 | | - Command::new("sh").arg("-c").arg("pip freeze | grep cairo-lang").output().unwrap().stdout; |
146 | | - let cairo_lang_version_untrimmed = String::from_utf8(cairo_lang_version_output).unwrap(); |
147 | | - let cairo_lang_version = cairo_lang_version_untrimmed.trim(); |
148 | | - let requirements_contents = fs::read_to_string(&*CAIRO0_PIP_REQUIREMENTS_FILE).unwrap(); |
149 | | - let expected_cairo_lang_version = requirements_contents |
150 | | - .lines() |
151 | | - .find(|line| line.starts_with("cairo-lang")) |
152 | | - .unwrap_or_else(|| { |
153 | | - panic!("Could not find cairo-lang in {:?}.", *CAIRO0_PIP_REQUIREMENTS_FILE) |
154 | | - }) |
155 | | - .trim(); |
156 | | - |
157 | | - assert!( |
158 | | - expected_cairo_lang_version.ends_with(cairo_lang_version), |
159 | | - "cairo-lang version {expected_cairo_lang_version} not found ({}). Please run:\npip3.9 \ |
160 | | - install -r {:?}\nthen rerun the test.", |
161 | | - if cairo_lang_version.is_empty() { |
162 | | - String::from("no installed cairo-lang found") |
163 | | - } else { |
164 | | - format!("installed version: {cairo_lang_version}") |
165 | | - }, |
166 | | - *CAIRO0_PIP_REQUIREMENTS_FILE |
167 | | - ); |
168 | | -} |
169 | | - |
170 | 138 | fn get_tag_and_repo_file_path(git_tag_override: Option<String>) -> (String, PathBuf) { |
171 | 139 | let tag = git_tag_override.unwrap_or(cairo1_compiler_tag()); |
172 | 140 | let cairo_repo_path = local_cairo1_compiler_repo_path(); |
|
0 commit comments