summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Simmons <53658028+simmonsj330@users.noreply.github.com>2022-11-28 12:21:22 -0600
committerGitHub <noreply@github.com>2022-11-28 13:21:22 -0500
commitc7d0c98aa8d804fb5063b41e91ba2489a5e165e4 (patch)
tree96b6171a3e97ee16233a35a4fa961dbe5d5a58e3
parentd712fce7cb80e4c67852c911ec616a476b225e7c (diff)
Fixing reports on installers (#3623)
* adding hook * forgot to add if statement Co-authored-by: Chavithra <chavithra@gmail.com> Co-authored-by: James Maslek <jmaslek11@gmail.com>
-rw-r--r--build/pyinstaller/hooks/hook-inspect.py39
-rw-r--r--build/pyinstaller/terminal.spec4
-rw-r--r--openbb_terminal/reports/reports_controller.py4
3 files changed, 43 insertions, 4 deletions
diff --git a/build/pyinstaller/hooks/hook-inspect.py b/build/pyinstaller/hooks/hook-inspect.py
new file mode 100644
index 00000000000..718972baf50
--- /dev/null
+++ b/build/pyinstaller/hooks/hook-inspect.py
@@ -0,0 +1,39 @@
+# Runtime hook copied from pyinstaller
+
+
+import inspect
+import os
+import sys
+
+# pylint:disable=W0622,W0212,E1101
+
+_orig_inspect_getsourcefile = inspect.getsourcefile
+
+
+# Provide custom implementation of inspect.getsourcefile() for frozen applications that properly resolves relative
+# filenames obtained from object (e.g., inspect stack-frames). See #5963.
+def _pyi_getsourcefile(object):
+ filename = inspect.getfile(object)
+ if not os.path.isabs(filename):
+ # Check if given filename matches the basename of __main__'s __file__.
+ if hasattr(sys.modules["__main__"], "__file__"):
+ main_file = sys.modules["__main__"].__file__
+ if filename == os.path.basename(main_file):
+ return main_file
+
+ # If filename ends with .py suffix and does not correspond to frozen entry-point script, convert it to
+ # corresponding .pyc in sys._MEIPASS.
+ if filename.endswith(".py"):
+ filename = os.path.normpath(os.path.join(sys._MEIPASS, filename + "c"))
+ # Ensure the relative path did not try to jump out of sys._MEIPASS, just in case...
+ if filename.startswith(sys._MEIPASS):
+ return filename
+ elif filename.startswith(sys._MEIPASS) and filename.endswith(".pyc"):
+ # If filename is already PyInstaller-compatible, prevent any further processing (i.e., with original
+ # implementation).
+ return filename
+ # Use original implementation as a fallback.
+ return _orig_inspect_getsourcefile(object)
+
+
+inspect.getsourcefile = _pyi_getsourcefile
diff --git a/build/pyinstaller/terminal.spec b/build/pyinstaller/terminal.spec
index 1d2dc508569..926e10f69f2 100644
--- a/build/pyinstaller/terminal.spec
+++ b/build/pyinstaller/terminal.spec
@@ -44,6 +44,8 @@ added_files = [
(os.path.join(pathex, "user_agent"), "user_agent"),
(os.path.join(pathex, "vaderSentiment"), "vaderSentiment"),
(os.path.join(pathex, "prophet"), "prophet"),
+ (os.path.join(pathex, "riskfolio"), "riskfolio"),
+ (os.path.join(pathex, "astropy"), "astropy"),
(os.path.join(pathex, "frozendict", "VERSION"), "frozendict"),
(
os.path.join(pathex, "linearmodels", "datasets"),
@@ -91,6 +93,8 @@ hidden_imports = [
"_sysconfigdata__darwin_darwin",
"prophet",
"debugpy",
+ "riskfolio",
+ "astropy",
]
diff --git a/openbb_terminal/reports/reports_controller.py b/openbb_terminal/reports/reports_controller.py
index 5a52d23205e..3883577131f 100644
--- a/openbb_terminal/reports/reports_controller.py
+++ b/openbb_terminal/reports/reports_controller.py
@@ -20,7 +20,6 @@ from openbb_terminal.decorators import log_start_end
from openbb_terminal.menu import session
from openbb_terminal.parent_classes import BaseController
from openbb_terminal.rich_config import console, MenuText
-from openbb_terminal.terminal_helper import is_packaged_application
logger = logging.getLogger(__name__)
@@ -145,9 +144,6 @@ class ReportController(BaseController):
@log_start_end(log=logger)
def call_forecast(self, other_args: List[str]):
- if is_packaged_application():
- console.print("This report is disabled for the installed version")
- return
try:
import darts # pyright: reportMissingImports=false # noqa: F401, E501 #pylint: disable=import-outside-toplevel, unused-import