Make auth-login work without env_setup
Change-Id: I4e46ea46ae3e4c4b0c1dcbe67a7029534e8fe612
diff --git a/env_setup/cipd/wrapper.py b/env_setup/cipd/wrapper.py
index e8c7b19..03baa95 100755
--- a/env_setup/cipd/wrapper.py
+++ b/env_setup/cipd/wrapper.py
@@ -44,12 +44,17 @@
# Put CIPD client in tools so that users can easily get it in their PATH.
CIPD_HOST = 'chrome-infra-packages.appspot.com'
+try:
+ PW_ROOT = os.environ['PW_ROOT']
+except KeyError:
+ PW_ROOT = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'])
+
# Get default install dir from environment since args cannot always be passed
# through this script (args are passed as-is to cipd).
if 'CIPD_PY_INSTALL_DIR' in os.environ:
DEFAULT_INSTALL_DIR = os.environ['CIPD_PY_INSTALL_DIR']
else:
- DEFAULT_INSTALL_DIR = os.path.join(os.environ['PW_ROOT'], '.cipd')
+ DEFAULT_INSTALL_DIR = os.path.join(PW_ROOT, '.cipd')
def platform_normalized():