Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use public API for Pkg stdlibs #3098

Merged
merged 4 commits into from
Feb 14, 2025
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
19 changes: 3 additions & 16 deletions src/packages/PkgCompat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,9 @@ end
# Standard Libraries
###

# (⚠️ Internal API with fallback)
_stdlibs() = try
stdlibs = values(Pkg.Types.stdlibs())
T = eltype(stdlibs)
if T == String
stdlibs
elseif T <: Tuple{String,Any}
first.(stdlibs)
else
error()
end
catch e
@warn "Pkg compat: failed to load standard libraries." exception=(e,catch_backtrace())

String["ArgTools", "Artifacts", "Base64", "CRC32c", "CompilerSupportLibraries_jll", "Dates", "DelimitedFiles", "Distributed", "Downloads", "FileWatching", "Future", "GMP_jll", "InteractiveUtils", "LLD_jll", "LLVMLibUnwind_jll", "LazyArtifacts", "LibCURL", "LibCURL_jll", "LibGit2", "LibGit2_jll", "LibOSXUnwind_jll", "LibSSH2_jll", "LibUV_jll", "LibUnwind_jll", "Libdl", "LinearAlgebra", "Logging", "MPFR_jll", "Markdown", "MbedTLS_jll", "Mmap", "MozillaCACerts_jll", "NetworkOptions", "OpenBLAS_jll", "OpenLibm_jll", "PCRE2_jll", "Pkg", "Printf", "Profile", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "SuiteSparse", "SuiteSparse_jll", "TOML", "Tar", "Test", "UUIDs", "Unicode", "Zlib_jll", "dSFMT_jll", "libLLVM_jll", "libblastrampoline_jll", "nghttp2_jll", "p7zip_jll"]
end
# (✅ Public API)
_stdlibs_found = sort(readdir(Sys.STDLIB))
_stdlibs() = _stdlibs_found

# ⚠️ Internal API with fallback
is_stdlib(package_name::AbstractString) = package_name ∈ _stdlibs()
Expand Down
12 changes: 12 additions & 0 deletions test/packages/PkgCompat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ import Pkg
@test PkgCompat.package_exists("Dates")

@test PkgCompat.is_stdlib("Dates")
@test PkgCompat.is_stdlib("Markdown")
@test PkgCompat.is_stdlib("Sockets")
@test PkgCompat.is_stdlib("MbedTLS_jll")
@test PkgCompat.is_stdlib("Test")
@test PkgCompat.is_stdlib("Pkg")
@test PkgCompat.is_stdlib("Random")
@test PkgCompat.is_stdlib("FileWatching")
@test PkgCompat.is_stdlib("Distributed")
# upgradable stdlibs:
@test PkgCompat.is_stdlib("Statistics")
@test PkgCompat.is_stdlib("DelimitedFiles")

@test !PkgCompat.is_stdlib("PlutoUI")


Expand Down
Loading