Macros

ShareAdd.@usinganyMacro
@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.

source

Functions

Exported functions

ShareAdd.delete_shared_envMethod
delete_shared_env(env::Union{AbstractString, EnvInfo})

Deletes the shared environment env by erasing it's directory.

Returns nothing.

source
ShareAdd.delete_shared_pkgMethod
delete_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.

source
ShareAdd.list_shared_pkgsMethod
list_shared_pkgs(; all=false) -> Vector{String}

Returns the names of packages in all shared environments. If all=true, also includes packages in @stdlib.

source
ShareAdd.reset_loadpath!Method
reset_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"].

source
ShareAdd.sh_addMethod
sh_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"
source
ShareAdd.update_sharedFunction
update_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 environment nm (if it exists).
  • Called with a single argument nm::String not starting with "@", updates the package nm in all shared environments.
  • Called with a single argument nm::Vector{String}, updates the packages and/or environments in nm.
  • Called with two arguments env and pkgs, updates the package(s) pkgs in the environment env.

Returnes nothing.

source

Public functions

ShareAdd.check_packagesMethod
check_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 in LOAD_PATH
  • inshared_pkgs: packages that are available in some shared environments
  • installable_pkgs: available packages
  • unavailable_pkgs: packages that are not available from any registry
  • shared_pkgs: Dictionary of packages in shared environments
  • current_pr: information about the current environment as @NamedTuple{name::String, shared::Bool}
source
ShareAdd.current_envMethod
current_env(; depot = first(DEPOT_PATH)) -> EnvInfo

Returns information about the current active environment as an EnvInfo object.

source
ShareAdd.env_pathFunction
env_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 @.

source

Internal functions

ShareAdd.optim_setMethod
optim_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.

source

Types

All types are declared as public

ShareAdd.EnvInfoType
mutable struct EnvInfo
  • name::String - name of the environment
  • path::String - path of the environment's folder
  • pkgs::Vector{String} - list of packages in the environment
  • in_path::Bool - whether the environment is in LOAD_PATH
source
ShareAdd.EnvSetType
struct EnvSet
  • envs::Set{String} - set of environment names
  • extraneous_pks::Set{String} - (internally used, see optim_set function for details)
  • extra_lng::Int - as above
  • no_of_sets::Int - as above
source
ShareAdd.PackageInfoType
mutable struct PackageInfo
  • name::String - name of the package
  • envs::Vector{EnvInfo} - list of environments in which the package is present
  • in_path::Bool - whether any of the environments is in LOAD_PATH
source

Index