PyOxidizer
PyOxidizer copied to clipboard
PyOxidizer unable to build exectuables using pygame module
As per the title. I'd read good things about the speed of pyOxidiser executables vs PyInstaller so I thought it might make a good replacement when making game executables for distribution via platforms like steam.
Unfortunately, while I was able to build a basic python app following all the instructions, when I try including pygame in the toml file I get an error like this:
Collecting pygame
Downloading https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz (3.2MB)
ERROR: Command errored out with exit status 1:
command: 'C:\Users\USERNAME\Desktop\pyOxidizerTest\pygame_app\build\target\x86_64-pc-windows-msvc\debug\pyoxidizer\python.82ae15f31178\python\install\python.e
xe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\USERNAME\\AppData\\Local\\Temp\\pip-install-b2y0v2y4\\pygame\\setup.py'"'"'; __file__='"'"'
C:\\Users\\USERNAME\\AppData\\Local\\Temp\\pip-install-b2y0v2y4\\pygame\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"
'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: C:\Users\USERNAME\AppData\Local\Temp\pip-install-b2y0v2y4\pygame\
Complete output (17 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USERNAME\AppData\Local\Temp\pip-install-b2y0v2y4\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\USERNAME\AppData\Local\Temp\pip-install-b2y0v2y4\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\USERNAME\AppData\Local\Temp\pip-install-b2y0v2y4\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\USERNAME\AppData\Local\Temp\pip-install-b2y0v2y4\pygame\buildconfig\download_win_prebuilt.py", line 303, in ask
'\nDownload prebuilts to "%s" and copy to %s? [Y/n]' % (download_dir, dest_str))
EOFError: EOF when reading a line
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
thread 'main' panicked at 'error running pip', C:\Users\USERNAME\.cargo\registry\src\github.com-1ecc6299db9ec823\pyoxidizer-0.3.0\src\pyrepackager\packaging_rule.r
s:889:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
the lines I added to the auto generated .toml file:
[[packaging_rule]]
type = "pip-install-simple"
package = "pygame"
mode = "module"
module = "src.window_test.__main__"
And this was the simple program I was trying to package:
import pygame
class WindowTestApp:
def __init__(self):
pygame.init()
self.window_surface = pygame.display.set_mode((800, 600))
self.running = True
def run(self):
while self.running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running = False
pygame.display.flip()
if __name__ == "__main__":
app = WindowTestApp()
app.run()
Is chucking your program's python files into the generated src directory the intended path to packaging an application as I have done here? The 'getting started' documentation seems to focus on packaging a module downloaded from pypi which seems like a much rarer use case to my mind.
This appears to be a build-time error. I suspect it has more to do with PyOxidizer disabling the use of binary wheels and forcing your machine to build pygame from source, which likely has some complex build dependencies.
I suspect the easiest path forward is teaching PyOxidizer to work with compiled extension modules from wheels. This is easier said than done. But it is on my radar, as it would make a lot of packaging problems go away.
Is this case resolved with pygame ? I did not passed simple test. game was compiled, but no result/window.
Traceback (most recent call last):
File "runpy", line 196, in _run_module_as_main
File "runpy", line 86, in _run_code
File "main", line 3, in <module>
ModuleNotFoundError: No module named 'pygame'
Python 311