Use importlib resources for resource files to fix loading issues, fix nuitka build script

This commit is contained in:
csd4ni3l
2025-10-12 21:54:00 +02:00
parent a54810cea6
commit 5445b78c84
6 changed files with 21 additions and 10 deletions

View File

@@ -43,9 +43,9 @@ jobs:
run: | run: |
mkdir -p zip_output mkdir -p zip_output
if [ "${{ runner.os }}" = "Windows" ]; then if [ "${{ runner.os }}" = "Windows" ]; then
powershell.exe -Command "Compress-Archive -Path 'build/wizard_vs_irs.run.dist/*' -DestinationPath 'zip_output/WizardvsIRS-${{ runner.os }}.zip'" powershell.exe -Command "Compress-Archive -Path 'build/run.dist/*' -DestinationPath 'zip_output/WizardvsIRS-${{ runner.os }}.zip'"
else else
cd build/wizard_vs_irs.run.dist cd build/run.dist
zip -r "../../zip_output/WizardvsIRS-${{ runner.os }}.zip" . zip -r "../../zip_output/WizardvsIRS-${{ runner.os }}.zip" .
fi fi

3
MANIFEST.in Normal file
View File

@@ -0,0 +1,3 @@
include CREDITS
include LICENSE
recursive-include wizard_vs_irs/assets *

View File

@@ -21,3 +21,9 @@ wizard-vs-irs = "wizard_vs_irs.run:main"
[build-system] [build-system]
requires = ["setuptools>=61.0"] requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.setuptools]
include-package-data = true
[tool.setuptools.packages.find]
where = ["."]

2
uv.lock generated
View File

@@ -206,7 +206,7 @@ wheels = [
[[package]] [[package]]
name = "wizard-vs-irs" name = "wizard-vs-irs"
version = "0.1.1" version = "0.1.2"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "arcade" }, { name = "arcade" },

View File

@@ -12,7 +12,8 @@ def main():
sys.excepthook = on_exception sys.excepthook = on_exception
pyglet.resource.path.append(os.getcwd()) pyglet.resource.path.append(os.getcwd())
pyglet.font.add_directory('./assets/fonts') from importlib.resources import files
pyglet.font.add_directory(str(files("wizard_vs_irs") / "assets" / "fonts"))
if not log_dir in os.listdir(): if not log_dir in os.listdir():
os.makedirs(log_dir) os.makedirs(log_dir)

View File

@@ -1,15 +1,16 @@
import arcade.gui, arcade import arcade.gui, arcade
from importlib.resources import files
button_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button.png")) button_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture(str(files("wizard_vs_irs") / "assets" / "graphics" / "button.png")))
button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button_hovered.png")) button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture(str(files("wizard_vs_irs") / "assets" / "graphics" / "button_hovered.png")))
light_wizard_spritesheet = arcade.load_spritesheet("assets/graphics/mage-light.png").get_texture_grid((48, 64), 3, 12) light_wizard_spritesheet = arcade.load_spritesheet(str(files("wizard_vs_irs") / "assets" / "graphics" / "mage-light.png")).get_texture_grid((48, 64), 3, 12)
light_wizard_up_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[0:2]]) light_wizard_up_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[0:2]])
light_wizard_right_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[3:5]]) light_wizard_right_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[3:5]])
light_wizard_standing_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[6:8]]) light_wizard_standing_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[6:8]])
light_wizard_left_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[9:11]]) light_wizard_left_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in light_wizard_spritesheet[9:11]])
dark_wizard_spritesheet = arcade.load_spritesheet("assets/graphics/mage-dark.png").get_texture_grid((48, 64), 3, 12) dark_wizard_spritesheet = arcade.load_spritesheet(str(files("wizard_vs_irs") / "assets" / "graphics" / "mage-dark.png")).get_texture_grid((48, 64), 3, 12)
dark_wizard_up_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[0:2]]) dark_wizard_up_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[0:2]])
dark_wizard_right_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[3:5]]) dark_wizard_right_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[3:5]])
dark_wizard_standing_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[6:8]]) dark_wizard_standing_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[6:8]])
@@ -19,4 +20,4 @@ fireball_texture = arcade.make_circle_texture(10, arcade.color.RED)
lightning_bolt_texture = arcade.make_circle_texture(20, arcade.color.BLUE) lightning_bolt_texture = arcade.make_circle_texture(20, arcade.color.BLUE)
ice_blast_texture = arcade.make_circle_texture(20, arcade.color.ICEBERG) ice_blast_texture = arcade.make_circle_texture(20, arcade.color.ICEBERG)
irs_agent_texture = arcade.load_texture("assets/graphics/irs_agent.png") irs_agent_texture = arcade.load_texture(str(files("wizard_vs_irs") / "assets" / "graphics" / "irs_agent.png"))