Skip to content

Commit

Permalink
Merge pull request #3595 from JuliaLang/backports-release-1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Aug 19, 2023
2 parents cc71837 + 3a39ca3 commit 6235d3f
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 51 deletions.
13 changes: 7 additions & 6 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
extdep_names = extdep_names isa String ? String[extdep_names] : extdep_names
for extdep_name in extdep_names
extdep_uuid = weakdeps[extdep_name]
if extdep_uuid in keys(ctx.env.manifest.deps)
if extdep_uuid in keys(ctx.env.manifest.deps) || Base.in_sysimage(Base.PkgId(extdep_uuid, extdep_name))
push!(ext_deps, Base.PkgId(extdep_uuid, extdep_name))
else
all_extdeps_available = false
Expand Down Expand Up @@ -1298,8 +1298,9 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
println(io, " Interrupted: Exiting precompilation...")
end
interrupted = true
return true
else
@error "Pkg.precompile error" exception=(err, catch_backtrace())
return false
end
end

Expand Down Expand Up @@ -1373,7 +1374,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
wait(t)
end
catch err
handle_interrupt(err, true)
handle_interrupt(err, true) || rethrow()
finally
fancyprint && print(io, ansi_enablecursor)
end
Expand Down Expand Up @@ -1482,7 +1483,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
n_done += 1
notify(was_processed[pkg])
catch err_outer
handle_interrupt(err_outer)
handle_interrupt(err_outer) || rethrow()
notify(was_processed[pkg])
finally
filter!(!istaskdone, tasks)
Expand All @@ -1495,7 +1496,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
try
wait(interrupted_or_done)
catch err
handle_interrupt(err)
handle_interrupt(err) || rethrow()
finally
Base.LOADING_CACHE[] = nothing
end
Expand Down Expand Up @@ -1552,7 +1553,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
if !isempty(stderr_outputs)
plural1 = length(stderr_outputs) == 1 ? "y" : "ies"
plural2 = length(stderr_outputs) == 1 ? "" : "s"
print(iostr, "\n ", color_string("$(length(stderr_outputs))", Base.warn_color()), " dependenc$(plural1) had warnings during precompilation:")
print(iostr, "\n ", color_string("$(length(stderr_outputs))", Base.warn_color()), " dependenc$(plural1) had output during precompilation:")
for (pkgid, err) in stderr_outputs
err = join(split(err, "\n"), color_string("\n", Base.warn_color()))
print(iostr, color_string("\n", Base.warn_color()), pkgid, color_string("\n", Base.warn_color()), err, color_string("\n", Base.warn_color()))
Expand Down
14 changes: 12 additions & 2 deletions src/GitTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ function clone(io::IO, url, source_path; header=nothing, credentials=nothing, kw
end
try
if use_cli_git()
run(pipeline(`git clone --quiet $url $source_path`; stdout=devnull))
cmd = `git clone --quiet $url $source_path`
try
run(pipeline(cmd; stdout=devnull))
catch err
Pkg.Types.pkgerror("The command $(cmd) failed, error: $err")
end
return LibGit2.GitRepo(source_path)
else
mkpath(source_path)
Expand Down Expand Up @@ -161,7 +166,12 @@ function fetch(io::IO, repo::LibGit2.GitRepo, remoteurl=nothing; header=nothing,
if use_cli_git()
let remoteurl=remoteurl
cd(LibGit2.path(repo)) do
run(pipeline(`git fetch -q $remoteurl $(only(refspecs))`; stdout=devnull))
cmd = `git fetch -q $remoteurl $(only(refspecs))`
try
run(pipeline(cmd; stdout=devnull))
catch err
Pkg.Types.pkgerror("The command $(cmd) failed, error: $err")
end
end
end
else
Expand Down
13 changes: 9 additions & 4 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,15 @@ end
project_rel_path(env::EnvCache, path::String) = normpath(joinpath(dirname(env.manifest_file), path))

function prune_manifest(env::EnvCache)
# if project uses another manifest, don't prune
dirname(env.project_file) != dirname(env.manifest_file) && return env.manifest
keep = collect(values(env.project.deps))
env.manifest = prune_manifest(env.manifest, keep)
# if project uses another manifest, only prune project entry in manifest
if dirname(env.project_file) != dirname(env.manifest_file)
proj_entry = env.manifest[env.project.uuid]
proj_entry.deps = env.project.deps
else
keep = collect(values(env.project.deps))
env.manifest = prune_manifest(env.manifest, keep)
end
return env.manifest
end

function prune_manifest(manifest::Manifest, keep::Vector{UUID})
Expand Down
4 changes: 1 addition & 3 deletions src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,7 @@ The logic for what path is activated is as follows:
activate the environment at the tracked path.
* Otherwise, `s` is interpreted as a non-existing path, which is then activated.
If no argument is given to `activate`, then activate the home project.
The home project is specified by either the `--project` command line option to
the julia executable, or the `JULIA_PROJECT` environment variable.
If no argument is given to `activate`, then use the first project found in `LOAD_PATH`.
# Examples
```
Expand Down
2 changes: 1 addition & 1 deletion src/REPLMode/command_declarations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ PSA[:name => "activate",
activate [--shared] path
activate --temp
Activate the environment at the given `path`, or the home project environment if no `path` is specified.
Activate the environment at the given `path`, or use the first project found in `LOAD_PATH` if no `path` is specified.
The active environment is the environment that is modified by executing package commands.
When the option `--shared` is given, `path` will be assumed to be a directory name and searched for in the
`environments` folders of the depots in the depot stack. In case no such environment exists in any of the depots,
Expand Down
8 changes: 4 additions & 4 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ function PackageSpec(; name::Union{Nothing,AbstractString} = nothing,
uuid = uuid === nothing ? nothing : UUID(uuid)
return PackageSpec(name, uuid, version, tree_hash, repo, path, pinned, url, rev, subdir)
end
PackageSpec(name::AbstractString) = PackageSpec(;name=name)
PackageSpec(name::AbstractString, uuid::UUID) = PackageSpec(;name=name, uuid=uuid)
PackageSpec(name::AbstractString, version::VersionTypes) = PackageSpec(;name=name, version=version)
PackageSpec(n::AbstractString, u::UUID, v::VersionTypes) = PackageSpec(;name=n, uuid=u, version=v)
PackageSpec(name::AbstractString) = PackageSpec(;name=name)::PackageSpec
PackageSpec(name::AbstractString, uuid::UUID) = PackageSpec(;name=name, uuid=uuid)::PackageSpec
PackageSpec(name::AbstractString, version::VersionTypes) = PackageSpec(;name=name, version=version)::PackageSpec
PackageSpec(n::AbstractString, u::UUID, v::VersionTypes) = PackageSpec(;name=n, uuid=u, version=v)::PackageSpec

function Base.:(==)(a::PackageSpec, b::PackageSpec)
return a.name == b.name && a.uuid == b.uuid && a.version == b.version &&
Expand Down
3 changes: 1 addition & 2 deletions src/project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ function destructure(project::Project)::Dict
entry!("uuid", project.uuid)
entry!("version", project.version)
entry!("manifest", project.manifest)
merge!(project.deps, project._deps_weak)
entry!("deps", project.deps)
entry!("deps", merge(project.deps, project._deps_weak))
entry!("weakdeps", project.weakdeps)
entry!("extras", project.extras)
entry!("compat", Dict(name => x.str for (name, x) in project.compat))
Expand Down
2 changes: 1 addition & 1 deletion test/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using ..Utils
cd(mkdir("tests"))
Pkg.activate("Foo") # activate developed Foo from another directory
@test Base.active_project() == joinpath(path, "modules", "Foo", "Project.toml")
Pkg.activate() # activate home project
Pkg.activate() # activate LOAD_PATH project
@test Base.ACTIVE_PROJECT[] === nothing
end end
end
Expand Down
2 changes: 2 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ end
end
end

@test eltype([PackageSpec(a) for a in []]) == PackageSpec

end # module
42 changes: 27 additions & 15 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Pkg._auto_gc_enabled[] = false
source053 = pkg.source
source053_time = mtime(pkg.source)
end
# - The home project was automatically created.
# - The active project was automatically created.
@test haskey(Pkg.project().dependencies, "Example")
@test length(Pkg.project().dependencies) == 1
# Now we install the same package at a different version:
Expand Down Expand Up @@ -2687,22 +2687,34 @@ end
# # Other
#
# Note: these tests should be run on clean depots
@testset "downloads" begin
for v in (nothing, "true")
withenv("JULIA_PKG_USE_CLI_GIT" => v) do
# libgit2 downloads
isolate() do
Pkg.add("Example"; use_git_for_all_downloads=true)
@test haskey(Pkg.dependencies(), exuuid)
@eval import $(Symbol(TEST_PKG.name))
@test_throws SystemError open(pathof(eval(Symbol(TEST_PKG.name))), "w") do io end # check read-only
Pkg.rm(TEST_PKG.name)
end
for v in (nothing, "true")
withenv("JULIA_PKG_USE_CLI_GIT" => v, "GIT_TERMINAL_PROMPT" => 0) do
@testset "downloads with JULIA_PKG_USE_CLI_GIT = $v" begin
isolate() do
@testset "libgit2 downloads" begin
Pkg.add(TEST_PKG.name; use_git_for_all_downloads=true)
@test haskey(Pkg.dependencies(), TEST_PKG.uuid)
Pkg.rm(TEST_PKG.name)
@testset "via name" begin
Pkg.add(TEST_PKG.name; use_git_for_all_downloads=true)
@test haskey(Pkg.dependencies(), TEST_PKG.uuid)
@eval import $(Symbol(TEST_PKG.name))
@test_throws SystemError open(pathof(eval(Symbol(TEST_PKG.name))), "w") do io end # check read-only
Pkg.rm(TEST_PKG.name)
end
if (Pkg.get_bool_env("JULIA_PKG_USE_CLI_GIT", default = "false") && Sys.iswindows()) == false
# TODO: fix. on GH windows runners cli git will prompt for credentials here
@testset "via url" begin
Pkg.add(url="https://github.com/JuliaLang/Example.jl", use_git_for_all_downloads=true)
@test haskey(Pkg.dependencies(), TEST_PKG.uuid)
Pkg.rm(TEST_PKG.name)
end
end
end
if !Sys.iswindows()
# TODO: fix. on GH windows runners cli git will prompt for credentials here
@testset "libgit2 failures" begin
doesnotexist = "https://github.com/DoesNotExist/DoesNotExist.jl"
@test_throws Pkg.Types.PkgError Pkg.add(url=doesnotexist, use_git_for_all_downloads=true)
@test_throws Pkg.Types.PkgError Pkg.Registry.add(Pkg.RegistrySpec(url=doesnotexist))
end
end
@testset "tarball downloads" begin
Pkg.add("JSON"; use_only_tarballs_for_downloads=true)
Expand Down
22 changes: 21 additions & 1 deletion test/project_manifest.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ProjectManifestTest

import ..Pkg # ensure we are using the correct Pkg
using Test, Pkg
using Test, Pkg, UUIDs
using ..Utils

temp_pkg_dir() do project_path
Expand Down Expand Up @@ -29,13 +29,33 @@ temp_pkg_dir() do project_path
Pkg.test()
end
end
m = Pkg.Types.read_manifest(joinpath(dir, "monorepo", "Manifest.toml"))
@test haskey(m, UUID("dd0d8fba-d7c4-4f8e-a2bb-3a090b3e34f2")) # B subpackage
@test haskey(m, UUID("4ee78ca3-4e78-462f-a078-747ed543fa86")) # C subpackage
@test haskey(m, UUID("bf733257-898a-45a0-b2f2-c1c188bdd870")) # D subpackage, but no direct dependency
pkgC = m[UUID("4ee78ca3-4e78-462f-a078-747ed543fa86")]
@test haskey(pkgC.deps, "D")
cd(joinpath(dir, "monorepo")) do
with_current_env() do
Pkg.develop(path="packages/C")
Pkg.add("Test")
Pkg.test()
end
end
# now test removing a dependency from subpackage correctly updates root manifest
cd(joinpath(dir, "monorepo", "packages", "C")) do
with_current_env() do
Pkg.rm("D")
Pkg.test()
end
end
m = Pkg.Types.read_manifest(joinpath(dir, "monorepo", "Manifest.toml"))
# currently, we don't prune dependencies from the root manifest since when rm-ing a dep
# in a subpackage, we don't also do a full resolve at the root level
# https://github.com/JuliaLang/Pkg.jl/issues/3590
@test_broken !haskey(m, UUID("bf733257-898a-45a0-b2f2-c1c188bdd870")) # D subpackage, but no direct dependency
pkgC = m[UUID("4ee78ca3-4e78-462f-a078-747ed543fa86")]
@test !haskey(pkgC.deps, "D")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ temp_pkg_dir() do project_path
pkg"activate --shared Foo" # activate existing shared Foo
@test Base.active_project() == joinpath(tmpdir, "Project.toml")
pop!(Base.DEPOT_PATH)
pkg"activate" # activate home project
pkg"activate" # activate LOAD_PATH project
@test Base.ACTIVE_PROJECT[] === nothing
# expansion of ~
if !Sys.iswindows()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.0-DEV"
julia_version = "1.11.0-DEV"
manifest_format = "2.0"
project_hash = "51e63007fdb8e0cae2b36f0e7b2acebf7b7432a5"
project_hash = "c0b34a2f360e3789aa008772cc2c162a8e9d9850"

[[deps.Adapt]]
deps = ["LinearAlgebra"]
Expand All @@ -16,7 +16,7 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.0.1+0"
version = "1.0.5+1"

[[deps.Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
Expand All @@ -28,11 +28,17 @@ deps = ["Example"]
path = "../HasExtensions.jl"
uuid = "4d3288b3-3afc-4bb6-85f3-489fffe514c8"
version = "0.1.0"
weakdeps = ["OffsetArrays"]
weakdeps = ["IndirectArrays", "OffsetArrays"]

[deps.HasExtensions.extensions]
IndirectArraysExt = "IndirectArrays"
OffsetArraysExt = "OffsetArrays"

[[deps.IndirectArrays]]
git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f"
uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
version = "1.0.0"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

Expand All @@ -49,9 +55,9 @@ version = "1.12.8"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.21+0"
version = "0.3.23+2"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.2.0+0"
version = "5.8.0+1"
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ version = "0.1.0"

[deps]
HasExtensions = "4d3288b3-3afc-4bb6-85f3-489fffe514c8"
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"

[compat]
HasExtensions = "0.1"
IndirectArrays = "1.0"
OffsetArrays = "1.12"

[extras]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ module HasDepWithExtensions

using HasExtensions
using OffsetArrays: OffsetArray
# Loading OffsetArrays makes the extesion "OffsetArraysExt" to load
# Loading OffsetArrays makes the extesion "OffsetArraysExt" load

using IndirectArrays: IndirectArray
# Loading IndirectArrays makes the extesion "IndirectArraysExt" load

function do_something()
# @info "First do something with the basic array support in B"
# @info "First do something with the basic array support"
HasExtensions.foo(rand(Float64, 2)) == 1 || error("Unexpected value")

# @info "Now do something with extended OffsetArray support in B"
# @info "Now do something with extended OffsetArray support"
HasExtensions.foo(OffsetArray(rand(Float64, 2), 0:1)) == 2 || error("Unexpected value")

# @info "Now do something with extended IndirectArray support"
HasExtensions.foo(IndirectArray(rand(1:6, 32, 32), 1:6)) == 3 || error("Unexpected value")
end

end # module
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ using HasDepWithExtensions
using Test

@test HasDepWithExtensions.HasExtensions.offsetarrays_loaded
@test HasDepWithExtensions.HasExtensions.indirectarrays_loaded
HasDepWithExtensions.do_something()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0-DEV"
manifest_format = "2.0"
project_hash = "549efd0c32255f4b8717f50f49778e183bcc0e36"
project_hash = "8e0de0086d647967f02f7aba44b17d73156d2fee"

[[deps.Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
Expand Down
Loading

0 comments on commit 6235d3f

Please sign in to comment.