Package: depmanager
DepManagerDepmanager is a minimalistic tool to manage dependencies (also known as third-party
libraries) of a C++ Project. It works closely with cmake tool.It allow to store dependencies in a distant repository to share builds with other and
have a local cache project-independent.InstallationDepmanager is written in python so in the following we assume you have a
working python installation designated as<python>withpipinstalled.pipTo install dep manager simply use<python> -m pip  install depmanagerSee the page on Pypi:depmanager.From sourcePrerequisite: python module 'build' install it with<python> -m pip install buildClone the gitHub repository.In the source root do:<python>-mbuild<python>-mpipinstalldist/depmanager-x.y.z-py3-none-any.whlCommandline useGet helpFor any command or sub-command adding--helpor-hto get help
on parameters or usage.GeneralitiesIn the base commande you can find:commandsubcommandsdescriptioninfobasedir, cmakedir, versioninfo on local instancegetGet the config packagepackpull, push, add, del, queryManage packagesremotelist, add, del, infoManage the list of distant serversbuildBuild a new packageIn the following,<query>designate something representing the dependency's description.
The syntax reads:--predicate(-p) <name>:<version> --type(-t) <type> --os(-o) <os> --arch(-a) <arch> --compiler(-c) <compiler> --glibc <glibc>Valid values fortype:shared,static,header.Valid values foros:Windows,Linux(default: host os)Valid values forarch:x86_64,aarch64(default: host arch)Valid values forcompiler:gnu,msvc(default:gnu)
Note: clang compiler stands forgnuwhile clang-cl stands formsvc.Valid values forglibcare only needed for linux. By giving, a value the system will look at
package with compatible version will be search (ie. wit a version number lower or equal).
It is still possible to do an exact search by using=as first character. (like--glibc =2.36)Also, we will designate<remote>as a description a remote server, syntax reads:[-n <name>|-d].
If nothing given, we assume 'local'. If-dgiven, use the default remote, else use the remote by
its name.If the name does not exist, it will fall back to default then to local.Base commandsinfoSubcommands:versiongives the version of the local manager.basedirgives the path to the local data of the managercmakedirgives the path to add toCMAKE_MODULE_PATHbefore includeExternalDependencyManagergetdepmanager get <query>Get path to cmake config of the 'best' package given by the query information.The command will first search in the local cache, if not found it will search in the default remote. This does not
intent for human use but more for
cmake integration.packActions on packages.querydepmanager pack query <query> [--transitive(-t)] <remote>Simply do a search in the given remote (in local if
nothing given) and print the result.The--transitive(-t)flag will allow to use transitive query, meaning to search for local then remote.add, deldepmanager pack add <location>Will add a package to the local database.<location>can be a
folder, then it must contain a properly formattededp.infofile. Or an archive (.zip, .tgz or .tar.gz
file format allowed). The uncompressed archive must contain a properly formattededp.infofile.depmanager pack del <query> <remote> [-r]Will remove from local cache all package matching the query.The-roption allows operation on multiple packages (local only), else the command will return an error if multiple
package matches the query.push, pulldepmanager pack [push|pull] <query> <remote> [--force(-f)] [-r]will synchronize Local cache with the remote.
Thequerymust be precise enough to match one and only one package.remotemust be valid.pushwill look for the package in local cache that match the query and send it to the given remote.pullwill look for the package in given remote that match the query and bring it to the local cache.If--forceis given, The transfert occurs even if the package already exists in the destination.The-roption allows operation on multiple packages. If multiple versions, only the highest one will be used.cleandepmanager pack clean [--full(-f)]Will clean the local repository by removing old packages, only the newest
version of each package is kept.The[--full(-f)]option will make the clean operation applies to all package, thus emptying the local database.remoteManage the list of remote servers
subcommands:listlists the defined remote server.addadds a new remote to the list.--name(-n) <name> --url(-u) <proto>://<url[:port]> [--default(-d)].Mandatory. If name already exists it will modify the existing one.Allowed proto are:ftpsupports loginfoldera folder of your computer (mostly for debug or testing)srva dedicated server seegitHubsrvsa dedicated server with secure connexion seegitHubLogin can be defined with:--login(-l) <login> --passwd(-p) <passwd>.del <remote>remove the designated remote if exists.sync <remote> [--push-only|--pull-only] [--dry-run]push to remote all local package that does not already
exist on remote. Pull local package that have a newer version on the remote. If no remote given, it will use the
default one.info <remote>gets information from the remote: type and version.builddepmanager build [OPTIONS] <location>will search for recipe in the given location and build them.Some option can be passed to the build system:--single-thread: on some low-end devices (such as RaspberryPi) single thread build is recommended.--force,-f: Force the build even if the dependency already exists--cross-c: redefine the C compiler--cross-cxx: redefine the C++ compiler--cross-arch: redefine the architecture--cross-os: redefine the OSUsing package with cmakeInclude depmanager to cmakeTo initialize depmanager into cmake you need to add toCMAKE_MODULE_PATHthe path
to the cmake folder of this installation.Here is a small cmake code snippet to initialize depmanager in cmake.# add HINTS or PATH to find the executable if not in the PATHfind_program(EDEPMANAGERdepmanager)if(${EDEPMANAGER}STREQUALEDEPMANAGER-NOTFOUND)message(FATAL_ERROR"Dependency manager not found.")else()execute_process(COMMAND${EDEPMANAGER}infocmakedirOUTPUT_VARIABLEdepmanager_path)string(STRIP${depmanager_path}depmanager_path)list(PREPENDCMAKE_MODULE_PATH${depmanager_path})include(DepManager)endif()Automated modeIn automated mode, depmanager can automatically set a remote repository, retrieve packages from this repository
and load then in one command.The commanddm_load_environment([QUIET][PATHpath][KINDkind][ARCHtarget_arch][OStarget_os][COMPILERtarget_compiler][GLIBCtarget_glibc])IfQUIETset, only errors are written.pathis the path to the configuration file, either directly a configuration file name,
or a directory containing a file nameddepmanager.yml. By default, it will look at the
project root. See the next paragraph for more information about configuration file.kindis used to force library kind (shared,static,header). By default, it uses
the value fromBUILD_SHARED_LIBS.target_arch,target_os,target_compiler,target_glibcare used in the query. If not set, default
values areCMAKE_SYSTEM_PROCESSOR,CMAKE_SYSTEM_NAMEandCMAKE_CXX_COMPILER_IDThe cmake function will update the CMAKE variable for the search of package.After call this command, the cmake user has to call for neededfind_package.Configuration fileThe configuration file is a yaml file. Here is an example with explication in comment.remote:# If server is defined, depmanager will add this server to its# database (if not already there)server:# Same parameter as command-line (also the required)name:"my_server"kind:"srvs"url:"https://packages.example.net"login:"foo"passwd:"bar"# If package not found locally, do you allow for download?pull:true# If newer remote package exists, download it? (implies 'pull')pull-newer:truepackages:# list the needed packages.fmt:# version 'at least'version:">=10.1.0"spdlog:# exact versionversion:"1.12.0"debugbreak:# if not found locally, don't pull, nor error.optional:trueglm:version:"0.9.9.9"# force the shared version even in static build mode.kind:"shared"glfw:# use this only for the (same for arch, and compiler)os:LinuxManual modeIn manual mode you should load or find each package individually.
You should also manually set the remote and download the package.Find packagesWith depmanager initialized in cmake, it provides an alternative to classicalfind_packageof cmake bydm_find_packagedm_find_package(package[QUIET][TRACE][REQUIRED][VERSIONversion][KINDkind][ARCHtarget_arch][OStarget_os][COMPILERtarget_compiler][GLIBCtarget_glibc])packageis the package name to find.versionis the exact version to match (wildcard are allowed). By default, find the
latest one.kindis used to force library kind (shared,static,header). By default, it returns
the first found.IfREQUIREDset, the function will give an error if no package found.
(same as originalfind_package)IfQUIETset, only errors are written. (same as originalfind_package). In opposition,
ifTRACEset, many more debug message displayed.target_arch,target_os,target_compilertarget_glibcare used in the query. If not set, default
values areCMAKE_SYSTEM_PROCESSOR,CMAKE_SYSTEM_NAMEandCMAKE_CXX_COMPILER_IDLIMITATION:it requires the library name is the package name. So no multi lib or lib with different name.Load packageThis command is similar to the previous one, but does not directly do a cmake'sfind_package.
It only adds to theCMAKE_PREFIX_PATHlist the folders of given package.dm_load_package(package[REQUIRED][TRACE][VERSIONversion][KINDkind][ARCHtarget_arch][OStarget_os][COMPILERtarget_compiler][GLIBCtarget_glibc])After call this command, the cmake user has to call for neededfind_package.Create you own packageDepmanager allow you to create your own packages by defining recipes. Then rundepmanager build <location of recipes> [OPTIONS]The program will then build and add dependencies to the local cache.The location can contain as many recipe in any number of files.The search behavior can bve set as recursive with option--recursive,-r. As sometimes, sources also contains python
files that may fail to load, the depth of recursion can be restrained using--recursi-depth <n>.By default, a package will not be build if already exists in the local cache. You can force the rebuild with the
option--force,-f.By default, the builder will use all the cpu cores, but--single-thred,-swill force to use only one core.Cross-compilation can be used by giving the tools at command
line:--cross-c <C_COMPILER> --cross-cxx <CXX_COMPILER> --cross-arch <TARGET_ARCH> --cross-os <TARGET_OS>It is also possible to give a remote name-n <remote_name>or set to default remote-d. This way,
The builder will look into remote to see if an package already exists and pull it instead of building it.
Also, after a successful build, it will automatically push to the remote. Use either--no-pulland--no-pushoption to skip these steps.A--dry-runoption will do all the checks and print the results but no pull, build and push action will be done.The recipeDuring build, Depmanager will look in all.pyfile for class that inherits from
depmanager.api.recipe.Recipe.As for dependency usage, build also rely on cmake for building.The builder will use the provided recipe in the following workflow:Init recipeCallrecipe.source()Callrecipe.configure()Initialize options based on recipe dataRun cmake configureFor all configuration (mostly 'Debug', 'Release')build targetinstallCallrecipe.install()Generate edp.info fileImport into local cacheCallrecipe.clean()Clean TemporaryHere is a small example"""Small recipe example"""fromdepmanager.api.recipeimportRecipeclassMyAwesomeLib(Recipe):"""Awesome lib"""name="awesome_lib"# lib nameversion="0.0.1.foo"# lib versionsource_dir="src"# where to fine the sources (especially) the CmakeList.txtkind="static"# the lib's kindclassAnotherAwesomeLib(MyAwesomeLib):"""Shared version of previous one"""kind="shared"As many python file may exist in the source you want to build, python file using shebang will be ignored to avoid errors
when parsing them. Do not add shebang in your recipe files.RoadmapFirst of all in the roadmap is to use this tool in C++ project to get feedback.Among things:version 0.7.xCreation of a frontend application.Can view, edit, suppress local package.Can add, remove, explore remotes.Can push, pull packages.version 0.6.xAdd recipe librayPossibility to store the recipes in remoteAuto build recipe if neither local nor remote found.version 0.5.xAdd a sorting order for remotes.Searching across remotes with final package sorting.Allow auto-pull best-fitting packageversion 0.4.xAdd concept of toolset.Tool set defines arch, os and compilers; stored in config.ini; with a default one.Use toolset in build.Use toolset in queries.More detail documentation.Documentation hosted in instance ofDepmanager Server.version 0.3.3 -- 2024-01-27Improved Builder Configurations managementOperation on multiple packageadd a 'clean' commandbasic mode: keep only the newest packagesfull mode: delete everything.allow local deletion of multiple packagesallow push/pull of multiple packagesversion 0.3.2 -- 2024-01-19Better management of push in auto-buildBugfixes in the use of CMakemanage dependency in the list of Recipesversion 0.3.1 -- 2024-01-16Allow to externally control the build systemAllow to build a package by giving a single recipeAllow to pull packages prior to build if exists on a remoteAllow to push (force) to remote after buildHelper functions to find recipes in filesystemAllow recursive searchversion 0.3.0 -- 2024-01-12CMake integration improvementSimplify integration with cmakePython auto generate the Module dir for cmakeAllow to load package by batchuse Yaml config file.version 0.2.1 -- 2023-12-31Bufix: allow more date format and don't break if bad format.version 0.2.0 -- 2023-12-12WARNING: Some breaking change. Backward compatibility not fully tested.Faster commandlineUse remote connexion only if neededTransitive searchQuery: search in local then remote.get: Auto-pull if not in local.Add new remote command.Get info from remote (type and version)Allow to delete package on remote.Better Package propertiesAdd build Date in package properties.Add build glibc version in package properties if applicable.Better queries on glibc compatible systemUse system's glibc in get searchesversion 0.1.4 -- 2023-06-21Allow to sync with remote.Allow to pull local package that have newer version.Allow to push local package newer than remote or not existing in remote.Allow to force push/pull.Bugfix: safe deleteversion 0.1.3 -- 2023-06-12Update internal statuses when using API.omit -d in push/pull command.add progress bar in push/pull command.Allow single thread in build.version 0.1.2 -- 2023-05-31Add possibility to force os, arch and compiler for cross compiling.Adapt build system to search dependency in the forced environment.version 0.1.1Add remote 'srv' Type: a dedicated dependency server.Add remote 'srvs' Type: a dedicated dependency server with secure connexion.