If I use setuptools
to bundle a small program that just opens a grey window and doesn’t load anything, the distributable produced works fine.
However, if I create a program that loads a model (like the tutorial in the Panda3D manual), setuptools
still produces an app, but it doesn’t open.
My program (02_grassy_scene
) is this:
from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Load the environment model
self.scene = self.loader.loadModel("models/environment")
# Reparent the model to render
self.scene.reparentTo(self.render)
# Apply scale and position transforms on the model
self.scene.setScale(0.25, 0.25, 0.25)
self.scene.setPos(-8, 42, 0)
app = MyApp()
app.run()
My setup.py
is this:
from setuptools import setup
setup( # Parameters of the program go in here
name = "Grassy Scene",
options = {
"build_apps" : { # Build options go in here
"include_patterns" : ["**/*.egg"],
"gui_apps" : {"Grassy Scene" : "02_grass_scene.py"},
"plugins" : ["pandagl"],
}
}
)
And this is the error I get when I try to run the program:
:loader(error): Couldn't load file models/environment.egg: not found on model path (currently: "/Volumes/iMac and MBP Files/Programming/Python/Panda3D/Tutorials from the Manual/02/build/macosx_10_6_x86_64/Grassy Scene.app/Contents/MacOS/../Resources:/..:/../models")
Traceback (most recent call last):
File "02_grass_scene.py", line 18, in <module>
app = MyApp()
File "02_grass_scene.py", line 8, in __init__
self.scene = self.loader.loadModel("models/environment")
File "/Volumes/iMac and MBP Files/Programming/Python/Panda3D/Tutorials from the Manual/02/build/__whl_cache__/panda3d-1.10.4.1+opt-cp37-cp37m-macosx_10_6_x86_64.whl/direct/showbase/Loader.py", line 286, in loadModel
OSError: Could not load model file(s): ['models/environment']
I have a models
directory in the same folder as 02_grassy_scene.py
and the environment.egg.pz
model is in that directory. When I run the program normally (without setuptools
), it works fine and is able to find the model in the models
folder. In fact, it even shows up in getModelPaths()
.
What could be going wrong in the meantime?
Also, in the setup.py
file, in the include-patterns line, where is **/*.egg
?