Skip to content

Commit

Permalink
Align openssl version with OpenSSL_jll version (#140)
Browse files Browse the repository at this point in the history
* Align openssl version with OpenSSL_jll version

* fix logic for compatible openssl version

* test with OpenSSL_jll installed

* update changelog

---------

Co-authored-by: Christopher Doris <github.com/cjdoris>
  • Loading branch information
lassepe authored Jul 20, 2024
1 parent 2a90c67 commit da6a637
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
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
* Pip packages are now installed using [`uv`](https://pypi.org/project/uv/) if it is installed.
* Special handling of `openssl` for compatibility with `OpenSSL_jll` if it is installed.

## 0.2.22 (2023-10-20)
* `pkg> conda run conda ...` now runs whatever conda executable CondaPkg is configured with.
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ TOML = "1"
julia = "1.6"

[extras]
OpenSSL_jll = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"

[targets]
test = ["Test", "TestItemRunner"]
test = ["OpenSSL_jll", "Test", "TestItemRunner"]
33 changes: 33 additions & 0 deletions src/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,34 @@ function _compatible_libstdcxx_ng_version()
end
end

"""
_compatible_openssl_version()
Find the version that aligns with the installed `OpenSSL_jll` version, if any.
See https://www.openssl.org/policies/releasestrat.html.
"""
function _compatible_openssl_version()
deps = Pkg.dependencies()
uuid = Base.UUID("458c3c95-2e84-50aa-8efc-19380b2a3a95")
dep = get(deps, uuid, nothing)
if (dep === nothing) || (dep.name != "OpenSSL_jll")
return nothing
end
version = dep.version
if version === nothing
return nothing
end
@debug "found OpenSSL_jll $version"
if version.major >= 3
# from v3, minor releases are ABI-compatible
return ">=$(version.major), <$(version.major).$(version.minor+1)"
else
# before this, only patch releases are ABI-compatible
return ">=$(version.major).$(version.minor), <$(version.major).$(version.minor).$(version.patch+1)"
end
end

function _resolve_find_dependencies(io, load_path)
packages = Dict{String,Dict{String,PkgSpec}}() # name -> depsfile -> spec
channels = ChannelSpec[]
Expand Down Expand Up @@ -123,6 +151,11 @@ function _resolve_find_dependencies(io, load_path)
version === nothing && continue
pkg = PkgSpec(pkg; version)
end
if pkg.name == "openssl" && pkg.version == "<=julia"
version = _compatible_openssl_version()
version === nothing && continue
pkg = PkgSpec(pkg; version)
end
get!(Dict{String,PkgSpec}, packages, pkg.name)[fn] = pkg
end
if isempty(chans)
Expand Down
9 changes: 9 additions & 0 deletions test/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ end
@test true
end

@testitem "install/remove opensll" begin
include("setup.jl")
CondaPkg.add("openssl", version="<=julia", resolve=false)
CondaPkg.resolve(force=true)
CondaPkg.rm("openssl", resolve=false)
CondaPkg.resolve(force=true)
@test true
end

@testitem "external conda env" begin
include("setup.jl")
dn = string(tempname(), backend, Sys.KERNEL, VERSION)
Expand Down

0 comments on commit da6a637

Please sign in to comment.