I followed this beginner tutorial to make a game, and after finishing it I’ve ended up with a lot of data files in subfolders.
After a bit of fiddling, and following setuptools documentation, I ended up with this file structure:
(In case it’s not clear, the Python files and the Assets folder are in Source)
In my game scripts, I get each resource with a path name that starts with “Assets”, like this:
loader.loadTexture("Assets/UI/UIButton.png")
This works fine when running python Source/Game.py
. But after I build the game with bdist_apps
, the data files are placed under Source/Assets
, so the game can’t find those files anymore and will crash if I try to load them.
Here’s my setup.py
file (I’m not using the TOML file right now):
from setuptools import setup, find_packages
setup(
name="Panda-chan and the Endless Horde",
include_package_data=True,
options={
"build_apps": {
"include_patterns": [
"**/*.png",
"**/*.ogg",
"**/*.txt",
"**/*.egg",
"Fonts/*"
],
"gui_apps": {
"Panda-chan and the Endless Horde": "Source/Game.py"
},
"plugins": [
"pandagl",
"p3openal_audio"
],
"platforms": [
"manylinux2010_x86_64",
"macosx_10_9_x86_64",
"win_amd64"
],
"log_filename": "$HOME/PandaChanAndHorde/output.log",
"log_append": False
}
}
)
And my MANIFEST.in
file:
include Source/Assets/Fonts/*
include Source/Assets/Models/*
include Source/Assets/Music/*
include Source/Assets/Sounds/*
include Source/Assets/UI/*
What kind of file structure and build configuration do I need to get consistent file paths?