Skip to content

Commit 2d585f2

Browse files
committed
✨ this let's the interpreter look for the packages in the shipped folder
- but they need to be present as full modules (which means that `.py` and not `.so` files are present? - will be large... but that is a side note Use Python=3.12 where pyvis examples should work in streamlit
1 parent f6cbac9 commit 2d585f2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

gui/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ Windows and macOS specific options:
6363
6464
## Quarto notebook execution
6565
66-
- add python exe to bundle as suggested [on stackoverflow](https://stackoverflow.com/a/72639099/9684872)
67-
- use [copy_python_executable.py](copy_python_executable.py) to copy the python executable to the bundle after PyInstaller is done
66+
- add python exe to bundle as suggested [on stackoverflow](https://stackoverflow.com/a/72639099/9684872) [not this way at least]
6867
69-
Basic workflow for bundle:
68+
## test shipping a python virtual environment with vuegen installed
7069
71-
1. use quarto (pandoc?) to convert qmd to ipynb
72-
1. use nbconvert programmatically (see [docs](https://nbconvert.readthedocs.io/en/latest/execute_api.html#example))
73-
and the bundled Python executable to execute notebook
74-
1. use quarto (pandoc?) ot convert executed ipynb to desired format

gui/app.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
quarto_share_path = os.path.join(sys._MEIPASS, "quarto_cli", "share")
5757
_PATH = os.pathsep.join([quarto_bin_path, quarto_share_path, _PATH])
5858
os.environ["PATH"] = _PATH
59+
# This requires that the python version is the same as the one used to create the executable
60+
# in the Python environment the kernel is started from for quarto based reports
61+
# os.environ["PYTHONPATH"] = os.pathsep.join(
62+
# sys.path
63+
# ) # ! requires kernel env with same Python env, but does not really seem to help
64+
os.environ["PYTHONPATH"] = os.pathsep.join(
65+
[sys.path[0], sys._MEIPASS]
66+
) # does not work
5967
elif app_path.parent.name == "gui":
6068
# should be always the case for GUI run from command line
6169
path_to_dat = (
@@ -111,10 +119,8 @@ def inner():
111119
kwargs["output_dir"] = output_dir_entry.get()
112120
print("kwargs:")
113121
pprint(kwargs)
114-
# os.environ["PYTHONPATH"] = os.pathsep.join(sys.path)
122+
115123
if python_dir_entry.get():
116-
# os.environ["PYTHONHOME"] = python_dir_entry.get()
117-
os.environ["PATH"] = python_dir_entry.get() + os.pathsep + _PATH
118124
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
119125
os.environ["PATH"] = os.pathsep.join(
120126
[
@@ -124,6 +130,10 @@ def inner():
124130
_PATH,
125131
]
126132
)
133+
else:
134+
messagebox.showwarning(
135+
"warning", "Running locally. Ignoring set Python Path"
136+
)
127137
try:
128138
os.chdir(kwargs["output_dir"]) # Change the working directory
129139
# Define logger suffix based on report type and name

0 commit comments

Comments
 (0)