Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JULIA_CONDAPKG_UNSAFE_PARALLEL environment variable. Useful for (unsafe) skipping resolving #155

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
* Add `pip_backend` preference.
* Add `JULIA_CONDAPKG_UNSAFE_PARALLEL` environment variable to (unsafe) skip resolving, which is necessary to load in parallel or in read only environments.

## 0.2.23 (2024-07-20)
* Pip packages are now installed using [`uv`](https://pypi.org/project/uv/) if it is installed.
Expand Down
25 changes: 16 additions & 9 deletions src/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ function offline()
getpref(Bool, "offline", "JULIA_CONDAPKG_OFFLINE", false)
end

function unsafe_parallel()
getpref(Bool, "unsafe_parallel", "JULIA_CONDAPKG_UNSAFE_PARALLEL", false)
end

function _pip_backend()
b = getpref(String, "pip_backend", "JULIA_CONDAPKG_PIP_BACKEND", "uv")
if b == "pip"
Expand Down Expand Up @@ -558,17 +562,20 @@ function resolve(;
STATE.shared = shared
meta_file = joinpath(meta_dir, "meta")
lock_file = joinpath(meta_dir, "lock")
# grap a file lock so only one process can resolve this environment at a time
mkpath(meta_dir)
lock = try
Pidfile.mkpidlock(lock_file; wait = false)
catch
@info "CondaPkg: Waiting for lock to be freed. You may delete this file if no other process is resolving." lock_file
Pidfile.mkpidlock(lock_file; wait = true)
if !unsafe_parallel()
# grap a file lock so only one process can resolve this environment at a time
mkpath(meta_dir)
lock = try
Pidfile.mkpidlock(lock_file; wait = false)
catch
@info "CondaPkg: Waiting for lock to be freed. You may delete this file if no other process is resolving." lock_file
Pidfile.mkpidlock(lock_file; wait = true)
end
end
try
# skip resolving if nothing has changed since the metadata was updated
if !force && _resolve_can_skip_1(conda_env, load_path, meta_file)
if (!force && _resolve_can_skip_1(conda_env, load_path, meta_file)) ||
unsafe_parallel()
@debug "already resolved"
STATE.resolved = true
interactive && _log(io, "Dependencies already up to date")
Expand Down Expand Up @@ -714,7 +721,7 @@ function resolve(;
STATE.resolved = true
return
finally
close(lock)
unsafe_parallel() || close(lock)
end
end

Expand Down
Loading