Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Python virtual environment #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gronke
Copy link
Contributor

@gronke gronke commented Jul 25, 2024

A previous Pull-Request #8 has added the --break-system-packages flag to the pip command. In response Python system packages, which are also installed via Docker, will break on update.

This PR installs the system package python-venv and configures a virtual environment in /opt/venv/.

@gronke gronke requested a review from a team as a code owner July 25, 2024 15:29
@gronke gronke force-pushed the chore/python-venv branch from 55ffc41 to 94f9185 Compare July 25, 2024 17:55
@PeterMosmans
Copy link

What's the added value of using a virtual environment here for an immutable image (that gets hopefully built / updated quite often)?

@gronke
Copy link
Contributor Author

gronke commented Jul 30, 2024

What's the added value of using a virtual environment here for an immutable image (that gets hopefully built / updated quite often)?

Since Python PIP version 23.0.1 (2023-02-17) it requires the --break-system-packages flag when installing packages without virtual environment.

This repo mixes system packages (installed from Debian apt) and Python PIP, which may conflict. One obvious way to resolve this issue is adding the --break-system-packages, though it comes with a catch: It breaks when system packets are updated at a later time. And actually we do want to be able to do that.

This PR opts for the virtual environment instead, which fixes the issue in both cases.

@PeterMosmans
Copy link

PeterMosmans commented Jul 30, 2024

Thanks for the explanation @gronke - however, what's against doing something like

RUN apt-get install -y python3 python3-pip python3-tz pandoc python3-pypandoc python3-gitlab python3-slugify

where all packages are system packages?

@gronke
Copy link
Contributor Author

gronke commented Sep 27, 2024

Would you please create a PR and close this one in case you prefer the other solution? One way or the other, builds are currently broken. I don't mind either solution.

@PeterMosmans
Copy link

It was just a question as I was curious for the reason of using venv instead of system packages - all good from my side this solution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants