Skip to content

Commit 6c978c0

Browse files
bors[bot]KristofferCjonas-schulzefredrikekre00vareladavid
authored
Merge #1337
1337: [release-1.3] Backports for 1.3 r=fredrikekre a=fredrikekre Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com> Co-authored-by: Jonas Schulze <jonas.schulze@st.ovgu.de> Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com> Co-authored-by: David Varela <00.varela.david@gmail.com> Co-authored-by: Lyndon White <oxinabox@ucc.asn.au>
2 parents 60f47de + 7fa58c8 commit 6c978c0

File tree

14 files changed

+124
-57
lines changed

14 files changed

+124
-57
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
33
keywords = ["package", "management"]
44
license = "MIT"
55
desc = "The next-generation Julia package manager."
6-
version = "1.2.0"
6+
version = "1.3.0"
77

88
[deps]
99
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
DocumenterLaTeX = "cd674d7a-5f81-5cf3-af33-235ef1834b99"
44

55
[compat]
6-
Documenter = "~0.22"
6+
Documenter = "~0.23"

docs/make.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if "pdf" in ARGS
1616
push!(formats, LaTeX(platform = "docker"))
1717
end
1818

19+
# setup for doctesting
20+
DocMeta.setdocmeta!(Pkg.BinaryPlatforms, :DocTestSetup, :(using Pkg.BinaryPlatforms); recursive=true)
21+
1922
makedocs(
2023
format = formats,
2124
modules = [Pkg],

docs/src/artifacts.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ This mechanism is also used to provide the binary dependencies for packages buil
88

99
`Pkg` provides an API for working with artifacts, as well as a TOML file format for recording artifact usage in your packages, and to automate downloading of artifacts at package install time.
1010
Artifacts can always be referred to by content hash, but are typically accessed by a name that is bound to a content hash in an `Artifacts.toml` file that lives in a project's source tree.
11-
An example `Artifacts.toml` file is shown here as an example:
11+
12+
!!! note
13+
It is possible to use the alternate name `JuliaArtifacts.toml`, similar
14+
to how it is possible to use `JuliaProject.toml` and `JuliaManifest.toml`
15+
instead of `Project.toml` and `Manifest.toml`, respectively.
16+
17+
An example `Artifacts.toml` file is shown here:
1218

1319
```TOML
1420
# Example Artifacts.toml file

src/Artifacts.jl

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export create_artifact, artifact_exists, artifact_path, remove_artifact, verify_
1313
artifact_meta, artifact_hash, bind_artifact!, unbind_artifact!, download_artifact,
1414
find_artifacts_toml, ensure_artifact_installed, @artifact_str, archive_artifact
1515

16+
# keep in sync with Base.project_names and Base.manifest_names
17+
const artifact_names = ("JuliaArtifacts.toml", "Artifacts.toml")
18+
1619
const ARTIFACTS_DIR_OVERRIDE = Ref{Union{String,Nothing}}(nothing)
1720
"""
1821
with_artifacts_directory(f::Function, artifacts_dir::String)
@@ -370,12 +373,12 @@ returns the `Platform` object that this entry specifies. Returns `nothing` on e
370373
"""
371374
function unpack_platform(entry::Dict, name::String, artifacts_toml::String)
372375
if !haskey(entry, "os")
373-
@error("Invalid Artifacts.toml at '$(artifacts_toml)': platform-specific artifact entry '$name' missing 'os' key")
376+
@error("Invalid artifacts file at '$(artifacts_toml)': platform-specific artifact entry '$name' missing 'os' key")
374377
return nothing
375378
end
376379

377380
if !haskey(entry, "arch")
378-
@error("Invalid Artifacts.toml at '$(artifacts_toml)': platform-specific artifact entrty '$name' missing 'arch' key")
381+
@error("Invalid artifacts file at '$(artifacts_toml)': platform-specific artifact entrty '$name' missing 'arch' key")
379382
return nothing
380383
end
381384

@@ -439,7 +442,7 @@ end
439442
load_artifacts_toml(artifacts_toml::String;
440443
pkg_uuid::Union{UUID,Nothing}=nothing)
441444
442-
Loads an `Artifacts.toml` file from disk. If `pkg_uuid` is set to the `UUID` of the
445+
Loads an `(Julia)Artifacts.toml` file from disk. If `pkg_uuid` is set to the `UUID` of the
443446
owning package, UUID/name overrides stored in a depot `Overrides.toml` will be resolved.
444447
"""
445448
function load_artifacts_toml(artifacts_toml::String;
@@ -480,7 +483,7 @@ end
480483
pkg_uuid::Union{Base.UUID,Nothing}=nothing)
481484
482485
Get metadata about a given artifact (identified by name) stored within the given
483-
`Artifacts.toml` file. If the artifact is platform-specific, use `platform` to choose the
486+
`(Julia)Artifacts.toml` file. If the artifact is platform-specific, use `platform` to choose the
484487
most appropriate mapping. If none is found, return `nothing`.
485488
"""
486489
function artifact_meta(name::String, artifacts_toml::String;
@@ -508,13 +511,13 @@ function artifact_meta(name::String, artifact_dict::Dict, artifacts_toml::String
508511
meta = select_platform(dl_dict, platform)
509512
# If it's NOT a dict, complain
510513
elseif !isa(meta, Dict)
511-
@error("Invalid Artifacts.toml at $(artifacts_toml): artifact '$name' malformed, must be array or dict!")
514+
@error("Invalid artifacts file at $(artifacts_toml): artifact '$name' malformed, must be array or dict!")
512515
return nothing
513516
end
514517

515518
# This is such a no-no, we are going to call it out right here, right now.
516519
if meta != nothing && !haskey(meta, "git-tree-sha1")
517-
@error("Invalid Artifacts.toml at $(artifacts_toml): artifact '$name' contains no `git-tree-sha1`!")
520+
@error("Invalid artifacts file at $(artifacts_toml): artifact '$name' contains no `git-tree-sha1`!")
518521
return nothing
519522
end
520523

@@ -546,7 +549,7 @@ end
546549
lazy::Bool = false,
547550
force::Bool = false)
548551
549-
Writes a mapping of `name` -> `hash` within the given `Artifacts.toml` file. If
552+
Writes a mapping of `name` -> `hash` within the given `(Julia)Artifacts.toml` file. If
550553
`platform` is not `nothing`, this artifact is marked as platform-specific, and will be
551554
a multi-mapping. It is valid to bind multiple artifacts with the same name, but
552555
different `platform`s and `hash`'es within the same `artifacts_toml`. If `force` is set
@@ -566,7 +569,7 @@ function bind_artifact!(artifacts_toml::String, name::String, hash::SHA1;
566569
# First, check to see if this artifact is already bound:
567570
if isfile(artifacts_toml)
568571
artifact_dict = parse_toml(artifacts_toml)
569-
572+
570573
if !force && haskey(artifact_dict, name)
571574
meta = artifact_dict[name]
572575
if !isa(meta, Array)
@@ -633,8 +636,8 @@ end
633636
"""
634637
unbind_artifact!(artifacts_toml::String, name::String; platform = nothing)
635638
636-
Unbind the given `name` from an `Artifacts.toml` file. Silently fails if no such binding
637-
exists within the file.
639+
Unbind the given `name` from an `(Julia)Artifacts.toml` file.
640+
Silently fails if no such binding exists within the file.
638641
"""
639642
function unbind_artifact!(artifacts_toml::String, name::String;
640643
platform::Union{Platform,Nothing} = nothing)
@@ -730,7 +733,7 @@ end
730733
find_artifacts_toml(path::String)
731734
732735
Given the path to a `.jl` file, (such as the one returned by `__source__.file` in a macro
733-
context), find the `Artifacts.toml` that is contained within the containing project (if it
736+
context), find the `(Julia)Artifacts.toml` that is contained within the containing project (if it
734737
exists), otherwise return `nothing`.
735738
"""
736739
function find_artifacts_toml(path::String)
@@ -740,25 +743,22 @@ function find_artifacts_toml(path::String)
740743

741744
# Run until we hit the root directory.
742745
while dirname(path) != path
743-
# Also check for `JuliaArtifacts.toml`, preferring that as it's more specific
744-
artifacts_toml_path = joinpath(path, "JuliaArtifacts.toml")
745-
if isfile(artifacts_toml_path)
746-
return abspath(artifacts_toml_path)
747-
end
748-
749-
# Does this `Artifacts.toml` exist?
750-
artifacts_toml_path = joinpath(path, "Artifacts.toml")
751-
if isfile(artifacts_toml_path)
752-
return abspath(artifacts_toml_path)
746+
for f in artifact_names
747+
artifacts_toml_path = joinpath(path, f)
748+
if isfile(artifacts_toml_path)
749+
return abspath(artifacts_toml_path)
750+
end
753751
end
754752

755-
# Does a `Project.toml` file exist here, in the absence of an Artifacts.toml?
753+
# Does a `(Julia)Project.toml` file exist here, in the absence of an Artifacts.toml?
756754
# If so, stop the search as we've probably hit the top-level of this package,
757755
# and we don't want to escape out into the larger filesystem.
758-
if isfile(joinpath(path, "Project.toml"))
759-
return nothing
756+
for f in Base.project_names
757+
if isfile(joinpath(path, f))
758+
return nothing
759+
end
760760
end
761-
761+
762762
# Move up a directory
763763
path = dirname(path)
764764
end
@@ -796,7 +796,7 @@ function ensure_artifact_installed(name::String, meta::Dict, artifacts_toml::Str
796796
if !haskey(meta, "download")
797797
error("Cannot automatically install '$(name)'; no download section in '$(artifacts_toml)'")
798798
end
799-
799+
800800
# Attempt to download from all sources
801801
for entry in meta["download"]
802802
url = entry["url"]
@@ -818,7 +818,7 @@ end
818818
pkg_uuid = nothing,
819819
include_lazy = false)
820820
821-
Installs all non-lazy artifacts from a given `Artifacts.toml` file. `package_uuid` must
821+
Installs all non-lazy artifacts from a given `(Julia)Artifacts.toml` file. `package_uuid` must
822822
be provided to properly support overrides from `Overrides.toml` entries in depots.
823823
824824
If `include_lazy` is set to `true`, then lazy packages will be installed as well.
@@ -855,14 +855,14 @@ end
855855
856856
Macro that is used to automatically ensure an artifact is installed, and return its
857857
location on-disk. Automatically looks the artifact up by name in the project's
858-
`Artifacts.toml` file. Throws an error on inability to install the requested artifact.
858+
`(Julia)Artifacts.toml` file. Throws an error on inability to install the requested artifact.
859859
"""
860860
macro artifact_str(name)
861861
return quote
862862
local artifacts_toml = $(find_artifacts_toml)($(string(__source__.file)))
863863
if artifacts_toml === nothing
864864
error(string(
865-
"Cannot locate 'Artifacts.toml' file when attempting to use artifact '",
865+
"Cannot locate '(Julia)Artifacts.toml' file when attempting to use artifact '",
866866
$(esc(name)),
867867
"' in '",
868868
$(esc(__module__)),

src/Operations.jl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import REPL
1010
using REPL.TerminalMenus
1111
using ..Types, ..GraphType, ..Resolve, ..Pkg2, ..PlatformEngines, ..GitTools, ..Display
1212
import ..depots, ..depots1, ..devdir, ..Types.uuid_julia, ..Types.PackageEntry
13-
import ..Artifacts: ensure_all_artifacts_installed
13+
import ..Artifacts: ensure_all_artifacts_installed, artifact_names
1414
using ..BinaryPlatforms
1515
import ..Pkg
1616

@@ -424,7 +424,9 @@ function deps_graph(ctx::Context, uuid_to_name::Dict{UUID,String}, reqs::Require
424424
for uuid in uuids
425425
uuid == uuid_julia && continue
426426
if !haskey(uuid_to_name, uuid)
427-
uuid_to_name[uuid] = registered_name(ctx.env, uuid)
427+
name = registered_name(ctx.env, uuid)
428+
name === nothing && pkgerror("cannot find name corresponding to UUID $(uuid) in a registry")
429+
uuid_to_name[uuid] = name
428430
entry = manifest_info(ctx.env, uuid)
429431
entry nothing && continue
430432
uuid_to_name[uuid] = entry.name
@@ -560,11 +562,14 @@ function download_artifacts(ctx::Context, pkgs::Vector{PackageSpec};
560562
platform::Platform=platform_key_abi())
561563
for pkg in pkgs
562564
path = source_path(pkg)
563-
# Check to see if this package has an Artifacts.toml
564-
artifacts_toml = joinpath(path, "Artifacts.toml")
565-
if isfile(artifacts_toml)
566-
ensure_all_artifacts_installed(artifacts_toml; platform=platform)
567-
write_env_usage(artifacts_toml, "artifact_usage.toml")
565+
# Check to see if this package has an (Julia)Artifacts.toml
566+
for f in artifact_names
567+
artifacts_toml = joinpath(path, f)
568+
if isfile(artifacts_toml)
569+
ensure_all_artifacts_installed(artifacts_toml; platform=platform)
570+
write_env_usage(artifacts_toml, "artifact_usage.toml")
571+
break
572+
end
568573
end
569574
end
570575
end
@@ -871,11 +876,10 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec})
871876
pkg.mode == PKGMODE_PROJECT || continue
872877
found = false
873878
for (name::String, uuid::UUID) in ctx.env.project.deps
874-
has_name(pkg) && pkg.name == name ||
875-
has_uuid(pkg) && pkg.uuid == uuid || continue
876-
!has_name(pkg) || pkg.name == name ||
879+
pkg.name == name || pkg.uuid == uuid || continue
880+
pkg.name == name ||
877881
error("project file name mismatch for `$uuid`: $(pkg.name)$name")
878-
!has_uuid(pkg) || pkg.uuid == uuid ||
882+
pkg.uuid == uuid ||
879883
error("project file UUID mismatch for `$name`: $(pkg.uuid)$uuid")
880884
uuid in drop || push!(drop, uuid)
881885
found = true
@@ -894,6 +898,9 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec})
894898
@info "No changes"
895899
return
896900
end
901+
filter!(ctx.env.project.compat) do (name, _)
902+
name in keys(ctx.env.project.deps)
903+
end
897904
deps_names = append!(collect(keys(ctx.env.project.deps)),
898905
collect(keys(ctx.env.project.extras)))
899906
filter!(ctx.env.project.targets) do (target, deps)
@@ -978,7 +985,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=UUID[];
978985
# TODO is it still necessary to prune? I don't think so..
979986
new_apply = download_source(ctx, pkgs)
980987

981-
# After downloading resolutionary packages, search for Artifacts.toml files
988+
# After downloading resolutionary packages, search for (Julia)Artifacts.toml files
982989
# and ensure they are all downloaded and unpacked as well:
983990
download_artifacts(ctx, pkgs; platform=platform)
984991

src/PlatformEngines.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,15 @@ if `force` is not set and the already-existent file fails verification, or if
603603
`force` is set, verification fails, and then verification fails again after
604604
redownloading the file.
605605
606-
If `quiet_download` is set to `false` (the default), this method will print to
607-
stdout when downloading a new file. If it is set to `true` (and `verbose` is
606+
If `quiet_download` is set to `false`, this method will print to
607+
stdout when downloading a new file. If it is set to `true` (default, and `verbose` is
608608
set to `false`) the downloading process will be completely silent. If
609609
`verbose` is set to `true`, messages about integrity verification will be
610610
printed in addition to messages regarding downloading.
611611
"""
612612
function download_verify(url::AbstractString, hash::AbstractString,
613613
dest::AbstractString; verbose::Bool = false,
614-
force::Bool = false, quiet_download::Bool = false)
614+
force::Bool = false, quiet_download::Bool = true)
615615
# Whether the file existed in the first place
616616
file_existed = false
617617

src/Types.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ function manifestfile_path(env_path::String; strict=false)
215215
maybe_file = joinpath(env_path, name)
216216
isfile(maybe_file) && return maybe_file
217217
end
218-
return strict ? nothing : joinpath(env_path, "Manifest.toml")
218+
if strict
219+
return nothing
220+
else
221+
project = basename(projectfile_path(env_path))
222+
idx = findfirst(x -> x == project, Base.project_names)
223+
@assert idx !== nothing
224+
return joinpath(env_path, Base.manifest_names[idx])
225+
end
219226
end
220227

221228
function find_project_file(env::Union{Nothing,String}=nothing)
@@ -1136,7 +1143,7 @@ function update_registries(ctx::Context, regs::Vector{RegistrySpec} = collect_re
11361143
# Using LibGit2.with here crashes julia when running the
11371144
# tests for PkgDev wiht "Unreachable reached".
11381145
# This seems to work around it.
1139-
local repo
1146+
repo = nothing
11401147
try
11411148
repo = LibGit2.GitRepo(reg.path)
11421149
if LibGit2.isdirty(repo)
@@ -1177,7 +1184,9 @@ function update_registries(ctx::Context, regs::Vector{RegistrySpec} = collect_re
11771184
end
11781185
@label done
11791186
finally
1180-
close(repo)
1187+
if repo isa LibGit2.GitRepo
1188+
close(repo)
1189+
end
11811190
end
11821191
end
11831192
end

src/backwards_compatible_isolation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
558558
# a trivial modification of the project file only.
559559
# See issue https://github.com/JuliaLang/Pkg.jl/issues/1144
560560
not_loadable = setdiff(should_be_in_manifest, should_be_in_project)
561-
Operations.rm(localctx, [PackageSpec(uuid = uuid) for uuid in not_loadable])
561+
Pkg.API.rm(localctx, [PackageSpec(uuid = uuid) for uuid in not_loadable])
562562

563563
write_env(localctx, display_diff = false)
564564
will_resolve && build_versions(localctx, new)

test/api.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ include("utils.jl")
1616
end
1717
end
1818

19+
@testset "Pkg.rm" begin
20+
# rm should remove compat entries
21+
temp_pkg_dir() do tmp
22+
copy_test_package(tmp, "BasicCompat")
23+
Pkg.activate(joinpath(tmp, "BasicCompat"))
24+
@test haskey(Pkg.Types.Context().env.project.compat, "Example")
25+
Pkg.rm("Example")
26+
@test !haskey(Pkg.Types.Context().env.project.compat, "Example")
27+
end
28+
end
29+
1930
@testset "Pkg.activate" begin
2031
temp_pkg_dir() do project_path
2132
cd_tempdir() do tmp

0 commit comments

Comments
 (0)