#๐Ÿ”’ themes not loading when bundled

69 messages ยท Page 1 of 1 (latest)

dreamy tapir
#

Dunno why this won't work

balmy kilnBOT
#

@dreamy tapir

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dreamy tapir
pliant wind
#

where is the theme file relative to main.spec

dreamy tapir
#

Idk

#

I could show you where my themes are located tho

pliant wind
#

can you send the path for themes/ and show the spec file

dreamy tapir
#

"C:\Users\user\OneDrive\Generator Incremental Simulator\src\themes"

#
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas=[('src/themes/*.json', 'themes')],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='main',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
pliant wind
#

try removing the spaces in ur path. those are never good

dreamy tapir
#

wdym

pliant wind
#

"Generator incremental Simulator" will only give you issues in the future

#

some programs dont handle spaces in files well

#

dont think its related to this issue though since its not being used to get themes

#

ig it could be depending on how whatever you are using builds exes

dreamy tapir
#

I am using pyinstaller

pliant wind
#

have you tried manually adding the data

#

to see if that works

dreamy tapir
#

yes

pliant wind
#

what command did you do

dreamy tapir
#

the exact one you used

#

i also used --onefile and --noconsole dunno if there're related

pliant wind
#

when you have run pyinstaller did it make a themes folder at all

#

datas=[('src/themes/*.json', 'themes')],

makes a themes folder that puts all the json files

dreamy tapir
pliant wind
#

have you looked at the documentation for spec files?

dreamy tapir
#

yes and i don't understand a single thing

pliant wind
pliant wind
dreamy tapir
pliant wind
#

wym

#

thats an example

dreamy tapir
#

Exactly what i said

pliant wind
#

the same thing you did here
datas=[('src/themes/*.json', 'themes')],

#

the idea is that you take the example but change it up for your use

dreamy tapir
#

This is the path the game is looking for

manager.get_theme().load_theme("src/themes/main_menu_theme.json")
manager.get_theme().load_theme("src/themes/generator_menu_button_theme.json")manager.get_theme().load_theme("src/themes/main_menu_theme.json")
manager.get_theme().load_theme("src/themes/generator_menu_button_theme.json")
pliant wind
#

well the first thing you would look at is the path

#

obviously your path isnt /mygame/sfx/

#

its /src/themes/

#

you want json files so instead of looking for mp3 just change that to json

dreamy tapir
#

I did and it didn't work

pliant wind
#

i have a hunch its partially because you dont really understand how pyinstaller works

dreamy tapir
#

You think i would be here if i did

pliant wind
#

well sure you can understand something and ask for some help

#

but pastnig lines into your project hoping someone elses config works is a recipe for unmaintainable code

#

im not trying to be a dick or anything but i see it a lot

dreamy tapir
#

doesn't it copy to a folder called themes?

pliant wind
#

it should

#

is there a themes folder that pyinstaller created?

dreamy tapir
#

Idk where pyinstaller created it's files

#

I just know it creates a temporary folder when the executable is ran

pliant wind
#

try replacing
datas=[('src/themes/*.json', 'themes')],
with
datas=[('/src/themes/*.json', 'themes')],

#

their example has a / at the beginning of the path

dreamy tapir
#

No the first one was the correct path

#

Unable to find '\src\themes\*.json' when adding binary and data files.

pliant wind
#

try moving a theme file into the same directory as your spec file

#

so you can just put theme.json to load it

#

so we can see if its a path issue or something else

#

if it can find the json file in the same directory as it we can narrow the issue down to the path itself, not an issue on a larger scope

dreamy tapir
#

I moved the executable to the parent directory so i don't think it's a path issue since the app is literally running

dreamy tapir
#

@pliant wind Ok so the game is looking for json files at this location
manager.get_theme().load_theme("src/themes/main_menu_theme.json") src/themes which was making it ignore themes bc that's not the actual directory for the game. I just got what you said earlier.

pliant wind
#

ah

balmy kilnBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.