Macros
ShareAdd.@usingany
— Macro@usingany pkg
@usingany pkg1, pkg2, ...
Makes package(s) available, if they are not already, and loads them with using
keyword.
- If a package is available in an environment in
LOAD_PATH
, that's OK. - If a package is available in a shared environment, this environment will be pushed into
LOAD_PATH
. - Otherwise if it can be installed, you will be prompted to select an environment to install the package(s).
- If the package is not listed in any registry, an error will be thrown.
This macro is exported.
Functions
Exported functions
ShareAdd.delete_shared_env
— Methoddelete_shared_env(env::Union{AbstractString, EnvInfo})
Deletes the shared environment env
by erasing it's directory.
Returns nothing
.
ShareAdd.delete_shared_pkg
— Methoddelete_shared_pkg(pkg::AbstractString)
Deletes the package pkg
from it's shared environment. Deletes this environment if it was the only package there. If the package is present in multiple environments, it will not be deleted and an error will be thrown, suggesting you do it manually.
Returns nothing
.
ShareAdd.list_shared_envs
— Methodlist_shared_envs() -> Vector{String}
Returns the names of all shared environments.
ShareAdd.list_shared_pkgs
— Methodlist_shared_pkgs(; all=false) -> Vector{String}
Returns the names of packages in all shared environments. If all=true
, also includes packages in @stdlib.
ShareAdd.make_importable
— Methodmake_importable(packages) -> :success | nothing
ShareAdd.reset_loadpath!
— Methodreset_loadpath!()
Resets the LOAD_PATH to the default values: removes any manually added paths, and resets the load path to the standard values of ["@", "@v#.#", "@stdlib"].
ShareAdd.sh_add
— Methodsh_add(env_name::AbstractString; depot = first(DEPOT_PATH)) -> Vector{String}
sh_add(env_names::AbstractVector{<:AbstractString}; depot = first(DEPOT_PATH)) -> Vector{String}
sh_add(env_name::AbstractString, ARGS...; depot = first(DEPOT_PATH)) -> Vector{String}
Adds shared environment(s) to LOAD_PATH
, making the corresponding packages all available in the current session.
Returns the list of all packages in the added environments as a Vector{String}
.
Examples
julia> sh_add("@StatPackages")
3-element Vector{String}:
"Arrow"
"CSV"
"DataFrames"
julia> sh_add(["@StatPackages", "@Makie"])
4-element Vector{String}:
"Arrow"
"CSV"
"DataFrames"
"Makie"
julia> sh_add("@StatPackages", "@Makie")
4-element Vector{String}:
"Arrow"
"CSV"
"DataFrames"
"Makie"
ShareAdd.update_shared
— Functionupdate_shared()
update_shared(nm::AbstractString)
update_shared(nm::Vector{AbstractString})
update_shared(env::AbstractString, pkgs::Union{AbstractString, Vector{AbstractString}})
update_shared(env::EnvInfo, pkgs::Union{Nothing, S, Vector{S}} = Nothing) where S <: AbstractString
- Called with no arguments, updates all shared environments.
- Called with a single argument
nm::String
starting with "@", updates the environmentnm
(if it exists). - Called with a single argument
nm::String
not starting with "@", updates the packagenm
in all shared environments. - Called with a single argument
nm::Vector{String}
, updates the packages and/or environments innm
. - Called with two arguments
env
andpkgs
, updates the package(s)pkgs
in the environmentenv
.
Returnes nothing
.
Public functions
ShareAdd.check_packages
— Methodcheck_packages(packages; depot = first(DEPOT_PATH)) -> NamedTuple
checks whether packages are available in the current environment, shared environments, or are installable.
Returns a NamedTuple with the following fields:
inpath_pkgs
: packages that are already present in some environment inLOAD_PATH
inshared_pkgs
: packages that are available in some shared environmentsinstallable_pkgs
: available packagesunavailable_pkgs
: packages that are not available from any registryshared_pkgs
: Dictionary of packages in shared environmentscurrent_pr
: information about the current environment as@NamedTuple{name::String, shared::Bool}
ShareAdd.current_env
— Methodcurrent_env(; depot = first(DEPOT_PATH)) -> EnvInfo
Returns information about the current active environment as an EnvInfo
object.
ShareAdd.env_path
— Functionenv_path(env_name::AbstractString, depot = first(DEPOT_PATH); skipfirstchar = true) -> String
Returns the path of the environment with name env_name
. If skipfirstchar
is true
, the first character of env_name
is skipped, so that the name of a shared environment can be passed without the leading @
.
ShareAdd.list_shared_packages
— Methodlist_shared_packages(;depot = first(DEPOT_PATH)) -> Dict{String, PackageInfo}
ShareAdd.shared_environments_envinfos
— Methodshared_environments_envinfos(; depot = first(DEPOT_PATH)) ->
(; shared_envs::Vector{EnvInfo},
envs_folder_path::String,
shared_env_names::Vector{String})
Internal functions
ShareAdd.optim_set
— Methodoptim_set(pks::AbstractArray{<:AbstractString}, envs::AbstractVector{EnvInfo}) -> OptimSet
optim_set(pkgs::AbstractArray{PackageInfo}) -> OptimSet
Finds the optimum set of environments for the given list of packages. Optimal is a set of environments with the least number of extraneous packages. If two sets have the same number of extraneous packages, then the one with the least number of environments is chosen.
The function is internal.
Types
All types are declared as public
ShareAdd.EnvInfo
— Typemutable struct EnvInfo
name::String
- name of the environmentpath::String
- path of the environment's folderpkgs::Vector{String}
- list of packages in the environmentin_path::Bool
- whether the environment is inLOAD_PATH
ShareAdd.EnvSet
— Typestruct EnvSet
envs::Set{String}
- set of environment namesextraneous_pks::Set{String}
- (internally used, seeoptim_set
function for details)extra_lng::Int
- as aboveno_of_sets::Int
- as above
ShareAdd.OptimSet
— Typemutable struct OptimSet
best_set::EnvSet
- the best set of environments currently found - seeoptim_set
function for details.
ShareAdd.PackageInfo
— Typemutable struct PackageInfo
name::String
- name of the packageenvs::Vector{EnvInfo}
- list of environments in which the package is presentin_path::Bool
- whether any of the environments is inLOAD_PATH
Index
ShareAdd.EnvInfo
ShareAdd.EnvSet
ShareAdd.OptimSet
ShareAdd.PackageInfo
ShareAdd.check_packages
ShareAdd.current_env
ShareAdd.delete_shared_env
ShareAdd.delete_shared_pkg
ShareAdd.env_path
ShareAdd.list_shared_envs
ShareAdd.list_shared_packages
ShareAdd.list_shared_pkgs
ShareAdd.make_importable
ShareAdd.optim_set
ShareAdd.reset_loadpath!
ShareAdd.sh_add
ShareAdd.shared_environments_envinfos
ShareAdd.update_shared
ShareAdd.@usingany