Created
February 9, 2026 06:27
-
-
Save inkydragon/b51d233ba500a4eb218a93623fa86c40 to your computer and use it in GitHub Desktop.
Get a list of standard libraries available in the current Julia installation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-License-Identifier: MIT | |
| """ | |
| Get a list of standard libraries available in the current Julia installation. | |
| Test with Julia v1.0, v1.6~v1.14-DEV | |
| # Returns | |
| - A sorted vector of strings, each representing a standard library name. | |
| """ | |
| function get_stdlibs() | |
| lib_names = String[] | |
| # Read stdlibs from disk | |
| if isdir(Sys.STDLIB) | |
| for entry in readdir(Sys.STDLIB) | |
| path = joinpath(Sys.STDLIB, entry) | |
| if isdir(path) | |
| push!(lib_names, entry) | |
| end | |
| end | |
| end | |
| if isdefined(Pkg.Types, :stdlibs) | |
| ret_type = typeof(Pkg.Types.stdlibs()) | |
| if ret_type == Dict{Base.UUID, String} | |
| # v1.6, v1.7 | |
| append!(lib_names, values(Pkg.Types.stdlibs())) | |
| else | |
| @warn "Unknown return type: `$ret_type` for Pkg.Types.stdlibs()" | |
| # v1.8+ | |
| # :: Dict{UUID, Tuple{String, VersionNumber}} | |
| for v in values(Pkg.Types.stdlibs()) | |
| push!(lib_names, v[1]) | |
| end | |
| end | |
| end | |
| # Need for Julia v1.11+ | |
| if isdefined(Pkg.Types, :UPGRADABLE_STDLIBS) | |
| push!(lib_names, Pkg.Types.UPGRADABLE_STDLIBS...) | |
| end | |
| sort!(lib_names) | |
| unique!(lib_names) | |
| return lib_names | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment