Hi!
I’ve managed to resolve this on Linux. I created a wheel for my Panel App by using the following setup.py
:
from setuptools import setup, find_packages
setup(
name='MyApp',
...
packages=find_packages(),
install_requires=[
'numpy>=1.22',
...
],
extra_requires={'dev': ['twine>=4.0.2']},
classifiers=[
'Programming Language :: Python :: 3',
...
],
scripts=['MyApp.sh',
'myapp.py',
],
python_requires='>=3.12',
)
Note: the key idea is to put MyApp.sh
and myapp.py
in the scripts
section in order to have them available in your $PATH
later.
Note that the MyApp.sh
is a shell script that will launch the panel app. In my case, it looks like this:
#! /usr/bin/bash
panel serve --show $(dirname $0)/myapp.py
The $(dirname $0)
will get the current path from the MyApp.sh
script (wich is the same for myapp.py
).
Then, I created the wheel file:
python setup.py bdist_wheel sdist
At this point, there will be a wheel file created in the dist
directory. Now you can upload it to PyPi or use it for a local installation. To test, I created another environment (make sure to have all the packages dependencies installed) and installed the wheel:
pip install --force-reinstall myapp.whl
Note: I used the --force-reinstall
to ensure that the modifications I made elsewhere would take effect upon installation.
With the wheel file installed within an appropriated environment, I could launch MyApp.sh
from elsewhere on my computer.
I’m not sure, but this seems more like a makeshift solution than an adequate one for what it is intented for, but it works in my case.
Caveats: in this way, both MyApp.sh
and myapp.py
will be included in your $PATH
, which is not ideal, since we just want MyApp.sh
.