All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Quentin Schulz <quentin.schulz@cherry.de>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v2] tools/make_pip: Use venv when invoking pip
Date: Wed, 16 Apr 2025 16:21:55 +0200	[thread overview]
Message-ID: <87cydc4264.fsf@kernel.org> (raw)
In-Reply-To: <7278a03f-57d3-4e50-9c84-8b329c2032e8@cherry.de>

Hi Quentin,

Thank you for the review.

On mer., avril 16, 2025 at 14:47, Quentin Schulz <quentin.schulz@cherry.de> wrote:

> Hi Mattijs,
>
> On 4/16/25 2:36 PM, Mattijs Korpershoek wrote:
>> 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
>> 
>> Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
>> ---
>> 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/20250409-ubuntu-24-04-v1-1-056728207b6c@kernel.org
>> ---
>>   scripts/make_pip.sh | 6 ++++++
>>   1 file changed, 6 insertions(+)
>> 
>> diff --git a/scripts/make_pip.sh b/scripts/make_pip.sh
>> index d2639ffd6e43..33ad51ada703 100755
>> --- a/scripts/make_pip.sh
>> +++ b/scripts/make_pip.sh
>> @@ -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?

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.

>
>> +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?

Ah, interesting to know. I just added it to have a "symetric cleanup".

>
> 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.

>
> Cheers,
> Quentin

  reply	other threads:[~2025-04-16 14:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 12:36 [PATCH v2] tools/make_pip: Use venv when invoking pip Mattijs Korpershoek
2025-04-16 12:47 ` Quentin Schulz
2025-04-16 14:21   ` Mattijs Korpershoek [this message]
2025-04-16 14:26     ` Quentin Schulz
2025-04-16 15:06       ` Mattijs Korpershoek
2025-04-16 15:09         ` Quentin Schulz
2025-04-25 13:42 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cydc4264.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=quentin.schulz@cherry.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.