blue-build / modules

BlueBuild standard modules used for building your Atomic Images
Apache License 2.0
22 stars 26 forks source link

Correct way to add python packages in post-install #216

Closed mecattaf closed 1 month ago

mecattaf commented 2 months ago

Hey team,

I am trying to add some python packages to my image, but doing so from post-install.sh does not seem to work for me:

#!/usr/bin/env bash
set -oue pipefail
pip install emoji-fzf

Thoughts on how to fix? Do we need a module for this where user specifies all their requested pip packages? Will face the same problem for cargo (rust) packages in the future.

Looking fwd to your feedback!

xynydev commented 2 months ago

I found your repo, post-install.sh seems to be a build script. Your build logs say:

#45 1.319 Installing collected packages: emoji-fzf
#45 1.368 Successfully installed emoji-fzf-0.9.0
#45 1.368 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

It seems that you're doing things correctly, and it is working. Or is the package not found after updating and rebooting your computer?

I went and checked how we do a pip install in the yafti module: pip install --prefix=/usr yafti. Maybe setting --prefix=/usr/lib/python3.12/site-packages/ would help with the root user issue?

If installing pip packages at build-time does not end up being viable, this could be fixed with https://github.com/blue-build/modules/issues/119.

mecattaf commented 1 month ago

Setting --prefix=/usr/lib/python3.12/site-packages/ did not solve the root user issue. For now I run the pip install manually after setup.