Working with EngeePkg
Use the EngeePkg package to clearly separate user and system packages and for advanced package handling functionality in your project.
EngeePkg is an add-on to the Pkg package manager, implemented as a standalone package for better control over loaded modules and packages.
EngeePkg has the following advantages over Pkg:
-
EngeePkg distinguishes between system and user packages, distinguishing among system packages those included in the system image. By default, the
EngeePkg.status
function outputs all information from LOAD_PATH. Classic Pkg with thePkg.status
function does not have this functionality and outputs information about packages from only one project (by default, the active project). Moreover,EngeePkg.status
, unlikePkg.status
, can provide information about loaded modules. -
EngeePkg cleans up the entire user project by removing all installed packages with the
EngeePkg.purge
function without explicitly listing them. Classic Pkg purges the project with thePkg.rm
function, but requires explicit enumeration of all packages.
To work with EngeePkg, add it to the current environment (project):
Pkg.add("EngeePkg")
Import EngeePkg into the workspace (command line or script editor):
using EngeePkg
Refer to Help on the command line (use the question mark ? to switch to help?
mode) to output the available EngeePkg commands:
ALL_MODULES CLI INIT_MODULES INSTALLED_MODULES
LOADED_MODULES PKGMODE_MANIFEST PKGMODE_PROJECT PKGSORT_BY_NAME
PKGSORT_BY_SRCPATH PKGSORT_BY_UUID PKGSORT_NONE PkgUtils
SYSTEM_MODULES Status USER_MODULES eval
include purge select_packages status
Next, let’s look at the EngeePkg.status
and EngeePkg.purge
functions with specific examples.
Function EngeePkg.status
.
The EngeePkg.status
function displays the status of installed packages and/or downloaded modules. Unlike Pkg.status
, EngeePkg.status
can display information about loaded modules, distinguish between system and user packages, and determine which packages are included in the system image.
The EngeePkg.status
function signature:
EngeePkg.status(modules::Union{String, UUID, Module, ModuleSelection};
mode::PackageMode, sort::PkgSortOrder, outdated::Bool, io::IO)
The optional first argument modules
specifies a selection of packages/modules. This can be the name or UUID of one particular package, or one module as such, or a constant specifying multiple packages/modules:
-
USER_MODULES
- installed from user packages. -
SYSTEM_MODULES
- installed from system packages. -
INSTALLED_MODULES
- installed in all projects (lists packages from all LOAD_PATH items). -
LOADED_MODULES
- loaded into memory (including those not installed). -
INIT_MODULES
- loaded into memory from the system image. -
ALL_MODULES
(by default) - all installed and loaded (lists packages from all LOAD_PATH items).
The io
argument specifies the terminal for output (by default
stdout
).
The sort
argument specifies the order of enumeration:
-
PKGSORT_BY_NAME
- sort by packet names; -
PKGSORT_BY_SRCPATH
- sort by location of source files of installed packages; -
PKGSORT_BY_UUID
- sort by package UUID; -
PKGSORT_NONE
(by default) - no sorting.
The mode
argument specifies the sampling mode of installed packages:
-
PKGMODE_PROJECT
- by project file (Project.toml); -
PKGMODE_MANIFEST
- by manifest file (Manifest.toml).
When sampling only installed packages (USER_MODULES
, SYSTEM_MODULES
, INSTALLED_MODULES
), by default the file containing data on direct project dependencies (Project.toml) is used. When selecting loaded (LOADED_MODULES
, INIT_MODULES
, ALL_MODULES
), as well as when selecting by name and UUID, the file describing the project data structure is used by default (Manifest.toml).
The output uses the same format as Pkg.status
. When selecting packages from multiple projects, the icons ①, ②, etc. are used to distinguish between them. The ▣ icon marks packages that have been downloaded. For example:
Status ① `/user/.project/Manifest.toml`
② `/usr/local/julia-1.9.3/environments/v1.9/Manifest.toml`
⌅ [39de3d68] AxisArrays v0.4.6 ② ▣
⌅ [98e50ef6] JuliaFormatter v1.0.20 ② ▣
[2aef5ad7] QueryOperators v0.9.3 ②
⌅ [48965c70] MatrixPencils v1.7.5 ② ▣
⌃ [69666777] Arrow v2.4.3 ②
[49dc2e85] Calculus v0.5.1 ② ▣
[efcefdf7] PCRE2_jll v10.42.0+0 ② ▣
⌅ [d8a4904e] MutableArithmetics v1.1.0 ② ▣
⌅ [aacddb02] JpegTurbo_jll v2.1.91+0 ② ▣
The Pkg.status
function of the Pkg package manager can only output package information from one project (by default, the active project). For example:
Status `/user/.project/Project.toml`
[e36ba207] EngeePkg v0.0.7
[4d00f742] GeometryTypes v0.8.5
⌅ [23fbe1c1] Latexify v0.15.18
The EngeePkg.status
function is joined by EngeePkg.select_packages
. While status
prints information in human-readable form, select_packages
returns the same information as a data object that can be manipulated programmatically.
The select_packages
function signature:
EngeePkg.select_packages(modules::Union{String, UUID, Module, ModuleSelection},
mode::PackageMode)
The select_packages
function gets a sample of installed packages and/or downloaded modules as an array of package descriptions. The modules
and mode
arguments have the same meaning as in EngeePkg.status
.
EngeePkg.purge function
The purge
function removes all packages installed in a given environment (by default in a user project):
EngeePkg.purge()
Command execution output
Updating `/user/.project/Project.toml` #удаление пакетов из Project.toml (пользовательские)
[c3fe647b] - AbstractAlgebra v0.27.8
[7d9f7c33] - Accessors v0.1.27
[79e6a3ab] - Adapt v3.5.0
[e36ba207] - EngeePkg v0.0.7
[cd3eb016] - HTTP v1.5.4
...
[91a5bcdd] - Plots v1.36.1
[c3e4b0f8] - Pluto v0.19.40
[438e738f] - PyCall v1.94.1
[d330b81b] - PyPlot v2.11.2
[3646fa90] - ScikitLearn v0.7.0
[6a2ea274] - Torch v0.1.0
Updating `/user/.project/Manifest.toml` ##удаление пакетов из Manifest.toml (системные)
[c3fe647b] - AbstractAlgebra v0.27.8
[7d9f7c33] - Accessors v0.1.27
[79e6a3ab] - Adapt v3.5.0
[b99e7846] - BinaryProvider v0.5.10
[d1d4a3ce] - BitFlags v0.1.7
...
[d360d2e6] - ChainRulesCore v1.15.7
[944b1d66] - CodecZlib v0.7.1
[19ecbf4d] - Codecs v0.5.0
[35d6a980] - ColorSchemes v3.20.0
[3da002f7] - ColorTypes v0.11.4
This function is used to completely clean up a user project. The Pkg package manager does not support this functionality - the Pkg.rm
function is available, for which only an explicit listing of all packages is available.