[Buildroot] [PATCH v2 1/2] utils/scanpypi: ensure tmp_extract is cleaned up on exception

Thomas Petazzoni thomas.petazzoni at bootlin.com
Thu Aug 4 07:59:07 UTC 2022


Hello,

On Wed, 3 Aug 2022 16:02:43 -0600
James Hilliard <james.hilliard1 at gmail.com> wrote:

> > If I understand correctly self.tmp_extract is where the Python package
> > source code is extracted. So if you remove it at the end of
> > load_setup(), how will your new load_pyproject() added in PATCH 2/2 be
> > able to use the package source code?  
> 
> We're not deleting self.tmp_extract, we're just ensuring we current dir and
> sys.path states are cleaned up properly on failure, load_pyproject() does the
> same thing. Always restoring initial state at the end means load_pyproject()
> doesn't need to deal with current dir and sys.path global state changes induced
> by load_setup().
> 
> >
> > Also, why is this removal needed, as anyway the full tmp_path gets
> > removed at the end of the main() function?  
> 
> sys.path.remove(self.tmp_extract) is not the same as shutil.rmtree(tmp_path)
> 
> We're restoring the module search path at the end to avoid leaking global state
> changes when there's an exception.

Aaah, yes, my bad! I guess I shouldn't have reviewed this past midnight.

I'll go ahead and apply PATCH 1/2.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com



More information about the buildroot mailing list