Skip to content

Commit

Permalink
Try to pass path
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 24, 2024
1 parent 43219c1 commit 9b6ab46
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
13 changes: 10 additions & 3 deletions crates/uv-fs/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ use path_slash::PathExt;

/// The current working directory.
pub static CWD: LazyLock<PathBuf> =
LazyLock::new(|| std::env::current_dir().expect("The current directory must exist"));
LazyLock::new(|| {
std::env::var("UV_CWD")
.ok()
.map(PathBuf::from)
.unwrap_or_else(|| std::env::current_dir().expect("The current directory must exist"))
});

/// The current working directory, canonicalized.
pub static CANONICAL_CWD: LazyLock<PathBuf> = LazyLock::new(|| {
std::env::current_dir()
.expect("The current directory must exist")
std::env::var("UV_CWD")
.ok()
.map(PathBuf::from)
.unwrap_or_else(|| std::env::current_dir().expect("The current directory must exist"))
.canonicalize()
.expect("The current directory must be canonicalized")
});
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,12 +1928,12 @@ impl Source {
}

fn from_path_source_dist(path_dist: &PathSourceDist, root: &Path) -> Result<Source, LockError> {
println!("path_dist.install_path: {:?}", path_dist.install_path);
println!("root: {:?}", root);



let path = relative_to(&path_dist.install_path, root)
.map_err(LockErrorKind::DistributionRelativePath)?;
println!("path: {:?}", path);

Ok(Source::Path(path))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/uv-workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Workspace {
pyproject_toml,
});

println!("workspace_root: {:?}", workspace_root);


Self::collect_members(
workspace_root.clone(),
Expand Down
6 changes: 2 additions & 4 deletions crates/uv/src/commands/project/lock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(clippy::single_match_else)]

use std::collections::BTreeSet;
use std::env;
use std::fmt::Write;

use anstream::eprint;
Expand Down Expand Up @@ -75,11 +76,8 @@ pub(crate) async fn lock(
cache: &Cache,
printer: Printer,
) -> anyhow::Result<ExitStatus> {
println!("cwd: {:?}", CWD);
println!("current_dir: {:?}", std::env::current_dir()?);

// Find the project requirements.
let workspace = Workspace::discover(&CWD, &DiscoveryOptions::default()).await?;
let workspace = Workspace::discover(&*CWD, &DiscoveryOptions::default()).await?;

// Find an interpreter for the project
let interpreter = FoundInterpreter::discover(
Expand Down
2 changes: 0 additions & 2 deletions crates/uv/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ impl TestContext {
/// * Increase the stack size to avoid stack overflows on windows due to large async functions.
pub fn add_shared_args(&self, command: &mut Command) {
command
.arg("--directory")
.arg(self.temp_dir.path())
.arg("--cache-dir")
.arg(self.cache_dir.path())
.env("VIRTUAL_ENV", self.venv.as_os_str())
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7106,7 +7106,7 @@ fn lock_sources_archive() -> Result<()> {
let mut workspace_archive_file = fs_err::File::create(&*workspace_archive)?;
std::io::copy(&mut response.bytes()?.as_ref(), &mut workspace_archive_file)?;

println!("workspace_archive: {:?}", workspace_archive.path());


let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(&formatdoc! {
Expand Down

0 comments on commit 9b6ab46

Please sign in to comment.