Ren'Py Renpy web application build fail - bad magic number

yozayozo

Newbie
Sep 14, 2021
18
2
Hello.
When I try to build web application of my renpy game, it always fails. I don't quite understand why.
What does bad magic number mean?
How can i fix this issue?

When I tried to build the tutorial game it passed smoothly

This is the build error traceback:

Code:
Initializing gl2 renderer:
primary display bounds: (0, 0, 2560, 1440)
swap interval: 1 frames
Windowed mode.
Vendor: 'NVIDIA Corporation'
Renderer: 'NVIDIA GeForce RTX 3090/PCIe/SSE2'
Version: '4.6.0 NVIDIA 496.49'
Display Info: None
Screen sizes: virtual=(800, 600) physical=(1076, 807) drawable=(1076, 807)
Maximum texture size: 4096x4096

Full traceback:
  File "launcher/game/web.rpyc", line 356, in script
  File "U:XXX\renpy-7.4.9-sdk/renpy/ast.py", line 928, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "U:XXX\renpy-7.4.9-sdk/renpy/python.py", line 2245, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/web.rpy", line 356, in <module>
  File "game/web.rpy", line 243, in build_web
  File "game/web.rpy", line 156, in repack_for_progressive_download
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/zipfile.py", line 793, in __init__
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/zipfile.py", line 862, in _RealGetContents
BadZipfile: Bad magic number for central directory

While running game code:
  File "game/web.rpy", line 356, in <module>
  File "game/web.rpy", line 243, in build_web
  File "game/web.rpy", line 156, in repack_for_progressive_download
BadZipfile: Bad magic number for central directory
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
What does bad magic number mean?
By default, tt's the file format signature ; the few first Bytes of the file that will tell which format is used by the content. And formats that have a complex structure also use them as signature for their different data blocks.

I don't remember well Zip format, but I assume that the "central directory" is the list of the files (with their significant information) stored in the archive. Therefore, it's a block that is easy to find, because it's always located at the same place ; like the summary of a book that is always at the start of the book after the title page, or at its end. Except that when Python's ZipFile module tried to proceed this block, it discovered that the signature of the block is not correct, what mean that the file is not a Zip file, corrupted, or use another version of the Zip format.


How can i fix this issue?
I'm tempted to say that you can't.
According to the traceback, the error happen at this line zin = zipfile.ZipFile(os.path.join(destination, 'game-old.zip')), therefore when trying to "extract" the content of an archive. This mean that, from the point of view of ZipFile, this is not a valid Zip archive, and there's not much you can do to change this.
 

yozayozo

Newbie
Sep 14, 2021
18
2
By default, tt's the file format signature ; the few first Bytes of the file that will tell which format is used by the content. And formats that have a complex structure also use them as signature for their different data blocks.

I don't remember well Zip format, but I assume that the "central directory" is the list of the files (with their significant information) stored in the archive. Therefore, it's a block that is easy to find, because it's always located at the same place ; like the summary of a book that is always at the start of the book after the title page, or at its end. Except that when Python's ZipFile module tried to proceed this block, it discovered that the signature of the block is not correct, what mean that the file is not a Zip file, corrupted, or use another version of the Zip format.




I'm tempted to say that you can't.
According to the traceback, the error happen at this line zin = zipfile.ZipFile(os.path.join(destination, 'game-old.zip')), therefore when trying to "extract" the content of an archive. This mean that, from the point of view of ZipFile, this is not a valid Zip archive, and there's not much you can do to change this.
Actually I did solve this somehow. It is an error that happens if a game is large like mine was (3.3 GB). After compressing the images and making the game take in total 1.9GB space, everything worked fine.

Sadly I do not have a detailed explanation as to why, but seems to be connected to the .zip file itself and its limitations. Zip file has maximum 4GB capacity, BUT when it reaches 2GB+ it is easily corruptable. Which is what presumably happened here
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
Sadly I do not have a detailed explanation as to why, but seems to be connected to the .zip file itself and its limitations. Zip file has maximum 4GB capacity, BUT when it reaches 2GB+ it is easily corruptable. Which is what presumably happened here
It's the 32 bits version of Zip that is limited to 4 GB, not the 64 bits one. And, since Ren'Py is already able to build distribution files that are way bigger than 4 GB, I guess that ZipFile module, that it use, can perfectly deal with the 64 bits format.