Skip to main content

A rocker plugin to help installing apt and pip dependencies

Project description

deps_rocker

Continuous Integration Status

Ci Codecov GitHub issues GitHub pull-requests merged GitHub release PyPI - Downloads License Python Pixi Badge Documentation Status

Installation

pip install deps-rocker

Development

Quick Development Setup

Use the provided development script to set up a development environment with both rockerc and deps_rocker:

./scripts/develop.sh

This script will:

  • Create a fresh UV virtual environment at ~/.venvs/dev-tools-uv
  • Install both rockerc and deps_rocker projects in editable mode
  • Add the virtual environment to your PATH in ~/.bashrc
  • Make console scripts from both projects available system-wide

After running the script, restart your shell or run source ~/.bashrc to activate the environment.

Manual Development Setup

Alternatively, you can manually inject deps_rocker into an existing rockerc installation:

pipx inject rockerc -e .

Usage

#recursively search for *.deps.yaml and install those packages on top of an existing image
rocker --deps ubuntu:22.04  

Motivation

Docker enables easy isolation of dependencies from the host system, but it is not easy to dynamically combine docker files from separate projects into a single unified environment.

Available Extensions

deps-rocker provides a comprehensive set of rocker extensions for development tools and environments:

Dependency Managers

  • odeps_dependencies - Recursively search for *.deps.yaml files and install packages
  • vcstool - Install and configure vcstool for multi-repository management

Package Managers

  • uv - Fast Python package installer and resolver
  • npm - Node.js package manager with nvm
  • pixi - Cross-platform package manager built on conda
  • cargo - Rust package manager and build tool

Host System Integration

  • cwd - Mount current working directory
  • cwd_name - Set container name based on directory

Development Tools

  • auto - Automatically detect and enable relevant extensions
  • ccache - C/C++ compiler cache for faster builds
  • fzf - Fuzzy finder for command line
  • gitui - Terminal git client via pixi global
  • lazygit - Simple terminal UI for git commands
  • nvim - Neovim text editor
  • palanteer - Performance profiling and debugging tool

Search Tools

  • deps-devtools - Collection of development search and analysis tools

Robotics

  • ros_jazzy - ROS 2 Jazzy Jalopy distribution
  • ros_underlay - ROS workspace overlay management
  • isaac_sim - NVIDIA Isaac Sim robotics simulator
  • urdf_viz - URDF visualization tools

AI Tools

  • claude - Claude AI assistant CLI
  • codex - OpenAI Codex code generation tool
  • gemini - Google Gemini AI CLI
  • spec_kit - AI-powered specification toolkit

Environment & Utilities

  • conda - Conda package manager and environment manager
  • jquery - JavaScript library for web development
  • curl - Command line HTTP client
  • locales - System locale configuration
  • tzdata - Timezone data configuration
  • ssh_client - SSH client tools
  • git_clone - Git repository cloning utilities
  • detach - Run containers in detached mode

Documentation

Find detailed documentation for all the rocker extensions this module provides here

Intro

This is a rocker extension for automating dependency installation. The aim is to allow a projects to define its development dependencies in a deps.yaml file which are added to the rocker container. If two projects define their dependencies in separate files, the extension will combine the common commands into the same docker layer to help reduce image size and duplication of work.

For example:

pkg a requires git, make and ffmpeg and pkg_b requires git-lfs and pip. Their deps.yaml files would look something like:

pkg_a.deps.yaml:

apt_sources:
  - git

apt_language-toolchain:
  - make
  - gcc

apt:
  - ffmpeg

pkg_b.deps.yaml

apt_sources:
  - git
  - git-lfs

apt_language-toolchain:
  - python3-pip

If you wanted a container that had the dependencies of both installed deps-rocker would combine the dependencies to produce a file like:

apt_sources:
  - git
  - git-lfs

apt_language-toolchain:
  - make
  - gcc
  - python3-pip

apt:
  - ffmpeg

Each heading in the yaml file produces a docker layer based on the command and the label. The format of the labels is {command_name}_{command-label}. The layer names are delimited by _ so layer names should use - eg: language-toolchain.

This makes it easy to define the dependencies for a single project, but enable reuse of common dependencies across multiple projects. However, deps rocker does not restrict what is defined in each layer and so relies on a common convention for multiple packages to play nicely with each other. If one package adds "make" to apt_sources and other package adds "make" to apt_langage_toolchain, the deps-rocker will not complain and will not deduplicate that install step.

Methodology:

The algorithm works by splitting each entry in the yaml file into a command and a layer. The entries from all the deps.yaml files are grouped by the command and layer into a list of entries for that command. The order of the commands is defined by the order they appear in the deps.yaml file. As long as all the files follow the same order of commands then a dependency tree of commands can be created and executed in a deterministic order. However if two files define conflicting orders deps-rocker will not be able to produce a deterministic set of commands and fail. e.g:

