Package Dependencies
This page was machine-translated. The Japanese page is the official version.
Use dependencies.json to add packages that an application depends on. When you run actdk build, ActDK reads this file and builds an application image with the required dependencies installed.
{
"apt": ["package1", "package2"],
"pip": ["package1", "package2"]
}For example, a sample application specifies dependencies as follows:
{
"apt": [
"libv4l-0",
"libv4lconvert0",
"python3-pil",
"python3-numpy",
"fonts-dejavu-core"
],
"pip": ["actfw-raspberrypi"]
}By default, packages are installed on the Docker image idein/actcast-rpi-app-base:bullseye-3 or idein/actcast-rpi-app-base:bookworm-9, depending on the target type.
apt packages
In the apt section, specify the names of packages to install with apt.
{
"apt": ["libv4l-0", "libv4lconvert0"]
}These packages are installed with apt-get when you run actdk build. By default, ActDK uses the apt repositories configured in the base image for each target type.
pip packages
In the pip section, specify the names of Python dependencies to install with pip.
{
"pip": ["actfw-raspberrypi"]
}These packages are installed with pip install when you run actdk build. By default, ActDK uses the Python 3 environment included in the base image for each target type.
Custom images
Use the custom image feature to add packages or files that cannot be installed with the standard method described above.
Specify a Docker image in the base_image section under a target type in dependencies.json. The target type must be one of the keys listed in target_types in .actdk/setting.json.
{
"apt": ["..."],
"pip": ["..."],
"raspberrypi-bookworm": {
"base_image": "<repo>:<tag>"
}
}Important
The Docker image must be accessible with docker pull both from the machine running the actdk command and from the target device.
Packages specified in the apt section are installed using the configuration in the base image specified here.
Example: Install ffmpeg
For example, to install a newer version of FFmpeg than the one available through apt, use a Dockerfile to download and install it:
FROM idein/actcast-rpi-app-base:bookworm-9
RUN apt-get update \
&& apt-get install -y wget xz-utils \
&& apt-get clean \
&& apt-get autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
RUN wget https://johnvansickle.com/ffmpeg/old-releases/ffmpeg-6.0-arm64-static.tar.xz \
&& tar -Jxvf ffmpeg-6.0-arm64-static.tar.xz \
&& mv ffmpeg-6.0-arm64-static/ffmpeg /usr/local/bin/ \
&& rm -rf ffmpeg-6.0-arm64-static.tar.xz ffmpeg-6.0-arm64-staticIf you build a Docker image from this Dockerfile and tag it my-org/my-base-image:ffmpeg-6.0, specify it in dependencies.json as follows:
{
"apt": ["..."],
"pip": ["..."],
"raspberrypi-bookworm": {
"base_image": "my-org/my-base-image:ffmpeg-6.0"
}
}Note
Replace the image name with the one you use.
The application can then use a custom image that includes the newer version of FFmpeg.
pyproject.toml integration
If a pyproject.toml file exists in the application project root, its dependencies are automatically merged with the pip section of dependencies.json.
In the following example, the application can use actfw-core.
Example
# pyproject.toml
dependencies = ["actfw-core"]{
"apt": [],
"pip": []
}When dependencies are merged, packages listed in pyproject.toml always have the lowest priority. Therefore, in the following example, version 1.0 of lib-a is used.
Example: A package in pyproject.toml is overridden
# pyproject.toml
dependencies = ["lib-a==2.0"]{
"apt": [],
"pip": ["lib-a==1.0"]
}