Tips and tricks - prl-julia/julia-type-stability GitHub Wiki
julia> using Pkg
julia> general=Pkg.Registry.reachable_registries()[1] # NOT PRETTY but normally should Just Work™
Registry: "General" at "/home/artem/.julia/registries/General.toml":
uuid: 23338594-aafe-5451-b93e-139f81909106
repo: https://github.com/JuliaRegistries/General.git
git-tree-sha1: 998e28e3bb762887f738913272e235131e93de60
packages: 9170
julia> uuid=findfirst(p -> p.name == "Multisets", general.pkgs)
UUID("3b2b4ff1-bcff-5658-a3ee-dbcf1ce5ac09")
julia> pkg_info=Pkg.Registry.registry_info(general[uuid])
...
julia> pkg_info.repo
"https://github.com/scheinerman/Multisets.jl.git"
Methods. Assume you have the method name (mf.name
) and module (mf.module
). You can get the method:
julia> fmeth = Core.eval(eval(Meta.parse("$(mf.module)")), Symbol("$(mf.name)"))
The mere number of dependencies in the current project can be checked with Pkg.dependencies()
. But it may be interesting to assess dependency tree (e.g. of the Stability package itself). There're several packages to do that in Julia:
-
PkgDependency — didn't work for me:
repo/Stability on beter-versioning [!] is 📦 v0.1.0 via ஃ v1.8.5 took 2m5s ❯ julia --project ... julia> using PkgDependency julia> PkgDependency.tree("Stability") ERROR: ArgumentError: "Stability" not found in dependencies. Please install this package and retry. Stacktrace: [1] tree(name::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ PkgDependency ~/.julia/packages/PkgDependency/7m1pB/src/PkgDependency.jl:74 [2] tree(name::String) @ PkgDependency ~/.julia/packages/PkgDependency/7m1pB/src/PkgDependency.jl:70 [3] top-level scope @ REPL[2]:1
- PkgGraph — worked for me.
E.g. I add PkgGraph
to the global environment, and then start Julia with the Stability project loaded:
repo/Stability on beter-versioning [!] is 📦 v0.1.0 via ஃ v1.8.5
❯ julia --project
...
julia> using PkgGraph
julia> depgraph_image(:Stability, dir=".", fmt=:svg)
Created Stability-deps.svg
Adding darkmode to [./Stability-deps.svg] … done
We use JuliaPkgsList.jl to get the list of most popular Julia packages to process. Check out the repo, cd
into it and try:
git clone https://github.com/julbinb/JuliaPkgsList.jl.git
cd JuliaPkgsList.jl
./gen-pkgs-list.jl 1000 -o top-1000-ver.txt --nopkgnum -n --includeversion
Explanation:
-
-n
for names, not URLs of packages; -
--nopkgnum
for not adding the number of packages to the file name (I like to give names myself); -
--includeversion
to get the package versions in the same file. May be useful for reproducibility.
Artifact's Overview document describe how to plot 2d-histograms for one package. Here's how to plot in bulk. Assuming you want to go through SVG to make sure the graphs work everywhere.
-
Create the list of packages of interest in a separate file. E.g.
head top-1000-pkgs.txt > top-10-pkgs.txt
. -
Change
OUTPUT_FORMAT
inscripts/plot.jl
tosvg
. -
Enter the artifact sandbox (for reproducibility) as described in steps 2-3 of Overview.pdf,
cd pkgs
and:JULIA_PROJECT=../Stability julia -L ../Stability/scripts/plot.jl -e 'plot_all_pkgs("/artifact/top-10-pkgs.txt")'
This should produce SVGs under
<package>/figs
for every package in the list. This of course assumespackage
contains raw data distributed with the artifact. -
Quit the sandbox,
sudo chown -R myuser .
if necessary. -
There are several ways to convert SVG to PDF. Don't use ImageMagick's
convert
-- it will rasterize. We suggestinkscape
, e.g.:#!/bin/bash find . -name "*.svg" -print0 | while read -d $'\0' f do inkscape "$f" --export-pdf="${f%.svg}.pdf" done
Then you can collect all PDFs in one dir as they have package names on them:
mkdir ../figs && find . -name "*.pdf" | xargs -I {} mv {} ../figs/
.