From 3342ad1e681b777deacef2ce5abfa882116e2258 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 16 Aug 2017 13:17:26 +0100
Subject: [PATCH 03/14] Darwin: Hack sys.{exec_,}prefix if run from
 python.app/Contents

---
 Lib/site.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Lib/site.py b/Lib/site.py
index 3b51e81d4a..aa5dcac36d 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -63,6 +63,15 @@ import os
 import __builtin__
 import traceback
 
+def _fix_prefix(path):
+    path = os.path.normpath(path)
+    if path.endswith('/python.app/Contents'):
+        path = os.path.normpath(path + '/../..')
+    return path
+
+sys.prefix = _fix_prefix(sys.prefix)
+sys.exec_prefix = _fix_prefix(sys.exec_prefix)
+
 # Prefixes for site-packages; add additional prefixes like /usr/local here
 PREFIXES = [sys.prefix, sys.exec_prefix]
 # Enable per user site-packages directory
-- 
2.18.0

