One of the development PCs is brew-cask with google-cloud-sdk installed on Mac OS X, the other is apt-get with google-cloud-sdk-app-engine-python installed on Bash on Ubuntu on I want to manage PYTHONPATH for unit test to run locally in the chaotic environment of Windows.
Python 2.7
Since the setting information is returned by json with gcloud info --format = json, get sdk_root from there.
import os, sys, subprocess, json
gcloud_info = json.loads(subprocess.check_output(['gcloud', 'info', '--format=json']))
sdk_path = os.path.join(gcloud_info["installation"]["sdk_root"], 'platform', 'google_appengine')
sys.path.append(sdk_path)
sys.path.append(os.path.join(sdk_path, 'lib', 'yaml', 'lib'))
Recommended Posts