Skip to content
Open
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
27 changes: 27 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,30 @@ jobs:
- uses: fredrikekre/runic-action@v1
with:
version: "1.4" # Keep version in sync with .pre-commit-config.yaml

explicit-imports:
runs-on: ubuntu-latest
name: "ExplicitImports.jl"
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 'nightly'
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- name: Install dependencies
shell: julia {0}
run: |
# Add ExplicitImports.jl
using Pkg
Pkg.add([
PackageSpec(name = "ExplicitImports", version = "1.12"),
])
- name: ExplicitImports.jl code checks
shell: julia --project {0}
run: |
using Pkg, ExplicitImports
# check_no_implicit_imports(Pkg) # `Pkg.Registry`: `@dateformat_str` bug in ExplicitImports?
# check_no_stale_explicit_imports(Pkg) # artifact_names in PkgArtifacts
check_all_qualified_accesses_via_owners(Pkg)
check_no_self_qualified_accesses(Pkg)
3 changes: 2 additions & 1 deletion ext/REPLExt/REPLExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ if Base.get_bool_env("JULIA_PKG_DISALLOW_PKG_PRECOMPILATION", false) == true
error("Precompililing Pkg extension REPLExt is disallowed. JULIA_PKG_DISALLOW_PKG_PRECOMPILATION=$(ENV["JULIA_PKG_DISALLOW_PKG_PRECOMPILATION"])")
end

using Markdown, UUIDs, Dates
import Dates
using UUIDs: UUID

import REPL
import .REPL: LineEdit, REPLCompletions, TerminalMenus
Expand Down
8 changes: 4 additions & 4 deletions ext/REPLExt/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
Pkg.DEFAULT_IO[] = Pkg.unstableio(devnull)
withenv("JULIA_PKG_SERVER" => nothing, "JULIA_PKG_UNPACK_REGISTRY" => nothing) do
tmp = Pkg._run_precompilation_script_setup()
tmp = Pkg.PrecompileHelper._run_precompilation_script_setup()
cd(tmp) do
try_prompt_pkg_add(Symbol[:notapackage])
promptf()
Expand All @@ -29,10 +29,10 @@ let
copy!(DEPOT_PATH, original_depot_path)
copy!(LOAD_PATH, original_load_path)

Base.precompile(Tuple{typeof(REPL.LineEdit.complete_line), REPLExt.PkgCompletionProvider, REPL.LineEdit.PromptState})
Base.precompile(Tuple{typeof(REPL.LineEdit.complete_line), PkgCompletionProvider, REPL.LineEdit.PromptState})
Base.precompile(Tuple{typeof(REPL.REPLCompletions.completion_text), REPL.REPLCompletions.PackageCompletion})
Base.precompile(Tuple{typeof(REPLExt.on_done), REPL.LineEdit.MIState, Base.GenericIOBuffer{Memory{UInt8}}, Bool, REPL.LineEditREPL})
return Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:hint,), Tuple{Bool}}, typeof(REPL.LineEdit.complete_line), REPLExt.PkgCompletionProvider, REPL.LineEdit.PromptState})
Base.precompile(Tuple{typeof(on_done), REPL.LineEdit.MIState, Base.GenericIOBuffer{Memory{UInt8}}, Bool, REPL.LineEditREPL})
return Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:hint,), Tuple{Bool}}, typeof(REPL.LineEdit.complete_line), PkgCompletionProvider, REPL.LineEdit.PromptState})
end

if Base.generating_output()
Expand Down
27 changes: 13 additions & 14 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@

module API

using UUIDs
using Printf
import Random
using Dates
import FileWatching
import LibGit2
import Logging
import FileWatching
import Printf
import Random
using Dates: Dates, DateTime, Day, Period, now
using UUIDs: UUIDs, UUID

import Base: StaleCacheKey
using Base.BinaryPlatforms

import ..depots, ..depots1, ..logdir, ..devdir, ..printpkgstyle, .._autoprecompilation_enabled_scoped
import ..Operations, ..GitTools, ..Pkg, ..Registry
import ..TOML
import ..depots1, ..logdir, ..devdir, ..printpkgstyle, .._autoprecompilation_enabled_scoped
import ..can_fancyprint, ..pathrepr, ..isurl, ..PREV_ENV_PATH, ..atomic_toml_write
using ..Types, ..TOML
using ..Types: VersionTypes
using Base.BinaryPlatforms
import ..stderr_f, ..stdout_f
import ..Resolve: ResolverError, ResolverTimeoutError
using ..Types
using ..Artifacts: artifact_paths
using ..MiniProgressBars
import ..Resolve: ResolverError, ResolverTimeoutError

include("generate.jl")

