LoginSignup
0
0

More than 5 years have passed since last update.

GAE/Pythonのローカルでのユニットテストを通すためのライブラリパス設定

Last updated at Posted at 2016-11-26

概要

開発用PCの片方は brew-cask で google-cloud-sdk をインストールしてしまった Mac OS X、もう片方は apt-get で google-cloud-sdk-app-engine-python をインストールした Bash on Ubuntu on Windows というカオスな環境で、ローカルで走らせるユニットテスト用の PYTHONPATH をなんとかしたい。

環境

Python 2.7

やり方

gcloud info --format=json で json で設定情報が帰ってくるので、sdk_root をそこからゲットする。

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'))
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0