Skip to content

Commit

Permalink
handle python with build=**cpython** specially (#108)
Browse files Browse the repository at this point in the history
Co-authored-by: Christopher Doris <github.com/cjdoris>
  • Loading branch information
cjdoris authored Sep 30, 2023
1 parent 0c34c8e commit 5a7ce31
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Unreleased
* Special handling of `python` with `build="**cpython**"`.

## 0.2.20 (2023-09-22)
* Shared envs are now not always fully reinstalled when resolving.

Expand Down
31 changes: 29 additions & 2 deletions src/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,37 @@ function _resolve_find_dependencies(io, load_path)
(packages, channels, pip_packages, extra_path)
end

function _resolve_merge_packages(packages)
function _resolve_merge_packages(packages, channels)
specs = PkgSpec[]
for (name, pkgs) in packages
@assert length(pkgs) > 0
# special case: name=python, channel=**cpython**
if name == "python" && any(pkg.build == "**cpython**" for pkg in values(pkgs))
candidate_channels = String[]
append!(candidate_channels, (pkg.channel for pkg in values(pkgs)))
append!(candidate_channels, (c.name for c in channels))
filter!(c -> c in ("conda-forge", "anaconda", "pkgs/main"), candidate_channels)
if isempty(candidate_channels)
error("can currently only install cpython from conda-forge, anaconda or pkgs/main channel")
end
channel = first(candidate_channels)
for (fn, pkg) in collect(pkgs)
if pkg.build == "**cpython**"
if pkg.channel == ""
pkg = PkgSpec(pkg, channel=channel)
end
if pkg.channel == "conda-forge"
build = "*cpython*"
elseif pkg.channel in ("anaconda", "pkgs/main")
build = ""
else
error("can currently only install cpython from conda-forge, anaconda or pkgs/main channel")
end
pkg = PkgSpec(pkg, build=build)
pkgs[fn] = pkg
end
end
end
for pkg in values(pkgs)
@assert pkg.name == name
push!(specs, pkg)
Expand Down Expand Up @@ -448,7 +475,7 @@ function resolve(; force::Bool=false, io::IO=stderr, interactive::Bool=false, dr
# (in the future we might prioritise them)
sort!(unique!(channels), by=c->c.name)
# merge dependencies
specs = _resolve_merge_packages(packages)
specs = _resolve_merge_packages(packages, channels)
# merge pip dependencies
pip_specs = _resolve_merge_pip_packages(pip_packages)
# find what has changed
Expand Down

0 comments on commit 5a7ce31

Please sign in to comment.