Skip to content
Merged
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
16 changes: 16 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,20 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
REPLExt = "REPL"

[compat]
Artifacts = "1.11"
Dates = "1.11"
Downloads = "1.6"
FileWatching = "1.11"
LibGit2 = "1.11"
Libdl = "1.11"
Logging = "1.11"
Markdown = "1.11"
Printf = "1.11"
Random = "1.11"
REPL = "1.11"
SHA = "0.7"
TOML = "1"
Tar = "1.10"
UUIDs = "1.11"
julia = "1.12"
p7zip_jll = "17.5"
18 changes: 10 additions & 8 deletions ext/REPLExt/completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ end


const JULIA_UUID = UUID("1222c4b2-2114-5bfd-aeef-88e4692bbb3e")
function complete_remote_package(partial; hint::Bool)
found_match = false
isempty(partial) && return String[]
function complete_remote_package!(comps, partial; hint::Bool)
isempty(partial) && return true # true means returned early
found_match = !isempty(comps)
cmp = Set{String}()
for reg in Registry.reachable_registries()
for (uuid, regpkg) in reg
Expand All @@ -80,9 +80,9 @@ function complete_remote_package(partial; hint::Bool)
if is_julia_compat === nothing || is_julia_compat
push!(cmp, name)
# In hint mode the result is only used if there is a single matching entry
# so we abort the search
# so we can return no matches in case of more than one match
if hint && found_match
return sort!(collect(cmp))
return true # true means returned early
end
found_match = true
break
Expand All @@ -91,7 +91,8 @@ function complete_remote_package(partial; hint::Bool)
end
end
end
return sort!(collect(cmp))
append!(comps, sort!(collect(cmp)))
return false # false means performed full search
end

function complete_help(options, partial; hint::Bool)
Expand Down Expand Up @@ -149,8 +150,9 @@ function complete_add_dev(options, partial, i1, i2; hint::Bool)
if occursin(Base.Filesystem.path_separator_re, partial)
return comps, idx, !isempty(comps)
end
comps = vcat(comps, sort(complete_remote_package(partial; hint)))
if !isempty(partial)
returned_early = complete_remote_package!(comps, partial; hint)
# returning early means that no further search should be done here
if !returned_early
append!(comps, filter!(startswith(partial), [info.name for info in values(Types.stdlib_infos())]))
end
return comps, idx, !isempty(comps)
Expand Down
66 changes: 45 additions & 21 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,42 @@ end
# This has to be done after the packages have been downloaded
# since we need access to the Project file to read the information
# about extensions
function fixups_from_projectfile!(env::EnvCache)
function fixups_from_projectfile!(ctx::Context)
env = ctx.env
for pkg in values(env.manifest)
# isfile_casesenstive within locate_project_file used to error on Windows if given a
# relative path so abspath it to be extra safe https://github.com/JuliaLang/julia/pull/55220
project_file = Base.locate_project_file(abspath(source_path(env.manifest_file, pkg)))
if project_file isa String && isfile(project_file)
p = Types.read_project(project_file)
pkg.weakdeps = p.weakdeps
pkg.exts = p.exts
pkg.entryfile = p.entryfile
for (name, _) in p.weakdeps
if ctx.julia_version !== VERSION && is_stdlib(pkg.uuid, ctx.julia_version)
# Special handling for non-current julia_version resolving given the source for historical stdlibs
# isn't available at this stage as Pkg thinks it should not be needed, so rely on STDLIBS_BY_VERSION
stdlibs = Types.get_last_stdlibs(ctx.julia_version)
p = stdlibs[pkg.uuid]
pkg.weakdeps = Dict{String, Base.UUID}(stdlibs[uuid].name => uuid for uuid in p.weakdeps)
# pkg.exts = p.exts # TODO: STDLIBS_BY_VERSION doesn't record this
# pkg.entryfile = p.entryfile # TODO: STDLIBS_BY_VERSION doesn't record this
for (name, _) in pkg.weakdeps
if !haskey(p.deps, name)
delete!(pkg.deps, name)
end
end
else
# normal mode based on project files.
# isfile_casesenstive within locate_project_file used to error on Windows if given a
# relative path so abspath it to be extra safe https://github.com/JuliaLang/julia/pull/55220
sourcepath = source_path(env.manifest_file, pkg)
if sourcepath === nothing
pkgerror("could not find source path for package $(pkg.name) based on manifest $(env.manifest_file)")
end
project_file = Base.locate_project_file(abspath(sourcepath))
if project_file isa String && isfile(project_file)
p = Types.read_project(project_file)
pkg.weakdeps = p.weakdeps
pkg.exts = p.exts
pkg.entryfile = p.entryfile
for (name, _) in p.weakdeps
if !haskey(p.deps, name)
delete!(pkg.deps, name)
end
end
end
end
end
prune_manifest(env)
Expand Down Expand Up @@ -1658,7 +1679,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
man_pkgs, deps_map = _resolve(ctx.io, ctx.env, ctx.registries, pkgs, preserve, ctx.julia_version)
update_manifest!(ctx.env, man_pkgs, deps_map, ctx.julia_version)
new_apply = download_source(ctx)
fixups_from_projectfile!(ctx.env)
fixups_from_projectfile!(ctx)

