tools/make_pip: Use venv when invoking pip
PATCH v2 1/1 tools/make_pip: Use venv when invoking pip
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.
To prepare CI container migration to Ubuntu 24.04, use a venv in the make_pip script.
Note: This has been reported on [1]
[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/37
---
This has been tested in docker on ubuntu:24.04 after running:
$ apt install python3 python3-venv
with:
$ ./scripts/make_pip.sh u_boot_pylib "-n"
And shows:
Successfully built u_boot_pylib-0.0.6.tar.gz and u_boot_pylib-0.0.6-py3-none-any.whl
Also tested with "$ make pip".
---
Changes in v2:
- Use venv instead of virtualenv (Tom)
- Link to v1: https://lore.kernel.org/r/[email protected]
--- scripts/make_pip.sh | 6 ++++++ 1 file changed, 6 insertions(+)
scripts/make_pip.sh +6 -0
@@ -106,6 +106,10 @@ fi mkdir ${dir}/tests cd ${dir} +# Use virtual environment +python3 -m venv .venv +source .venv/bin/activate + # Make sure the tools are up to date python3 -m pip install --upgrade build python3 -m pip install --upgrade twine
@@ -122,6 +126,8 @@ if [ -n "${upload}" ]; then echo "Completed upload of ${tool}" fi +# Finish using virtual environment +deactivate rm -rf "${dir}" echo -e "done\n\n"
---
base-commit: 9d9fbdab0e9664bff147109cc89ad2786f6ecd83
change-id: 20250408-ubuntu-24-04-0dce32b95770
Best regards,
Signature · 1 line
Mattijs Korpershoek <[email protected]>
Hi Mattijs,
Quoted 37 lines · Mattijs Korpershoek
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.To prepare CI container migration to Ubuntu 24.04, use a venv in the
make_pipscript.Note: This has been reported on [1]
[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/37
Signed-off-by Mattijs Korpershoek <[email protected]>---
This has been tested in docker on ubuntu:24.04 after running:$ apt install python3 python3-venvwith:
$ ./scripts/make_pip.sh u_boot_pylib "-n"And shows:
Successfully built u_boot_pylib-0.0.6.tar.gz and u_boot_pylib-0.0.6-py3-none-any.whlAlso tested with "$ make pip".
---
Changes in v2:
- Use venv instead of virtualenv (Tom)
- Link to v1: https://lore.kernel.org/r/[email protected]--- scripts/make_pip.sh | 6 ++++++ 1 file changed, 6 insertions(+)scripts/make_pip.sh +0
-0
scripts/make_pip.sh fi · line 110
Quoted 5 lines
scripts/make_pip.sh +2
-0@@ -106,6 +106,10 @@ fi mkdir ${dir}/tests cd ${dir} +# Use virtual environment +python3 -m venv .venv
Do we want to make sure there are no leftovers from previous runs? If so, maybe add --clear here?
scripts/make_pip.sh if [ -n "${upload}" ]; then · line 130
Quoted 11 lines
scripts/make_pip.sh +4
-0+source .venv/bin/activate + # Make sure the tools are up to date python3 -m pip install --upgrade build python3 -m pip install --upgrade twine@@ -122,6 +126,8 @@ if [ -n "${upload}" ]; then echo "Completed upload of ${tool}" fi +# Finish using virtual environment +deactivate
Maybe you want this in a trap so that if we exit early (which may happen due to the script doing set -e), we're out of the venv?
And I tested otherwise, with:
#!/usr/bin/env bash
python3 -m venv .venv
source .venv/bin/activate
and it seems that once I exit the script it's deactivated anyways?
So, I guess no need for the trap or the deactivate, but we can play it safe and still have it :)
Cheers,
Quentin
Hi Quentin,
Thank you for the review.
Quoted 43 lines · Quentin Schulz
Hi Mattijs,
Quoted 40 lines · Mattijs Korpershoek
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.To prepare CI container migration to Ubuntu 24.04, use a venv in the
make_pipscript.Note: This has been reported on [1]
[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/37
Signed-off-by Mattijs Korpershoek <[email protected]>---
This has been tested in docker on ubuntu:24.04 after running:$ apt install python3 python3-venvwith:
$ ./scripts/make_pip.sh u_boot_pylib "-n"And shows:
Successfully built u_boot_pylib-0.0.6.tar.gz and u_boot_pylib-0.0.6-py3-none-any.whlAlso tested with "$ make pip".
---
Changes in v2:
- Use venv instead of virtualenv (Tom)
- Link to v1: https://lore.kernel.org/r/[email protected]--- scripts/make_pip.sh | 6 ++++++ 1 file changed, 6 insertions(+)scripts/make_pip.sh +0
-0@@ -106,6 +106,10 @@ fi mkdir ${dir}/tests cd ${dir}
Quoted 5 lines
scripts/make_pip.sh fi · line 110
Quoted 2 lines
scripts/make_pip.sh +2
-0+# Use virtual environment +python3 -m venv .venvDo we want to make sure there are no leftovers from previous runs? If so, maybe add --clear here?
I've thought about this, and looking at the script itself it already suffers from those issues. For example, the $dir created with mktemp is also not removed.
Quoted 16 lines
scripts/make_pip.sh if [ -n "${upload}" ]; then · line 130
Quoted 12 lines
scripts/make_pip.sh +4
-0+source .venv/bin/activate + # Make sure the tools are up to date python3 -m pip install --upgrade build python3 -m pip install --upgrade twine@@ -122,6 +126,8 @@ if [ -n "${upload}" ]; then echo "Completed upload of ${tool}" fi +# Finish using virtual environment +deactivateMaybe you want this in a trap so that if we exit early (which may happen due to the script doing
set -e), we're out of the venv?
Quoted 7 lines
And I tested otherwise, with:
#!/usr/bin/env bash
python3 -m venv .venv
source .venv/bin/activateand it seems that once I exit the script it's deactivated anyways?
Ah, interesting to know. I just added it to have a "symetric cleanup".
Quoted 3 lines
So, I guess no need for the trap or the deactivate, but we can play it safe and still have it :)
I think using a trap makes sense, but this should also be done for the ${dir} directory.
I'd also argue that this would more be the candidate for another patch than to be part of this one.
Quoted 3 lines
Cheers,
Quentin
Hi Mattijs,
Quoted 77 lines · Mattijs Korpershoek
Hi Quentin,
Thank you for the review.
Quoted 43 lines · Quentin Schulz
Hi Mattijs,
Quoted 40 lines · Mattijs Korpershoek
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.To prepare CI container migration to Ubuntu 24.04, use a venv in the
make_pipscript.Note: This has been reported on [1]
[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/37
Signed-off-by Mattijs Korpershoek <[email protected]>---
This has been tested in docker on ubuntu:24.04 after running:$ apt install python3 python3-venvwith:
$ ./scripts/make_pip.sh u_boot_pylib "-n"And shows:
Successfully built u_boot_pylib-0.0.6.tar.gz and u_boot_pylib-0.0.6-py3-none-any.whlAlso tested with "$ make pip".
---
Changes in v2:
- Use venv instead of virtualenv (Tom)
- Link to v1: https://lore.kernel.org/r/[email protected]--- scripts/make_pip.sh | 6 ++++++ 1 file changed, 6 insertions(+)scripts/make_pip.sh +0
-0@@ -106,6 +106,10 @@ fi mkdir ${dir}/tests cd ${dir}Quoted 5 lines
scripts/make_pip.sh fi · line 110
Quoted 2 lines
scripts/make_pip.sh +2
-0+# Use virtual environment +python3 -m venv .venvDo we want to make sure there are no leftovers from previous runs? If so, maybe add --clear here?
I've thought about this, and looking at the script itself it already suffers from those issues. For example, the $dir created with mktemp is also not removed.
Quoted 18 lines
scripts/make_pip.sh if [ -n "${upload}" ]; then · line 130
Quoted 12 lines
scripts/make_pip.sh +4
-0+source .venv/bin/activate + # Make sure the tools are up to date python3 -m pip install --upgrade build python3 -m pip install --upgrade twine@@ -122,6 +126,8 @@ if [ -n "${upload}" ]; then echo "Completed upload of ${tool}" fi +# Finish using virtual environment +deactivateMaybe you want this in a trap so that if we exit early (which may happen due to the script doing
set -e), we're out of the venv?And I tested otherwise, with:
Quoted 8 lines
Quoted 5 lines
#!/usr/bin/env bash
python3 -m venv .venv
source .venv/bin/activateand it seems that once I exit the script it's deactivated anyways?
Ah, interesting to know. I just added it to have a "symetric cleanup".
Yup, absolutely makes sense.
Quoted 7 lines
Quoted 3 lines
So, I guess no need for the trap or the deactivate, but we can play it safe and still have it :)
I think using a trap makes sense, but this should also be done for the ${dir} directory.
Indeed.
Quoted 3 lines
I'd also argue that this would more be the candidate for another patch than to be part of this one.
Fair enough. I believe the --clear addition to python3 -m venv .venv would still make sense though? What do you think?
Cheers,
Quentin
Quoted 99 lines · Quentin Schulz
Hi Mattijs,
Quoted 77 lines · Mattijs Korpershoek
Hi Quentin,
Thank you for the review.
Quoted 43 lines · Quentin Schulz
Hi Mattijs,
Quoted 40 lines · Mattijs Korpershoek
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.To prepare CI container migration to Ubuntu 24.04, use a venv in the
make_pipscript.Note: This has been reported on [1]
[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/37
Signed-off-by Mattijs Korpershoek <[email protected]>---
This has been tested in docker on ubuntu:24.04 after running:$ apt install python3 python3-venvwith:
$ ./scripts/make_pip.sh u_boot_pylib "-n"And shows:
Successfully built u_boot_pylib-0.0.6.tar.gz and u_boot_pylib-0.0.6-py3-none-any.whlAlso tested with "$ make pip".
---
Changes in v2:
- Use venv instead of virtualenv (Tom)
- Link to v1: https://lore.kernel.org/r/[email protected]--- scripts/make_pip.sh | 6 ++++++ 1 file changed, 6 insertions(+)scripts/make_pip.sh +0
-0@@ -106,6 +106,10 @@ fi mkdir ${dir}/tests cd ${dir}Quoted 5 lines
scripts/make_pip.sh fi · line 110
Quoted 2 lines
scripts/make_pip.sh +2
-0+# Use virtual environment +python3 -m venv .venvDo we want to make sure there are no leftovers from previous runs? If so, maybe add --clear here?
I've thought about this, and looking at the script itself it already suffers from those issues. For example, the $dir created with mktemp is also not removed.
Quoted 18 lines
scripts/make_pip.sh if [ -n "${upload}" ]; then · line 130
Quoted 12 lines
scripts/make_pip.sh +4
-0+source .venv/bin/activate + # Make sure the tools are up to date python3 -m pip install --upgrade build python3 -m pip install --upgrade twine@@ -122,6 +126,8 @@ if [ -n "${upload}" ]; then echo "Completed upload of ${tool}" fi +# Finish using virtual environment +deactivateMaybe you want this in a trap so that if we exit early (which may happen due to the script doing
set -e), we're out of the venv?And I tested otherwise, with:
Quoted 8 lines
Quoted 5 lines
#!/usr/bin/env bash
python3 -m venv .venv
source .venv/bin/activateand it seems that once I exit the script it's deactivated anyways?
Ah, interesting to know. I just added it to have a "symetric cleanup".
Yup, absolutely makes sense.
Quoted 7 lines
Quoted 3 lines
So, I guess no need for the trap or the deactivate, but we can play it safe and still have it :)
I think using a trap makes sense, but this should also be done for the ${dir} directory.
Quoted 8 lines
Indeed.
Quoted 3 lines
I'd also argue that this would more be the candidate for another patch than to be part of this one.
Fair enough. I believe the --clear addition to python3 -m venv .venv would still make sense though? What do you think?
Hmm I'm a bit mixed about that one:
- .venv will be in a folder created via "mktemp -d"
- this folder will be different each time we run the script
So per my understanding, adding the --clear is not necessary here. However, I don't feel strongly about not adding it. So if you wish, I can spin up a v3 !
Quoted 3 lines
Cheers,
Quentin
Quentin Schulz
Reviewed-byHi Mattijs,
Quoted 107 lines · Mattijs Korpershoek
Quoted 105 lines · Quentin Schulz
Hi Mattijs,
Quoted 77 lines · Mattijs Korpershoek
Hi Quentin,
Thank you for the review.
Quoted 43 lines · Quentin Schulz
Hi Mattijs,
Quoted 40 lines · Mattijs Korpershoek
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.To prepare CI container migration to Ubuntu 24.04, use a venv in the
make_pipscript.Note: This has been reported on [1]
[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/37
Signed-off-by Mattijs Korpershoek <[email protected]>---
This has been tested in docker on ubuntu:24.04 after running:$ apt install python3 python3-venvwith:
$ ./scripts/make_pip.sh u_boot_pylib "-n"And shows:
Successfully built u_boot_pylib-0.0.6.tar.gz and u_boot_pylib-0.0.6-py3-none-any.whlAlso tested with "$ make pip".
---
Changes in v2:
- Use venv instead of virtualenv (Tom)
- Link to v1: https://lore.kernel.org/r/[email protected]--- scripts/make_pip.sh | 6 ++++++ 1 file changed, 6 insertions(+)scripts/make_pip.sh +0
-0@@ -106,6 +106,10 @@ fi mkdir ${dir}/tests cd ${dir}Quoted 5 lines
scripts/make_pip.sh fi · line 110
Quoted 2 lines
scripts/make_pip.sh +2
-0+# Use virtual environment +python3 -m venv .venvDo we want to make sure there are no leftovers from previous runs? If so, maybe add --clear here?
I've thought about this, and looking at the script itself it already suffers from those issues. For example, the $dir created with mktemp is also not removed.
Quoted 18 lines
scripts/make_pip.sh if [ -n "${upload}" ]; then · line 130
Quoted 12 lines
scripts/make_pip.sh +4
-0+source .venv/bin/activate + # Make sure the tools are up to date python3 -m pip install --upgrade build python3 -m pip install --upgrade twine@@ -122,6 +126,8 @@ if [ -n "${upload}" ]; then echo "Completed upload of ${tool}" fi +# Finish using virtual environment +deactivateMaybe you want this in a trap so that if we exit early (which may happen due to the script doing
set -e), we're out of the venv?And I tested otherwise, with:
Quoted 8 lines
Quoted 5 lines
#!/usr/bin/env bash
python3 -m venv .venv
source .venv/bin/activateand it seems that once I exit the script it's deactivated anyways?
Ah, interesting to know. I just added it to have a "symetric cleanup".
Yup, absolutely makes sense.
Quoted 7 lines
Quoted 3 lines
So, I guess no need for the trap or the deactivate, but we can play it safe and still have it :)
I think using a trap makes sense, but this should also be done for the ${dir} directory.
Indeed.
Quoted 3 lines
I'd also argue that this would more be the candidate for another patch than to be part of this one.
Quoted 7 lines
Quoted 2 lines
Fair enough. I believe the --clear addition to python3 -m venv .venv would still make sense though? What do you think?
Hmm I'm a bit mixed about that one:
- .venv will be in a folder created via "mktemp -d"
- this folder will be different each time we run the script
I clearly have missed this was running from an "mktemp -d"'ed directory. So it's useless indeed :)
Thanks!
Quentin
Quoted 9 lines · Mattijs Korpershoek
Recent Ubuntu versions (24.04+) disallow pip by default when installing packages. The recommended approach is to use a virtual environment (venv) instead.
Because of this, "make pip" is failing on such versions.To prepare CI container migration to Ubuntu 24.04, use a venv in the
make_pipscript.[...]
Applied to u-boot/master, thanks!
[1/1] tools/make_pip: Use venv when invoking pip
commit: 9d3f1ebaf8751f0287b5d02158cc706435f8fb19
Signature · 1 line
Tom