pkg_a.deps.yaml:

apt_sources:
  - git

apt_language-toolchain:
  - make
  - gcc

pkg_b.deps.yaml

apt_language-toolchain:
  - python3-pip

apt_sources:
  - git
  - git-lfs

pkg_a says that apt_langage-toolchain comes before apt_sources, and pkg_b says that apt_sources comes before apt_language-toolchain, which is a conflict.

The pseudocode for the deps-rocker algorithm is as follows:

dependencies_dictionary
for file in glob(*.deps.yaml):
  for entry in file.entries:
    add 

If two packages have unique layers that depend on a common layer

pkg_a.deps.yaml:

apt_sources:
  - git

apt_pkg_a_custom:
  - custom1

pkg_b.deps.yaml

apt_sources:
  - git-lfs

apt_pkg_b_custom:
  - custom1

Here apt_pkg_b_custom and apt_pkg_a_custom both need to be run after apt_sources. They will be run run in alphabetical order (to ensure determinism)

Commands

Commands are defined in templates/commandname_snippet.Dockerfile.

They use the empy templating language that is used by rocker. deps-rocker has some basic commands already implemented but adding a new command is as simple as adding a _snippet.Dockerfile.

Existing Commands:

  • apt: apt install packages
  • add-apt-repository: add repositories to apt
  • env: define environment variables
  • pip: install pip packages
  • run: RUN a docker command
  • script: run a script.
  • pyproject: look for any local pyproject.toml files and install dependencies listed there.

script:

If you have sudo inside your script deps-rocker will automatically remove them. This is so that you can run the script on the host machine where sudo is required.

Layer conventions

As mentioned above, deps-rocker does not enforce any particular layer order so the user can define them as they see fit, however to enhance interoperation of packages we define a suggested layer order. Examples of deps.yaml can be found in manifest_rocker

the template_pkg has common layers and dependencies that go in each layer as a guide to maximise reusability and caching. template_pkg

# Template package  Uncomment or modify these entries.

env_base:
  - DEPS_ROCKER=1

apt_base: #lowest level of dependency that changes very infrequently
  - build-essential

apt_io: #graphics sound, input devices etc
  - libasound2

apt_sources: #apt dependencies for setting up software sources
  - ca-certificates #needed for wget
  - wget
  - curl
  - lsb-release
  - gnupg2
  - git
  - git-lfs

script_sources: #scripts for adding repositories or repo keys
  - sources.sh

apt_language-toolchain: #packages related to setting up languages e.g. c++,python,rust etc
  - python3-pip
  - make
  - gcc

pip_language-toolchain: #install basic development tools which almost never change
  - pip #this updates pip to latest version
  - flit
  - pytest
  - ruff

apt_tools: #any other development tools
  - colcon

apt: #the main dependencies of the package
  - fsearch

pyproject: #Scan for all pyproject.tomls and install
  - all

script_build: #any build steps
  - build.sh

script_lint: 
  - lint.sh

script_test:
  - test.sh


## limitations/TODO

This has only been tested on the ubuntu base image. It assumes you have access to apt-get.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deps_rocker-0.23.2.tar.gz (60.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deps_rocker-0.23.2-py3-none-any.whl (108.7 kB view details)

Uploaded Python 3

File details

Details for the file deps_rocker-0.23.2.tar.gz.

File metadata

  • Download URL: deps_rocker-0.23.2.tar.gz
  • Upload date:
  • Size: 60.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for deps_rocker-0.23.2.tar.gz
Algorithm Hash digest
SHA256 b1d519a201f2f5710aa8a87cc73caaa0e47fff8c8b61b2a349c98c188452012e
MD5 3ac8cc97191fa21c188e5cfbc7d7362e
BLAKE2b-256 b064ba6700ba6dfc001d17baabcf67c1a202730eb26f2122e7ef5996d10c5898

See more details on using hashes here.

File details

Details for the file deps_rocker-0.23.2-py3-none-any.whl.

File metadata

  • Download URL: deps_rocker-0.23.2-py3-none-any.whl
  • Upload date:
  • Size: 108.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for deps_rocker-0.23.2-py3-none-any.whl
Algorithm Hash digest
SHA256 baf688e0d4ab60452813fa100addeb74381b0b6d7cb99d8afe3778b7e841f7d8
MD5 a686c744b3d6941d929234f667b78f0e
BLAKE2b-256 cbb6788b0ce03bb93ed07d91fd532f1114fd4ef52b692a1bf7a878e56ed88358

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page