Reland: Remove a bit of sys.path hackery.

Previously would reconfigure sys.path during the execution of
the recipe code in order to make `from recipe_engine import ...` work.
This changes it so that moves up a level, which will make all
known executions of (namely, the test runner and
the two bundled launcher scripts) automatically set PYTHONPATH

Reland: Spurious quotes in generated .bat file caused invalid
PYTHONPATH entry... but the reland just moves to make all
syspath manipulation unnecessary.

R=fancl, yiwzhang, mohrr

Bug: 1462728
Change-Id: If32c880caa5dc2084fb6255f0bfef392cba225c3
Commit-Queue: Chenlin Fan <>
Reviewed-by: Chenlin Fan <>
Auto-Submit: Robbie Iannucci <>
diff --git a/.gitattributes b/.gitattributes
index ada2a62..5b91166 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,5 @@
 /         recipes
+/            recipes
 /recipe_engine/**   recipes
 /**/unittests/**   -recipes
 .vpython3           recipes
diff --git a/recipe_engine/ b/
similarity index 87%
rename from recipe_engine/
rename to
index 93a8590..18da041 100755
--- a/recipe_engine/
+++ b/
@@ -55,28 +55,12 @@
 del _hack_lookup_codecs
-# Hack 4; Drop sys.path[0], which is ROOT_DIR/recipe_engine. This prevents user
-# recipe code from doing things like `import util` and getting
-# recipe_engine/
-# This is needed because lives inside of the recipe_engine folder; when
-# invokes this as `python path/to/recipe_engine/`, python puts
-# this directory at the front of sys.path.
-# A better long-term fix would be to move up one level so that the
-# automatically-prepended directory would remove the need for this and the
-# ROOT_DIR bit below.
-sys.path = sys.path[1:]
   import urllib3.contrib.pyopenssl
 except ImportError:
-ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-sys.path.insert(0, ROOT_DIR)
 from recipe_engine.internal import debugger
diff --git a/recipe_engine/internal/commands/bundle/ b/recipe_engine/internal/commands/bundle/
index e87fa5a..89cca94 100644
--- a/recipe_engine/internal/commands/bundle/
+++ b/recipe_engine/internal/commands/bundle/
@@ -153,13 +153,11 @@
 # pylint: disable=line-too-long
 TEMPLATE3_SH = """#!/usr/bin/env bash
-export PYTHONPATH=${BASH_SOURCE[0]%/*}/recipe_engine
-exec vpython3 -u ${BASH_SOURCE[0]%/*}/recipe_engine/recipe_engine/
+exec vpython3 -u ${BASH_SOURCE[0]%/*}/recipe_engine/
 TEMPLATE3_BAT = """@echo off
-set PYTHONPATH="%~dp0\\recipe_engine"
-call vpython3.bat -u "%~dp0\\recipe_engine\\recipe_engine\\"
+call vpython3.bat -u "%~dp0\\recipe_engine\\"
 # pylint: enable=line-too-long
diff --git a/recipe_engine/internal/commands/test/ b/recipe_engine/internal/commands/test/
index 9db71f8..7e92d1c 100644
--- a/recipe_engine/internal/commands/test/
+++ b/recipe_engine/internal/commands/test/
@@ -600,7 +600,7 @@
         # Assuming ANY of those things are still a thing at that point :).
-        os.path.join(engine_path, 'recipe_engine', ''),
+        os.path.join(engine_path, ''),
         os.path.join(recipe_deps.main_repo.path, RECIPES_CFG_LOCATION_REL),
diff --git a/ b/
index c6ef83a..0c0b2e2 100755
--- a/
+++ b/
@@ -252,7 +252,7 @@
       os.path.join(engine_path, spec),
-      os.path.join(engine_path, 'recipe_engine', ''),
+      os.path.join(engine_path, ''),
   ] + args)
   if IS_WIN: