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
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)
# check_no_stale_explicit_imports(Pkg) # artifact_names in PkgArtifacts
check_all_qualified_accesses_via_owners(Pkg)
check_no_self_qualified_accesses(Pkg)
6 changes: 4 additions & 2 deletions ext/REPLExt/REPLExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ 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
using Dates: Dates
using Markdown: Markdown
using UUIDs: UUIDs, UUID

import REPL
import .REPL: LineEdit, REPLCompletions, TerminalMenus
import .REPL: LineEdit, TerminalMenus

import Pkg
import .Pkg: linewrap, pathrepr, compat, can_fancyprint, printpkgstyle, PKGMODE_PROJECT
Expand Down
6 changes: 3 additions & 3 deletions ext/REPLExt/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})
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})
Base.precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:hint,), Tuple{Bool}}, typeof(REPL.LineEdit.complete_line), PkgCompletionProvider, REPL.LineEdit.PromptState})
return
end

Expand Down
19 changes: 9 additions & 10 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

module API

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

import Base: StaleCacheKey

import ..depots, ..depots1, ..logdir, ..devdir, ..printpkgstyle
import ..depots1, ..logdir, ..devdir, ..printpkgstyle
import ..Operations, ..GitTools, ..Pkg, ..Registry
import ..can_fancyprint, ..pathrepr, ..isurl, ..PREV_ENV_PATH
using ..Types, ..TOML
using ..Types: VersionTypes
using ..Types
using TOML: TOML
using Base.BinaryPlatforms
import ..stderr_f, ..stdout_f
using ..Artifacts: artifact_paths
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 @@ -1430,10 +1429,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 `Base.DEPOT_PATH`
fullpath = ""
# loop over all depots to check if the shared environment already exists
for depot in Pkg.depots()
for depot in Base.DEPOT_PATH
fullpath = joinpath(Pkg.envdir(depot), path)
isdir(fullpath) && break
end
Expand Down
5 changes: 3 additions & 2 deletions src/Apps/Apps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module Apps

using Pkg
using Pkg.Versions
using Pkg.Types: AppInfo, PackageSpec, Context, EnvCache, PackageEntry, Manifest, handle_repo_add!, handle_repo_develop!, write_manifest, write_project,
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
using TOML: TOML
using UUIDs: UUIDs, UUID
import Pkg.Registry

app_env_folder() = joinpath(first(DEPOT_PATH), "environments", "apps")
Expand Down
11 changes: 7 additions & 4 deletions src/Artifacts.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module PkgArtifacts

using Artifacts, Base.BinaryPlatforms, SHA
using Artifacts: artifact_names, @artifact_str, artifact_exists, artifact_hash, artifact_meta,
artifact_path, find_artifacts_toml,
select_downloadable_artifacts, artifact_paths,
artifacts_dirs, pack_platform!, unpack_platform, load_artifacts_toml,
query_override
using Base.BinaryPlatforms
using SHA: SHA, SHA256_CTX, sha256
using ..MiniProgressBars, ..PlatformEngines
using Tar: can_symlink
using FileWatching: FileWatching
Expand All @@ -9,9 +15,6 @@ import ..set_readonly, ..GitTools, ..TOML, ..pkg_server, ..can_fancyprint,
..stderr_f, ..printpkgstyle, ..mv_temp_dir_retries

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 ..Types: write_env_usage, parse_toml

const Artifacts = PkgArtifacts # This is to preserve compatability for folks who depend on the internals of this module
Expand Down
7 changes: 3 additions & 4 deletions src/GitTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ module GitTools
using ..Pkg
using ..MiniProgressBars
import ..can_fancyprint, ..printpkgstyle, ..stdout_f
using SHA
import Base: SHA1
using SHA: SHA, update!
import LibGit2
using Printf
using Printf: 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: Printf, @sprintf

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

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

using ..Types, ..Resolve, ..PlatformEngines, ..GitTools, ..MiniProgressBars
import ..depots, ..depots1, ..devdir, ..set_readonly, ..Types.PackageEntry
import ..Artifacts: ensure_artifact_installed, artifact_names, extract_all_hashes,
import ..depots1, ..devdir, ..set_readonly, ..Types.PackageEntry
import ..Artifacts: ensure_artifact_installed, artifact_names,
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

Expand All @@ -33,7 +33,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 @@ -194,9 +194,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 @@ -855,8 +855,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 @@ -2593,8 +2593,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 @@ -2879,7 +2879,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 && isempty(cinfo[1])
pkg_heldback = new_ver_avail && !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: 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 @@ -87,7 +86,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 @@ -879,7 +878,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 @@ -894,7 +893,7 @@ end

function _auto_precompile(ctx::Types.Context, pkgs::Vector{PackageSpec} = PackageSpec[]; warn_loaded = true, already_instantiated = false)
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
return
end
Expand All @@ -903,7 +902,7 @@ 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
7 changes: 5 additions & 2 deletions src/PlatformEngines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

module PlatformEngines

using SHA, Downloads, Tar
using SHA: SHA, sha256
using Downloads: Downloads
using Tar: Tar
import ...Pkg: Pkg, TOML, pkg_server, depots1, can_fancyprint, stderr_f
using ..MiniProgressBars
using Base.BinaryPlatforms, p7zip_jll
using Base.BinaryPlatforms
using p7zip_jll: p7zip_jll

export verify, unpack, package, download_verify_unpack

Expand Down
4 changes: 3 additions & 1 deletion src/REPLMode/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module REPLMode

@eval Base.Experimental.@compiler_options optimize = 1

using Markdown, UUIDs, Dates
using Dates: Dates, Hour
using Markdown: Markdown, @md_str
using UUIDs: UUIDs, UUID

import ..casesensitive_isdir, ..OFFLINE_MODE, ..linewrap, ..pathrepr
using ..Types, ..Operations, ..API, ..Registry, ..Resolve, ..Apps
Expand Down
Loading