Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Issue 2738053005: Make recipe module loader non-recursive

Created:
3 years, 9 months ago by Paweł Hajdan Jr.
Modified:
3 years, 9 months ago
Reviewers:
dnj, iannucci, martiniss
CC:
chromium-reviews, infra-reviews+recipes-py_chromium.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Make recipe module loader non-recursive Avoid importing python files other than api.py, test_api.py, and *config.py, to reduce chance of python path manipulation e.g. by resource scripts. BUG=none

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -27 lines) Patch
M recipe_engine/loader.py View 1 chunk +14 lines, -27 lines 0 comments Download

Messages

Total messages: 12 (5 generated)
Paweł Hajdan Jr.
Please review. If this looks good but you have suggestions for further improvements, I'd prefer ...
3 years, 9 months ago (2017-03-09 14:27:06 UTC) #6
iannucci
I think that this is the right change to the engine, but before we land ...
3 years, 9 months ago (2017-03-09 17:48:53 UTC) #7
iannucci
On 2017/03/09 17:48:53, iannucci wrote: > I think that this is the right change to ...
3 years, 9 months ago (2017-03-09 17:49:49 UTC) #8
Paweł Hajdan Jr.
If the change looks good, why not approve it? I believe both landing the CL ...
3 years, 9 months ago (2017-03-09 21:49:06 UTC) #9
iannucci1
On 2017/03/09 21:49:06, Paweł Hajdan Jr. wrote: > If the change looks good, why not ...
3 years, 9 months ago (2017-03-09 22:08:23 UTC) #10
Dirk Pranke
I don't really know this code and hence don't understand the full ramifications of this ...
3 years, 9 months ago (2017-03-09 22:13:03 UTC) #11
iannucci
3 years, 9 months ago (2017-03-09 23:01:10 UTC) #12
On 2017/03/09 22:13:03, Dirk Pranke wrote:
> I don't really know this code and hence don't understand the full
ramifications
> of this change.
> 
> Does this affect something like 
> 
>
https://cs.chromium.org/chromium/build/scripts/slave/recipe_modules/test_util...
> 
> 
> since that's not one of the approved names? Or does that go through regular
> python importing somehow?

It would affect something like

  path/to/recipe_modules/module/subdir/__init__.py
  path/to/recipe_modules/module/subdir/script.py
  path/to/recipe_modules/module/subdir/script_unittest.py

Right now when depending on 'module', the loader would see __init__.py and then
import everything in subdir (script.py and script_unittest.py). There is at
least one case where the unittest modifies sys.path and PYTHONPATH during import
time:
https://cs.chromium.org/chromium/build/scripts/slave/recipe_modules/test_resu...
.

Some scripts in other parts of the recipe codebase take implicit dependency on
this modification to PYTHONPATH. Additionally, this sys.path manipulation breaks
when not running under buildbot (e.g. when running the script in swarming or a
simple clone of build without the other surrounding repos), which causes the
whole recipe import process to fail if the unittest can't run
common.env.Install().

Because of the implicit dependencies, some scripts today (e.g. crbug.com/699969)
are 'working' by virtue of the fact that the unittest is tweaking PYTHONPATH
when it's taken as a dependency. If we land this loader change right now, these
implicit dependencies will break and builds will start failing because of it.

Note that this change IS A GOOD CHANGE! It would have prevented this mess if we
never did the recursive import thing in the first place. We should definitely
land it, but we need a plan so that landing it is safe (or at least as safe as
we can reasonably make it).

Powered by Google App Engine
This is Rietveld 408576698