-
Notifications
You must be signed in to change notification settings - Fork 19
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
Adding Python venv #78
Conversation
Needed after update to ubuntu 24.04 Signed-off-by: Erik Jaegervall <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
=======================================
Coverage 50.44% 50.44%
=======================================
Files 31 31
Lines 11702 11702
=======================================
Hits 5903 5903
Misses 5799 5799 ☔ View full report in Codecov by Sentry. |
- uses: actions/setup-python@v5 | ||
# Needed for pip | ||
with: | ||
python-version: '3.12' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really using a pip virtual environment? It looks like the problem is fixed, by installing a separate python installation which prevents the system python installation from being polluted - which might be a workable solution.
That the fix works is obvious. Just want to have a common understanding here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess you are right - as I understand it installs Python and adds it to path. It does not in itself initiate/activate a virtual environment. Setup-python has however some support for caching so in one way I think it may reuse certain parts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some other repos like https://github.com/eclipse-kuksa/kuksa-python-sdk/blob/main/.github/workflows/dash.yaml we actually use a virtual environment. From practical perspectives I generally do no think that the difference will be that big as we typically do not need multiple different Python environments in the same workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess you are right - as I understand it installs Python and adds it to path. It does not in itself initiate/activate a virtual environment. Setup-python has however some support for caching so in one way I think it may reuse certain parts
Agree. But caching seems to be disabled in our case, because from what I understand it needs to be explicitely enabled by using:
cache: 'pip' // pipenv //
see: https://github.com/actions/setup-python?tab=readme-ov-file#caching-packages-dependencies
Again, not telling here that we have to use a cache or not use cache (both will solve problems and create others), just pointing out things :)
In some other repos like https://github.com/eclipse-kuksa/kuksa-python-sdk/blob/main/.github/workflows/dash.yaml we actually use a virtual environment. From practical perspectives I generally do no think that the difference will be that big as we typically do not need multiple different Python environments in the same workflow.
I implemented that stuff based on some commands which were provided to me, so take it with a grain of salt :D It's probably still not the best way to handle that stuff. However in that case it was mandatory to have a clean / unpolluted python instance because otherwise we would point out libraries which are required by the system as libraries used by our software.
Personally I'm fine with the approach used here. As said, I just wanted to have a common understanding. The Commit Title somehow suggests that we use a venv and maybe even what we have now is called a venv - I'm no Python expert here. I was just directly thinking about the pip venv thingy and was somehow missing in my head and in this commit where it's activated :)
What was the issue with not doing this? Incompatible Python version, or just no pip oob? Generally of course "pinning" some Python version is likely a good idea even if it weren't broken before |
We are using ubuntu-latest and it looks like the underlying ubuntu version was upgraded, which lead to a new python version being applied which warns / fails with an error, when the system python is used for installation of requirements:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We use ubuntu-latest in most workflows, and github recently changed so that ubuntu-latest points to ubunto-24.04 instead of ubuntu-22.04 And then when doing It seems that pip in ubuntu-24.04 is more strict than in 22.04
See https://github.com/eclipse-kuksa/kuksa-databroker/actions/runs/11270488560 |
Needed after implicit update to ubuntu 24.04