From 77232c5b3301636446925c8dcbb5a0145e162741 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 4 Dec 2024 14:38:58 +0200 Subject: [PATCH 1/4] chore(starknet_api): revert use get_packaget_dir instead of env var This reverts commit c45f5cc0dce72ba5b1779c95e30d7f1a8461958e. commit-id:a48736e7 --- Cargo.lock | 2 +- crates/starknet_api/Cargo.toml | 7 +++++-- crates/starknet_api/src/test_utils.rs | 12 +++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b95f307863..b01906f227 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10226,9 +10226,9 @@ dependencies = [ "derive_more 0.99.18", "hex", "indexmap 2.6.0", + "infra_utils", "itertools 0.12.1", "num-bigint 0.4.6", - "papyrus_proc_macros", "pretty_assertions", "primitive-types", "rstest", diff --git a/crates/starknet_api/Cargo.toml b/crates/starknet_api/Cargo.toml index cb9b0095f2..4fd905b38c 100644 --- a/crates/starknet_api/Cargo.toml +++ b/crates/starknet_api/Cargo.toml @@ -11,14 +11,14 @@ testing = [] [dependencies] bitvec.workspace = true -cairo-lang-runner.workspace = true cairo-lang-starknet-classes.workspace = true +cairo-lang-runner.workspace = true derive_more.workspace = true hex.workspace = true indexmap = { workspace = true, features = ["serde"] } +infra_utils.workspace = true itertools.workspace = true num-bigint.workspace = true -papyrus_proc_macros.workspace = true pretty_assertions.workspace = true primitive-types = { workspace = true, features = ["serde"] } semver.workspace = true @@ -35,5 +35,8 @@ thiserror.workspace = true assert_matches.workspace = true rstest.workspace = true +[package.metadata.cargo-machete] +ignored = ["strum"] + [lints] workspace = true diff --git a/crates/starknet_api/src/test_utils.rs b/crates/starknet_api/src/test_utils.rs index 66a3e9d09b..2addfd0ae3 100644 --- a/crates/starknet_api/src/test_utils.rs +++ b/crates/starknet_api/src/test_utils.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::fs::read_to_string; use std::path::{Path, PathBuf}; -use papyrus_proc_macros::generate_get_package_dir; +use infra_utils::path::cargo_manifest_dir; use serde::{Deserialize, Serialize}; use serde_json::to_string_pretty; use starknet_types_core::felt::Felt; @@ -17,13 +17,11 @@ pub mod deploy_account; pub mod invoke; pub mod l1_handler; -generate_get_package_dir!(); - -/// Returns the path to a file in the resources directory. This assumes the package directory has a -/// `resources` folder. The value for file_path should be the path to the required file in the -/// folder "resources". +/// Returns the path to a file in the resources directory. This assumes the current working +/// directory has a `resources` folder. The value for file_path should be the path to the required +/// file in the folder "resources". pub fn path_in_resources>(file_path: P) -> PathBuf { - PathBuf::from(get_package_dir()).join("resources").join(file_path) + cargo_manifest_dir().unwrap().join("resources").join(file_path) } /// Reads from the directory containing the manifest at run time, same as current working directory. From 611737cbc68a3bb18a4762d128085ef1e8ecdfbe Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 4 Dec 2024 15:06:56 +0200 Subject: [PATCH 2/4] chore(starknet_api): rely on env::current_dir() instead of CARGO_MANIFEST_DIR commit-id:301ed4eb --- Cargo.lock | 3 +-- crates/starknet_api/Cargo.toml | 5 +---- crates/starknet_api/src/test_utils.rs | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b01906f227..d36ee0baec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -10226,7 +10226,6 @@ dependencies = [ "derive_more 0.99.18", "hex", "indexmap 2.6.0", - "infra_utils", "itertools 0.12.1", "num-bigint 0.4.6", "pretty_assertions", diff --git a/crates/starknet_api/Cargo.toml b/crates/starknet_api/Cargo.toml index 4fd905b38c..e04f457c96 100644 --- a/crates/starknet_api/Cargo.toml +++ b/crates/starknet_api/Cargo.toml @@ -11,12 +11,11 @@ testing = [] [dependencies] bitvec.workspace = true -cairo-lang-starknet-classes.workspace = true cairo-lang-runner.workspace = true +cairo-lang-starknet-classes.workspace = true derive_more.workspace = true hex.workspace = true indexmap = { workspace = true, features = ["serde"] } -infra_utils.workspace = true itertools.workspace = true num-bigint.workspace = true pretty_assertions.workspace = true @@ -35,8 +34,6 @@ thiserror.workspace = true assert_matches.workspace = true rstest.workspace = true -[package.metadata.cargo-machete] -ignored = ["strum"] [lints] workspace = true diff --git a/crates/starknet_api/src/test_utils.rs b/crates/starknet_api/src/test_utils.rs index 2addfd0ae3..87ba2be4fd 100644 --- a/crates/starknet_api/src/test_utils.rs +++ b/crates/starknet_api/src/test_utils.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use std::fs::read_to_string; use std::path::{Path, PathBuf}; -use infra_utils::path::cargo_manifest_dir; use serde::{Deserialize, Serialize}; use serde_json::to_string_pretty; use starknet_types_core::felt::Felt; @@ -21,7 +20,7 @@ pub mod l1_handler; /// directory has a `resources` folder. The value for file_path should be the path to the required /// file in the folder "resources". pub fn path_in_resources>(file_path: P) -> PathBuf { - cargo_manifest_dir().unwrap().join("resources").join(file_path) + std::env::current_dir().unwrap().join("resources").join(file_path) } /// Reads from the directory containing the manifest at run time, same as current working directory. From 1b90f8cc89af2c726790abbcf49b74052be0c7ae Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 4 Dec 2024 15:21:19 +0200 Subject: [PATCH 3/4] chore(blockifier): move env var from run time to compile time commit-id:80a7265d --- crates/blockifier/src/test_utils/cairo_compile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/blockifier/src/test_utils/cairo_compile.rs b/crates/blockifier/src/test_utils/cairo_compile.rs index 9d22166540..14c26b0636 100644 --- a/crates/blockifier/src/test_utils/cairo_compile.rs +++ b/crates/blockifier/src/test_utils/cairo_compile.rs @@ -83,7 +83,7 @@ pub fn cairo1_compiler_tag() -> String { /// overridden by the environment variable (otherwise, the default is used). fn local_cairo1_compiler_repo_path() -> PathBuf { // Location of blockifier's Cargo.toml. - let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let manifest_dir = env!("CARGO_MANIFEST_DIR"); Path::new(&manifest_dir).join( env::var(CAIRO1_REPO_RELATIVE_PATH_OVERRIDE_ENV_VAR) @@ -217,7 +217,7 @@ fn verify_cairo0_compiler_deps() { } else { format!("installed version: {cairo_lang_version}") }, - env::var("CARGO_MANIFEST_DIR").unwrap(), + env!("CARGO_MANIFEST_DIR"), CAIRO0_PIP_REQUIREMENTS_FILE ); } From ba2756eb5410b2c7bc8f1ce007d36edb542501c9 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Wed, 4 Dec 2024 15:25:28 +0200 Subject: [PATCH 4/4] chore(starknet_sierra_compile): move env var from run time to compile time commit-id:6e7f2a75 --- crates/starknet_sierra_compile/src/build_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/starknet_sierra_compile/src/build_utils.rs b/crates/starknet_sierra_compile/src/build_utils.rs index 279668e2e4..cb77e5ea80 100644 --- a/crates/starknet_sierra_compile/src/build_utils.rs +++ b/crates/starknet_sierra_compile/src/build_utils.rs @@ -36,5 +36,5 @@ pub fn output_file_path() -> String { #[cfg(feature = "cairo_native")] pub fn repo_root_dir() -> PathBuf { - Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("../..").to_path_buf() + Path::new(env!("CARGO_MANIFEST_DIR")).join("../..").to_path_buf() }