Expand Down Expand Up @@ -583,7 +582,7 @@ function gc(ctx::Context = Context(); collect_delay::Period = Day(7), verbose =
env = ctx.env

# Only look at user-depot unless force=true
gc_depots = force ? depots() : [depots1()]
gc_depots = force ? Base.DEPOT_PATH : [depots1()]

# First, we load in our `manifest_usage.toml` files which will tell us when our
# "index files" (`Manifest.toml`, `Artifacts.toml`) were last used. We will combine
Expand Down Expand Up @@ -1435,10 +1434,10 @@ function activate(path::AbstractString; shared::Bool = false, temp::Bool = false
end
end
else
# initialize `fullpath` in case of empty `Pkg.depots()`
# initialize `fullpath` in case of empty `Pkg.Base.DEPOT_PATH`
fullpath = ""
# loop over all depots to check if the shared environment already exists
for depot in Pkg.depots()
for depot in Pkg.Base.DEPOT_PATH
Comment on lines -1441 to +1440
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I removed depots() and replaced it with Base.DEPOT_PATH. This is weird (should just be Base.DEPOT_PATH) but I don't think it should change anything..

fullpath = joinpath(Pkg.envdir(depot), path)
isdir(fullpath) && break
end
Expand Down
17 changes: 9 additions & 8 deletions src/Apps/Apps.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module Apps

using Pkg
using Pkg: atomic_toml_write
using Pkg.Versions
using Pkg.Types: AppInfo, PackageSpec, Context, EnvCache, PackageEntry, Manifest, handle_repo_add!, handle_repo_develop!, write_manifest, write_project,
import ..Pkg
using ..Pkg: atomic_toml_write
using ..Pkg.Versions
using ..Pkg.Types: AppInfo, PackageSpec, Context, EnvCache, PackageEntry, Manifest, handle_repo_add!, handle_repo_develop!, write_manifest,
pkgerror, projectfile_path, manifestfile_path
using Pkg.Operations: print_single, source_path, update_package_add
using Pkg.API: handle_package_input!
using TOML, UUIDs
import Pkg.Registry
using ..Pkg.Operations: print_single, source_path, update_package_add
using ..Pkg.API: handle_package_input!
import TOML
using UUIDs: UUID
import ..Registry

app_env_folder() = joinpath(first(DEPOT_PATH), "environments", "apps")
app_manifest_file() = joinpath(app_env_folder(), "AppManifest.toml")
Expand Down
17 changes: 9 additions & 8 deletions src/Artifacts.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
module PkgArtifacts

using Artifacts, Base.BinaryPlatforms, SHA
using ..MiniProgressBars, ..PlatformEngines
import FileWatching
using Artifacts: @artifact_str, artifact_exists, artifact_hash, artifact_meta, artifact_path, find_artifacts_toml, select_downloadable_artifacts, with_artifacts_directory
using SHA: SHA, SHA256_CTX, sha256
using Tar: can_symlink
using FileWatching: FileWatching

import ..set_readonly, ..GitTools, ..TOML, ..pkg_server, ..can_fancyprint,
..stderr_f, ..printpkgstyle, ..mv_temp_dir_retries, ..atomic_toml_write
using Base.BinaryPlatforms

import Artifacts: artifact_names, artifact_paths, artifacts_dirs, pack_platform!, unpack_platform, load_artifacts_toml, query_override
import Base: get, SHA1
import Artifacts: artifact_names, ARTIFACTS_DIR_OVERRIDE, ARTIFACT_OVERRIDES, artifact_paths,
artifacts_dirs, pack_platform!, unpack_platform, load_artifacts_toml,
query_override, with_artifacts_directory, load_overrides

import ..set_readonly, ..GitTools, ..TOML, ..pkg_server, ..can_fancyprint,
..stderr_f, ..printpkgstyle, ..mv_temp_dir_retries, ..atomic_toml_write
import ..Types: write_env_usage, parse_toml
using ..MiniProgressBars, ..PlatformEngines

const Artifacts = PkgArtifacts # This is to preserve compatability for folks who depend on the internals of this module
export Artifacts, create_artifact, artifact_exists, artifact_path, remove_artifact, verify_artifact,
Expand Down
16 changes: 8 additions & 8 deletions src/BinaryPlatformsCompat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ module BinaryPlatformsCompat
end

# Next, things we don't need to coerce
for f in (:libgfortran_version, :libstdcxx_version, :platform_name, :wordsize, :platform_dlext, :tags, :triplet)
@eval begin
$(f)(p::PlatformUnion) = $(f)(p.p)
end
end
libgfortran_version(p::PlatformUnion) = libgfortran_version(p.p)
libstdcxx_version(p::PlatformUnion) = libstdcxx_version(p.p)
platform_name(p::PlatformUnion) = platform_name(p.p)
wordsize(p::PlatformUnion) = wordsize(p.p)
platform_dlext(p::PlatformUnion) = platform_dlext(p.p)
tags(p::PlatformUnion) = tags(p.p)
triplet(p::PlatformUnion) = triplet(p.p)

# Finally, add equality testing between these wrapper types and other AbstractPlatforms
@eval begin
Base.:(==)(a::PlatformUnion, b::AbstractPlatform) = b == a.p
end
Base.:(==)(a::PlatformUnion, b::AbstractPlatform) = b == a.p

# Add one-off functions
MacOS(; kwargs...) = MacOS(:x86_64; kwargs...)
Expand Down
11 changes: 5 additions & 6 deletions src/GitTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

module GitTools

import LibGit2
using SHA: SHA, SHA1_CTX, update!

import ..can_fancyprint, ..printpkgstyle, ..stdout_f
using ..Pkg
using ..MiniProgressBars
import ..can_fancyprint, ..printpkgstyle, ..stdout_f
using SHA
import Base: SHA1
import LibGit2
using Printf

use_cli_git() = Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false)
const RESOLVING_DELTAS_HEADER = "Resolving Deltas:"
Expand Down Expand Up @@ -75,7 +74,7 @@ function ensure_clone(io::IO, target_path, url; kwargs...)
if ispath(target_path)
return LibGit2.GitRepo(target_path)
else
return GitTools.clone(io, url, target_path; kwargs...)
return clone(io, url, target_path; kwargs...)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/MiniProgressBars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module MiniProgressBars

export MiniProgressBar, start_progress, end_progress, show_progress, print_progress_bottom

using Printf
using Printf: @sprintf

# Until Base.format_bytes supports sigdigits
function pkg_format_bytes(bytes; binary = true, sigdigits::Integer = 3)
Expand Down
35 changes: 19 additions & 16 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

module Operations

using FileWatching: FileWatching
using UUIDs
import Dates
import FileWatching
import LibGit2
import TOML
using Random: randstring
import LibGit2, Dates, TOML
using UUIDs: UUID

using ..Types, ..Resolve, ..PlatformEngines, ..GitTools, ..MiniProgressBars
import ..depots, ..depots1, ..devdir, ..set_readonly, ..Types.PackageEntry
import ..Artifacts: ensure_artifact_installed, artifact_names, extract_all_hashes,
artifact_exists, select_downloadable_artifacts, mv_temp_dir_retries
using Base.BinaryPlatforms

import ...Pkg
import ...Pkg: pkg_server, Registry, pathrepr, can_fancyprint, printpkgstyle, stderr_f, OFFLINE_MODE
import ...Pkg: Registry, pathrepr, can_fancyprint, printpkgstyle, stderr_f, OFFLINE_MODE
import ...Pkg: UPDATED_REGISTRY_THIS_SESSION, RESPECT_SYSIMAGE_VERSIONS, should_autoprecompile
import ...Pkg: usable_io, discover_repo
import ..depots1, ..devdir, ..set_readonly, ..Types.PackageEntry
import ..Artifacts: ensure_artifact_installed, artifact_names,
artifact_exists, select_downloadable_artifacts, mv_temp_dir_retries
using ..Types, ..Resolve, ..PlatformEngines, ..GitTools, ..MiniProgressBars

#########
# Utils #
Expand Down Expand Up @@ -61,7 +64,7 @@ function find_installed(name::String, uuid::UUID, sha1::SHA1)
slug_default = Base.version_slug(uuid, sha1)
# 4 used to be the default so look there first
for slug in (slug_default, Base.version_slug(uuid, sha1, 4))
for depot in depots()
for depot in Base.DEPOT_PATH
path = abspath(depot, "packages", name, slug)
ispath(path) && return path
end
Expand Down Expand Up @@ -222,9 +225,9 @@ end
function is_instantiated(env::EnvCache, workspace::Bool = false; platform = HostPlatform())::Bool
# Load everything
if workspace
pkgs = Operations.load_all_deps(env)
pkgs = load_all_deps(env)
else
pkgs = Operations.load_all_deps_loadable(env)
pkgs = load_all_deps_loadable(env)
end
# If the top-level project is a package, ensure it is instantiated as well
if env.pkg !== nothing
Expand Down Expand Up @@ -913,8 +916,8 @@ function install_git(
GitTools.checkout_tree_to_path(repo, tree, version_path)
return
finally
repo !== nothing && LibGit2.close(repo)
tree !== nothing && LibGit2.close(tree)
repo !== nothing && close(repo)
tree !== nothing && close(tree)
end
end

Expand Down Expand Up @@ -2704,8 +2707,8 @@ function stat_rep(x::PackageSpec; name = true)
rev = occursin(r"\b([a-f0-9]{40})\b", x.repo.rev) ? x.repo.rev[1:7] : x.repo.rev
end
subdir_str = x.repo.subdir === nothing ? "" : ":$(x.repo.subdir)"
repo = Operations.is_tracking_repo(x) ? "`$(x.repo.source)$(subdir_str)#$(rev)`" : ""
path = Operations.is_tracking_path(x) ? "$(pathrepr(x.path))" : ""
repo = is_tracking_repo(x) ? "`$(x.repo.source)$(subdir_str)#$(rev)`" : ""
path = is_tracking_path(x) ? "$(pathrepr(x.path))" : ""
pinned = x.pinned ? "⚲" : ""
return join(filter(!isempty, [name, version, repo, path, pinned]), " ")
end
Expand Down Expand Up @@ -2989,7 +2992,7 @@ function print_status(

pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.manifest_file, new)

new_ver_avail = !latest_version && !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new)
new_ver_avail = !latest_version && !is_tracking_repo(new) && !is_tracking_path(new)
pkg_upgradable = new_ver_avail && cinfo !== nothing && isempty(cinfo[1])
pkg_heldback = new_ver_avail && cinfo !== nothing && !isempty(cinfo[1])

Expand Down
15 changes: 7 additions & 8 deletions src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end

import Random
import TOML
using Dates
using Dates: Dates, Day, Period, Second

export @pkg_str
export PackageSpec
Expand All @@ -25,13 +25,12 @@ export Registry, RegistrySpec
public activate, add, build, compat, develop, free, gc, generate, instantiate,
pin, precompile, redo, rm, resolve, status, test, undo, update, why

depots() = Base.DEPOT_PATH
function depots1(depot_list::Union{String, Vector{String}} = depots())
function depots1(depot_list::Union{String, Vector{String}} = Base.DEPOT_PATH)
# Get the first depot from a list, with proper error handling
if depot_list isa String
return depot_list
else
isempty(depot_list) && Pkg.Types.pkgerror("no depots provided")
isempty(depot_list) && Types.pkgerror("no depots provided")
return depot_list[1]
end
end
Expand Down Expand Up @@ -109,7 +108,7 @@ include("Apps/Apps.jl")
include("REPLMode/REPLMode.jl")

import .REPLMode: @pkg_str
import .Types: UPLEVEL_MAJOR, UPLEVEL_MINOR, UPLEVEL_PATCH, UPLEVEL_FIXED
import .Types: UPLEVEL_MAJOR, UPLEVEL_MINOR, UPLEVEL_PATCH
import .Types: PKGMODE_MANIFEST, PKGMODE_PROJECT
import .Types: PRESERVE_TIERED_INSTALLED, PRESERVE_TIERED, PRESERVE_ALL_INSTALLED, PRESERVE_ALL, PRESERVE_DIRECT, PRESERVE_SEMVER, PRESERVE_NONE

Expand Down Expand Up @@ -957,7 +956,7 @@ function _auto_gc(ctx::Types.Context; collect_delay::Period = Day(7))
return if curr_time - DEPOT_ORPHANAGE_TIMESTAMPS[depots1()] > delay_secs
printpkgstyle(ctx.io, :Info, "We haven't cleaned this depot up for a bit, running Pkg.gc()...", color = Base.info_color())
try
Pkg.gc(ctx; collect_delay)
gc(ctx; collect_delay)
DEPOT_ORPHANAGE_TIMESTAMPS[depots1()] = curr_time
catch ex
@error("GC failed", exception = ex)
Expand All @@ -972,15 +971,15 @@ end

function _auto_precompile(ctx::Types.Context, pkgs::Vector{PackageSpec} = PackageSpec[]; warn_loaded = true, already_instantiated = false)
return if should_autoprecompile()
Pkg.precompile(ctx, pkgs; internal_call = true, warn_loaded = warn_loaded, already_instantiated = already_instantiated)
precompile(ctx, pkgs; internal_call = true, warn_loaded = warn_loaded, already_instantiated = already_instantiated)
end
end

include("precompile.jl")

# Reset globals that might have been mutated during precompilation.
DEFAULT_IO[] = nothing
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = false
UPDATED_REGISTRY_THIS_SESSION[] = false
PREV_ENV_PATH[] = ""
Types.STDLIB[] = nothing

Expand Down
9 changes: 7 additions & 2 deletions src/PlatformEngines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

module PlatformEngines

using SHA, Downloads, Tar
import Downloads
import Tar
import p7zip_jll
using SHA: SHA, sha256

using Base.BinaryPlatforms

import ...Pkg: Pkg, TOML, pkg_server, depots1, can_fancyprint, stderr_f, atomic_toml_write
using ..MiniProgressBars
using Base.BinaryPlatforms, p7zip_jll

export verify, unpack, package, download_verify_unpack

Expand Down
Loading
Loading