From eed67c881eddd1f522e02b7b410d92fae7e39325 Mon Sep 17 00:00:00 2001
From: Stefan Saraev <stefan@saraev.ca>
Date: Sat, 18 Apr 2015 15:12:49 +0300
Subject: [PATCH 01/12] enable PYTHONOPTIMIZE with external Python

---
 xbmc/interfaces/python/XBPython.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/xbmc/interfaces/python/XBPython.cpp b/xbmc/interfaces/python/XBPython.cpp
index 695c6db..fe8b157 100644
--- a/xbmc/interfaces/python/XBPython.cpp
+++ b/xbmc/interfaces/python/XBPython.cpp
@@ -572,10 +572,9 @@ bool XBPython::OnScriptInitialized(ILanguageInvoker *invoker)
     // at http://docs.python.org/using/cmdline.html#environment-variables
 
 #if !defined(TARGET_WINDOWS) && !defined(TARGET_ANDROID)
-    /* PYTHONOPTIMIZE is set off intentionally when using external Python.
-    Reason for this is because we cannot be sure what version of Python
-    was used to compile the various Python object files (i.e. .pyo,
-    .pyc, etc.). */
+    // Required for python to find optimized code (pyo) files
+    setenv("PYTHONOPTIMIZE", "1", 1);
+
     // check if we are running as real xbmc.app or just binary
     if (!CUtil::GetFrameworksPath(true).empty())
     {
-- 
2.1.4

