Skip to content

Commit f7dffce

Browse files
committed
fixups for ExplicitImports.jl
1 parent 2dcbe44 commit f7dffce

File tree

21 files changed

+156
-144
lines changed

21 files changed

+156
-144
lines changed

.github/workflows/check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,30 @@ jobs:
2828
- uses: fredrikekre/runic-action@v1
2929
with:
3030
version: "1.4" # Keep version in sync with .pre-commit-config.yaml
31+
32+
explicit-imports:
33+
runs-on: ubuntu-latest
34+
name: "ExplicitImports.jl"
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: julia-actions/setup-julia@v2
38+
with:
39+
version: 'nightly'
40+
- uses: julia-actions/cache@v2
41+
- uses: julia-actions/julia-buildpkg@v1
42+
- name: Install dependencies
43+
shell: julia {0}
44+
run: |
45+
# Add ExplicitImports.jl
46+
using Pkg
47+
Pkg.add([
48+
PackageSpec(name = "ExplicitImports", version = "1.12"),
49+
])
50+
- name: ExplicitImports.jl code checks
51+
shell: julia --project {0}
52+
run: |
53+
using Pkg, ExplicitImports
54+
# check_no_implicit_imports(Pkg) # `Pkg.Registry`: `@dateformat_str` bug in ExplicitImports?
55+
# check_no_stale_explicit_imports(Pkg) # artifact_names in PkgArtifacts
56+
check_all_qualified_accesses_via_owners(Pkg)
57+
check_no_self_qualified_accesses(Pkg)

.pre-commit-config.yaml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,3 @@ repos:
1515
- id: runic
1616
additional_dependencies:
1717
- '[email protected]' # Keep version in sync with .github/workflows/Check.yml
18-
19-
explicit-imports:
20-
runs-on: ubuntu-latest
21-
name: "ExplicitImports.jl"
22-
steps:
23-
- uses: actions/checkout@v4
24-
- uses: julia-actions/setup-julia@v2
25-
with:
26-
version: 'nightly'
27-
- uses: julia-actions/cache@v2
28-
- uses: julia-actions/julia-buildpkg@v1
29-
- name: Install dependencies
30-
shell: julia {0}
31-
run: |
32-
# Add ExplicitImports.jl
33-
using Pkg
34-
Pkg.add([
35-
PackageSpec(name = "ExplicitImports", version = "1.12"),
36-
])
37-
- name: ExplicitImports.jl code checks
38-
shell: julia --project {0}
39-
run: |
40-
using Pkg, ExplicitImports
41-
check_no_implicit_imports(Pkg)
42-
# check_no_stale_explicit_imports(Pkg) # artifact_names in PkgArtifacts
43-
check_all_qualified_accesses_via_owners(Pkg)
44-
check_no_self_qualified_accesses(Pkg)

ext/REPLExt/REPLExt.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ if Base.get_bool_env("JULIA_PKG_DISALLOW_PKG_PRECOMPILATION", false) == true
44
error("Precompililing Pkg extension REPLExt is disallowed. JULIA_PKG_DISALLOW_PKG_PRECOMPILATION=$(ENV["JULIA_PKG_DISALLOW_PKG_PRECOMPILATION"])")
55
end
66

7-
using Markdown, UUIDs, Dates
7+
import Dates
8+
using UUIDs: UUID
89

910
import REPL
1011
import .REPL: LineEdit, REPLCompletions, TerminalMenus
@@ -339,6 +340,6 @@ function __init__()
339340
end
340341
end
341342

342-
include("precompile.jl")
343+
# include("precompile.jl")
343344

344345
end

src/API.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22

33
module API
44

5-
using UUIDs
6-
using Printf
7-
import Random
8-
using Dates
5+
import FileWatching
96
import LibGit2
107
import Logging
11-
import FileWatching
8+
import Printf
9+
import Random
10+
using Dates: Dates, DateTime, Day, Period, now
11+
using UUIDs: UUIDs, UUID
1212

13-
import Base: StaleCacheKey
13+
using Base.BinaryPlatforms
1414

15-
import ..depots, ..depots1, ..logdir, ..devdir, ..printpkgstyle, .._autoprecompilation_enabled_scoped
1615
import ..Operations, ..GitTools, ..Pkg, ..Registry
16+
import ..TOML
17+
import ..depots1, ..logdir, ..devdir, ..printpkgstyle, .._autoprecompilation_enabled_scoped
1718
import ..can_fancyprint, ..pathrepr, ..isurl, ..PREV_ENV_PATH, ..atomic_toml_write
18-
using ..Types, ..TOML
19-
using ..Types: VersionTypes
20-
using Base.BinaryPlatforms
2119
import ..stderr_f, ..stdout_f
20+
import ..Resolve: ResolverError, ResolverTimeoutError
21+
using ..Types
2222
using ..Artifacts: artifact_paths
2323
using ..MiniProgressBars
24-
import ..Resolve: ResolverError, ResolverTimeoutError
2524