# After downloading resolutionary packages, search for (Julia)Artifacts.toml files
# and ensure they are all downloaded and unpacked as well:
Expand Down Expand Up @@ -1705,7 +1726,7 @@ function develop(ctx::Context, pkgs::Vector{PackageSpec}, new_git::Set{UUID};
pkgs, deps_map = _resolve(ctx.io, ctx.env, ctx.registries, pkgs, preserve, ctx.julia_version)
update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version)
new_apply = download_source(ctx)
fixups_from_projectfile!(ctx.env)
fixups_from_projectfile!(ctx)
download_artifacts(ctx; platform=platform, julia_version=ctx.julia_version)
write_env(ctx.env) # write env before building
show_update(ctx.env, ctx.registries; io=ctx.io)
Expand Down Expand Up @@ -1846,7 +1867,7 @@ function up(ctx::Context, pkgs::Vector{PackageSpec}, level::UpgradeLevel;
end
update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version)
new_apply = download_source(ctx)
fixups_from_projectfile!(ctx.env)
fixups_from_projectfile!(ctx)
download_artifacts(ctx, julia_version=ctx.julia_version)
write_env(ctx.env; skip_writing_project) # write env before building
show_update(ctx.env, ctx.registries; io=ctx.io, hidden_upgrades_info = true)
Expand Down Expand Up @@ -1892,7 +1913,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec})

update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version)
new = download_source(ctx)
fixups_from_projectfile!(ctx.env)
fixups_from_projectfile!(ctx)
download_artifacts(ctx; julia_version=ctx.julia_version)
write_env(ctx.env) # write env before building
show_update(ctx.env, ctx.registries; io=ctx.io)
Expand Down Expand Up @@ -1940,7 +1961,7 @@ function free(ctx::Context, pkgs::Vector{PackageSpec}; err_if_free=true)

update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version)
new = download_source(ctx)
fixups_from_projectfile!(ctx.env)
fixups_from_projectfile!(ctx)
download_artifacts(ctx)
write_env(ctx.env) # write env before building
show_update(ctx.env, ctx.registries; io=ctx.io)
Expand All @@ -1964,14 +1985,18 @@ end


function get_threads_spec()
if Threads.nthreads(:interactive) > 0
if haskey(ENV, "JULIA_NUM_THREADS")
# if set, prefer JULIA_NUM_THREADS because this is passed to the test worker via --threads
# which takes precedence in the worker
ENV["JULIA_NUM_THREADS"]
elseif Threads.nthreads(:interactive) > 0
"$(Threads.nthreads(:default)),$(Threads.nthreads(:interactive))"
else
"$(Threads.nthreads(:default))"
end
end

