From f418fdcc887c98838f979ee6891b32a25b0a4df7 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/15] 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.19.1