2625
include("generate.jl")
2726

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

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

588587
# First, we load in our `manifest_usage.toml` files which will tell us when our
589588
# "index files" (`Manifest.toml`, `Artifacts.toml`) were last used. We will combine
@@ -1435,10 +1434,10 @@ function activate(path::AbstractString; shared::Bool = false, temp::Bool = false
14351434
end
14361435
end
14371436
else
1438-
# initialize `fullpath` in case of empty `Pkg.depots()`
1437+
# initialize `fullpath` in case of empty `Pkg.Base.DEPOT_PATH`
14391438
fullpath = ""
14401439
# loop over all depots to check if the shared environment already exists
1441-
for depot in Pkg.depots()
1440+
for depot in Pkg.Base.DEPOT_PATH
14421441
fullpath = joinpath(Pkg.envdir(depot), path)
14431442
isdir(fullpath) && break
14441443
end

src/Apps/Apps.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module Apps
22

3-
using Pkg
4-
using Pkg: atomic_toml_write
5-
using Pkg.Versions
6-
using Pkg.Types: AppInfo, PackageSpec, Context, EnvCache, PackageEntry, Manifest, handle_repo_add!, handle_repo_develop!, write_manifest, write_project,
3+
using ..Pkg: atomic_toml_write
4+
using ..Pkg.Versions
5+
using ..Pkg.Types: AppInfo, PackageSpec, Context, EnvCache, PackageEntry, Manifest, handle_repo_add!, handle_repo_develop!, write_manifest,
76
pkgerror, projectfile_path, manifestfile_path
8-
using Pkg.Operations: print_single, source_path, update_package_add
9-
using Pkg.API: handle_package_input!
10-
using TOML, UUIDs
11-
import Pkg.Registry
7+
using ..Pkg.Operations: print_single, source_path, update_package_add
8+
using ..Pkg.API: handle_package_input!
9+
import TOML
10+
using UUIDs: UUID
11+
import ..Registry
1212

1313
app_env_folder() = joinpath(first(DEPOT_PATH), "environments", "apps")
1414
app_manifest_file() = joinpath(app_env_folder(), "AppManifest.toml")

src/Artifacts.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
module PkgArtifacts
22

3-
using Artifacts, Base.BinaryPlatforms, SHA
4-
using ..MiniProgressBars, ..PlatformEngines
3+
import FileWatching
4+
using Artifacts: @artifact_str, artifact_exists, artifact_hash, artifact_meta, artifact_path, find_artifacts_toml, select_downloadable_artifacts
5+
using SHA: SHA, SHA256_CTX, sha256
56
using Tar: can_symlink
6-
using FileWatching: FileWatching
77

8-
import ..set_readonly, ..GitTools, ..TOML, ..pkg_server, ..can_fancyprint,
9-
..stderr_f, ..printpkgstyle, ..mv_temp_dir_retries, ..atomic_toml_write
8+
using Base.BinaryPlatforms
109

10+
import Artifacts: artifact_names, artifact_paths, artifacts_dirs, pack_platform!, unpack_platform, load_artifacts_toml, query_override
1111
import Base: get, SHA1
12-
import Artifacts: artifact_names, ARTIFACTS_DIR_OVERRIDE, ARTIFACT_OVERRIDES, artifact_paths,
13-
artifacts_dirs, pack_platform!, unpack_platform, load_artifacts_toml,
14-
query_override, with_artifacts_directory, load_overrides
12+
13+
import ..set_readonly, ..GitTools, ..TOML, ..pkg_server, ..can_fancyprint,
14+
..stderr_f, ..printpkgstyle, ..mv_temp_dir_retries, ..atomic_toml_write
1515
import ..Types: write_env_usage, parse_toml
16+
using ..MiniProgressBars, ..PlatformEngines
1617

1718
const Artifacts = PkgArtifacts # This is to preserve compatability for folks who depend on the internals of this module
1819
export Artifacts, create_artifact, artifact_exists, artifact_path, remove_artifact, verify_artifact,

src/BinaryPlatformsCompat.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ module BinaryPlatformsCompat
8787
end
8888

8989
# Next, things we don't need to coerce
90-
for f in (:libgfortran_version, :libstdcxx_version, :platform_name, :wordsize, :platform_dlext, :tags, :triplet)
91-
@eval begin
92-
$(f)(p::PlatformUnion) = $(f)(p.p)
93-
end
94-
end
90+
libgfortran_version(p::PlatformUnion) = libgfortran_version(p.p)
91+
libstdcxx_version(p::PlatformUnion) = libstdcxx_version(p.p)
92+
platform_name(p::PlatformUnion) = platform_name(p.p)
93+
wordsize(p::PlatformUnion) = wordsize(p.p)
94+
platform_dlext(p::PlatformUnion) = platform_dlext(p.p)
95+
tags(p::PlatformUnion) = tags(p.p)
96+
triplet(p::PlatformUnion) = triplet(p.p)
9597

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

101101
# Add one-off functions
102102
MacOS(; kwargs...) = MacOS(:x86_64; kwargs...)

src/GitTools.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
module GitTools
44

5+
import LibGit2
6+
using SHA: SHA, SHA1_CTX, update!
7+
8+
import ..can_fancyprint, ..printpkgstyle, ..stdout_f
59
using ..Pkg
610
using ..MiniProgressBars
7-
import ..can_fancyprint, ..printpkgstyle, ..stdout_f
8-
using SHA
9-
import Base: SHA1
10-
import LibGit2
11-
using Printf
1211

1312
use_cli_git() = Base.get_bool_env("JULIA_PKG_USE_CLI_GIT", false)
1413
const RESOLVING_DELTAS_HEADER = "Resolving Deltas:"
@@ -75,7 +74,7 @@ function ensure_clone(io::IO, target_path, url; kwargs...)
7574
if ispath(target_path)
7675
return LibGit2.GitRepo(target_path)
7776
else
78-
return GitTools.clone(io, url, target_path; kwargs...)
77+
return clone(io, url, target_path; kwargs...)
7978
end
8079
end
8180

src/MiniProgressBars.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module MiniProgressBars
22

33
export MiniProgressBar, start_progress, end_progress, show_progress, print_progress_bottom
44

5-
using Printf
5+
using Printf: @sprintf
66

77
# Until Base.format_bytes supports sigdigits
88
function pkg_format_bytes(bytes; binary = true, sigdigits::Integer = 3)

src/Operations.jl

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
module Operations
44

5-
using FileWatching: FileWatching
6-
using UUIDs
5+
import Dates
6+
import FileWatching
7+
import LibGit2
8+
import TOML
79
using Random: randstring
8-
import LibGit2, Dates, TOML
10+
using UUIDs: UUID
911

10-
using ..Types, ..Resolve, ..PlatformEngines, ..GitTools, ..MiniProgressBars
11-
import ..depots, ..depots1, ..devdir, ..set_readonly, ..Types.PackageEntry
12-
import ..Artifacts: ensure_artifact_installed, artifact_names, extract_all_hashes,
13-
artifact_exists, select_downloadable_artifacts, mv_temp_dir_retries
1412
using Base.BinaryPlatforms
13+
1514
import ...Pkg
16-
import ...Pkg: pkg_server, Registry, pathrepr, can_fancyprint, printpkgstyle, stderr_f, OFFLINE_MODE
15+
import ...Pkg: Registry, pathrepr, can_fancyprint, printpkgstyle, stderr_f, OFFLINE_MODE
1716
import ...Pkg: UPDATED_REGISTRY_THIS_SESSION, RESPECT_SYSIMAGE_VERSIONS, should_autoprecompile
1817
import ...Pkg: usable_io, discover_repo
18+
import ..depots1, ..devdir, ..set_readonly, ..Types.PackageEntry
19+
import ..Artifacts: ensure_artifact_installed, artifact_names,
20+
artifact_exists, select_downloadable_artifacts, mv_temp_dir_retries
21+
using ..Types, ..Resolve, ..PlatformEngines, ..GitTools, ..MiniProgressBars
1922

2023
#########
2124
# Utils #
@@ -61,7 +64,7 @@ function find_installed(name::String, uuid::UUID, sha1::SHA1)
6164
slug_default = Base.version_slug(uuid, sha1)
6265
# 4 used to be the default so look there first
6366
for slug in (slug_default, Base.version_slug(uuid, sha1, 4))
64-
for depot in depots()
67+
for depot in Base.DEPOT_PATH
6568
path = abspath(depot, "packages", name, slug)
6669
ispath(path) && return path
6770
end
@@ -222,9 +225,9 @@ end
222225
function is_instantiated(env::EnvCache, workspace::Bool = false; platform = HostPlatform())::Bool
223226
# Load everything
224227
if workspace
225-
pkgs = Operations.load_all_deps(env)
228+
pkgs = load_all_deps(env)
226229
else
227-
pkgs = Operations.load_all_deps_loadable(env)
230+
pkgs = load_all_deps_loadable(env)
228231
end
229232
# If the top-level project is a package, ensure it is instantiated as well
230233
if env.pkg !== nothing
@@ -913,8 +916,8 @@ function install_git(
913916
GitTools.checkout_tree_to_path(repo, tree, version_path)
914917
return
915918
finally
916-
repo !== nothing && LibGit2.close(repo)
917-
tree !== nothing && LibGit2.close(tree)
919+
repo !== nothing && close(repo)
920+
tree !== nothing && close(tree)
918921
end
919922
end
920923

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

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

2992-
new_ver_avail = !latest_version && !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new)
2995+
new_ver_avail = !latest_version && !is_tracking_repo(new) && !is_tracking_path(new)
29932996
pkg_upgradable = new_ver_avail && cinfo !== nothing && isempty(cinfo[1])
29942997
pkg_heldback = new_ver_avail && cinfo !== nothing && !isempty(cinfo[1])
29952998

0 commit comments

Comments
 (0)