function gen_subprocess_flags(source_path::String; coverage, julia_args)
function gen_subprocess_flags(source_path::String; coverage, julia_args::Cmd)
coverage_arg = if coverage isa Bool
# source_path is the package root, not "src" so "ext" etc. is included
coverage ? string("@", source_path) : "none"
Expand Down Expand Up @@ -2309,7 +2334,7 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
test_fn !== nothing && test_fn()
sandbox_ctx = Context(;io=ctx.io)
status(sandbox_ctx.env, sandbox_ctx.registries; mode=PKGMODE_COMBINED, io=sandbox_ctx.io, ignore_indent = false, show_usagetips = false)
flags = gen_subprocess_flags(source_path; coverage,julia_args)
flags = gen_subprocess_flags(source_path; coverage, julia_args)

if should_autoprecompile()
cacheflags = Base.CacheFlags(parse(UInt8, read(`$(Base.julia_cmd()) $(flags) --eval 'show(ccall(:jl_cache_flags, UInt8, ()))'`, String)))
Expand All @@ -2319,7 +2344,7 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
printpkgstyle(ctx.io, :Testing, "Running tests...")
flush(ctx.io)
code = gen_test_code(source_path; test_args)
cmd = `$(Base.julia_cmd()) $(flags) --threads=$(get_threads_spec()) --eval $code`
cmd = `$(Base.julia_cmd()) --threads=$(get_threads_spec()) $(flags) --eval $code`
p, interrupted = subprocess_handler(cmd, ctx.io, "Tests interrupted. Exiting the test process")
if success(p)
printpkgstyle(ctx.io, :Testing, pkg.name * " tests passed ")
Expand Down Expand Up @@ -2549,8 +2574,7 @@ end

function is_package_downloaded(manifest_file::String, pkg::PackageSpec; platform=HostPlatform())
sourcepath = source_path(manifest_file, pkg)
identifier = pkg.name !== nothing ? pkg.name : pkg.uuid
(sourcepath === nothing) && pkgerror("Could not locate the source code for the $(identifier) package. Are you trying to use a manifest generated by a different version of Julia?")
sourcepath === nothing && return false
isdir(sourcepath) || return false
check_artifacts_downloaded(sourcepath; platform) || return false
return true
Expand Down
1 change: 1 addition & 0 deletions src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -869,5 +869,6 @@ include("precompile.jl")
DEFAULT_IO[] = nothing
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = false
PREV_ENV_PATH[] = ""
Types.STDLIB[] = nothing

end # module
4 changes: 2 additions & 2 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ is_project_uuid(env::EnvCache, uuid::UUID) = project_uuid(env) == uuid

const UPGRADABLE_STDLIBS = ["DelimitedFiles", "Statistics"]
const UPGRADABLE_STDLIBS_UUIDS = Set{UUID}()
const STDLIB = Ref{DictStdLibs}()
const STDLIB = Ref{Union{DictStdLibs, Nothing}}(nothing)
function load_stdlib()
stdlib = DictStdLibs()
for name in readdir(stdlib_dir())
Expand Down Expand Up @@ -500,7 +500,7 @@ function stdlibs()
return Dict(uuid => (info.name, info.version) for (uuid, info) in stdlib_infos())
end
function stdlib_infos()
if !isassigned(STDLIB)
if STDLIB[] === nothing
STDLIB[] = load_stdlib()
end
return STDLIB[]
Expand Down
11 changes: 7 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# "Precompiling" is the longest operation
const pkgstyle_indent = textwidth(string(:Precompiling))

function printpkgstyle(io::IO, cmd::Symbol, text::String, ignore_indent::Bool=false; color=:green)
indent = textwidth(string(:Precompiling)) # "Precompiling" is the longest operation
ignore_indent && (indent = 0)
printstyled(io, lpad(string(cmd), indent), color=color, bold=true)
println(io, " ", text)
indent = ignore_indent ? 0 : pkgstyle_indent
@lock io begin
printstyled(io, lpad(string(cmd), indent), color=color, bold=true)
println(io, " ", text)
end
end

function linewrap(str::String; io = stdout_f(), padding = 0, width = Base.displaysize(io)[2])
Expand Down
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
HistoricalStdlibVersions = "6df8b67a-e8a0-4029-b4b7-ac196fe72102"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Expand All @@ -15,4 +16,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Aqua = "0.8.10"
HistoricalStdlibVersions = "2"
2 changes: 2 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
using Aqua
Aqua.test_all(Pkg)
Loading