Files
OpenBB/build/pyinstaller/terminal.spec
montezdesousa a9787dd2d1 Refactor reports menu and make it work on installer (#2878)
* start papermill rollback

* move reports to templates folder

* comment some stuff

* refactor reports controller

* change var names

* clean ctrl class vars

* small refactoring on metadata search

* relocate some func

* breaking changes

* revert some changes

* destroying changes

* change menu appearance

* change menu appeaerance again

* update choices

* change some assets locations

* remove unused vars

* change some docstrings

* rename vars

* its working

* forgot one dash

* omg its working

* clean some code and doc

* change func name

* fix a bug and add some comments

* fix economy report startup

* add custom reports

* allow custom reports

* forgot to delete this

* unused import

* make somestuff more explicit, 5 min rule

* add helper func

* supress errors--no-verify

* add some type checks

* fix check ipynb func

* check inputs in run

* rewrite some integration tests

* remove unused import

* add some docs to website

* add auto completion

* warn if no forecast

* add to do

* add arg name if 1 arg

* add papermill pointing to github main

* add notebooks

* fix terminal spec

* relocated choices files

* merge main

* relocate website docs for reports

* limit user choices

* fix portfolio auto completion

* limit choices fix

* clean som edocstrings

* limit user choices in run command

* improve run parser

* fix msg

* add reports controller tests

* relax crypto choices limit

* contain commands

* pass pre commit

* flake8

* flake8

* ignore mypy

* pylint

* website

* move docs to jupyter tab

* add installer dep

* remove etf

* remove reports

* update reports to main

* handle events erros

* rever reports to previous commits before main merge

* add papermill installer strategies

* add flags to terminal

* avoid sdk crash

* execute notebook in thread

* remove unused sys

* execute report in a child process

* fix some notebook stuff

* fix portfolio report

* fix reports controller volatility

* change api to sdk

* move images

* remove som unucessary installer imports

* remove debugger warning

* move ipykernel launcher

* supress notebook crash

* remove portfolio decorator

* fix run command

* forgot to change this

* add images

* fix portfolio report

* fix crypto report

* linting and tests

* add run integration test

* pylint

* hide reports module args

* try at supressing args

* try at supreccing warning

* solve some os issues

* handle pm errors

* fix warning unrecognized arguments

* change comment

* avoid crash when parameters not found

* fix etf commands

* minor cleanup

* update forecasting check

* fix some linting

* fix futures test

* pylint

* limit user choices to prompt

* limit user choices to prompt

* supress warnings

* revert poetry lock back to main

* papermill pointing to main

* flake8

* forgot requirements

* Update helper_funcs.py

* Update reports_model.py

* choices

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: James Simmons <53658028+simmonsj330@users.noreply.github.com>
2022-10-26 21:27:30 +01:00

176 lines
4.5 KiB
Python
Vendored

# -*- mode: python ; coding: utf-8 -*-
import os
import pathlib
from dotenv import set_key
from PyInstaller.compat import is_darwin, is_win
from PyInstaller.building.api import PYZ, EXE, COLLECT
from PyInstaller.building.splash import Splash
from PyInstaller.building.build_main import Analysis
# import subprocess
from openbb_terminal.loggers import get_commit_hash
NAME = "OpenBBTerminal"
build_type = (
os.getenv("OPENBB_BUILD_TYPE") if bool(os.getenv("OPENBB_BUILD_TYPE")) else "folder"
)
# Local python environment packages folder
pathex = os.path.join(os.path.dirname(os.__file__), "site-packages")
# Removing unused ARM64 binary
binary_to_remove = pathlib.Path(
os.path.join(pathex, "_scs_direct.cpython-39-darwin.so")
)
print("Removing ARM64 Binary: _scs_direct.cpython-39-darwin.so")
binary_to_remove.unlink(missing_ok=True)
# Get latest commit
commit_hash = get_commit_hash()
build_assets_folder = os.path.join(os.getcwd(), "build", "pyinstaller")
default_env_file = os.path.join(build_assets_folder, ".env")
set_key(default_env_file, "OPENBB_LOGGING_COMMIT_HASH", str(commit_hash))
# Files that are explicitly pulled into the bundle
added_files = [
(os.path.join(os.getcwd(), "openbb_terminal"), "openbb_terminal"),
(os.path.join(pathex, "property_cached"), "property_cached"),
(os.path.join(pathex, "user_agent"), "user_agent"),
(os.path.join(pathex, "vaderSentiment"), "vaderSentiment"),
(os.path.join(pathex, "prophet"), "prophet"),
(os.path.join(pathex, "frozendict", "VERSION"), "frozendict"),
(
os.path.join(pathex, "linearmodels", "datasets"),
os.path.join("linearmodels", "datasets"),
),
(
os.path.join(pathex, "statsmodels", "datasets"),
os.path.join("statsmodels", "datasets"),
),
(
os.path.join(pathex, "investpy", "resources"),
os.path.join("investpy", "resources"),
),
(
os.path.join(pathex, "pymongo"),
"pymongo",
),
(os.path.join(pathex, "bson"), "bson"),
(os.path.join(pathex, "debugpy", "_vendored"), os.path.join("debugpy", "_vendored")),
(".env", "."),
]
# Python libraries that are explicitly pulled into the bundle
hidden_imports = [
"sklearn.utils._cython_blas",
"sklearn.utils._typedefs",
"sklearn.utils._heap",
"sklearn.utils._sorting",
"sklearn.utils._vector_sentinel",
"sklearn.neighbors.quad_tree",
"sklearn.tree._utils",
"sklearn.neighbors._partition_nodes",
"squarify",
"linearmodels",
"statsmodels",
"user_agent",
"vaderSentiment",
"frozendict",
"textwrap3",
"pyEX",
"tensorflow",
"feedparser",
"pymongo",
"bson",
"_sysconfigdata__darwin_darwin",
"prophet",
"debugpy",
]
analysis_kwargs = dict(
scripts=[os.path.join(os.getcwd(), "terminal.py")],
pathex=[pathex, "."],
binaries=[],
datas=added_files,
hiddenimports=hidden_imports,
hookspath=["build/pyinstaller/hooks"],
hooksconfig={},
runtime_hooks=["build/pyinstaller/hooks/hook-debugpy.py"],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None,
noarchive=False,
)
a = Analysis(**analysis_kwargs)
pyz = PYZ(a.pure, a.zipped_data, cipher=analysis_kwargs["cipher"])
exe_args = [
pyz,
a.scripts,
[],
]
exe_kwargs = dict(
name=NAME,
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
upx_exclude=[],
console=True,
disable_windowed_traceback=False,
target_arch="x86_64",
codesign_identity=None,
entitlements_file=None,
)
# Packaging settings
if build_type == "onefile":
exe_args += [a.binaries, a.zipfiles, a.datas]
exe_kwargs["runtime_tmpdir"] = None
elif build_type == "folder":
exe_kwargs["exclude_binaries"] = True
collect_args = [
a.binaries,
a.zipfiles,
a.datas,
]
collect_kwargs = dict(
strip=False,
upx=True,
upx_exclude=[],
name=NAME,
)
# Platform specific settings
if is_win:
splash = Splash(
os.path.join(os.getcwd(), "images", "openbb_splashscreen.png"),
binaries=a.binaries,
datas=a.datas,
text_pos=(200, 400),
text_size=12,
text_color="white",
)
exe_args += [splash, splash.binaries]
exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "openbb_icon.ico"),)
if is_darwin:
exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "openbb.icns"),)
exe = EXE(*exe_args, **exe_kwargs)
if build_type == "folder":
coll = COLLECT(*([exe] + collect_args), **collect_kwargs)