Closed jamesjsewell closed 5 years ago
I'm also interesting in knowing what the plans in the future will be for exporting a game made with Pyxel.
Yes, I'd like to export the games made with Pyxel too. Though I don't have concrete plan now. I'll think about it after implementing Pyxel Editor. Maybe the first target platforms are Windows, Mac, and Linux. I'm not sure Python code can be exported to mobile platforms or Web.
There is possibility of using brython to translate everything to JS and with some "maybe thin layer" run in browser.
Or the code can be freezed.
There should be definitely some support in pyxel, otherwise everybody is forced to do that on his own.
good point. I know in the blender game engine ( python on top of c ) you can target mac/linux/windows I'm sure there are some good compilers out there but I'd have to research it
What do you think about using PyInstaller?
It supports those three plataforms.
If you agree with this, I can implement this feature.
I think PyInstaller is fantastic! It can be a bit picky though when compiling things up, so we should communicate it as a convenience thing that people are expected to debug themselves rather than an official feature that we guarantee will work. The downside with any freezing method is the large output files and startup times.
The hard thing might be to ensure that glfw is available - no problem on windows, but osx and linux require a separate install? Not sure if pyinstaller can handle this.
PyInstaller sounds interesting. Thank you for information! If it can export Pyxel application to exe, I would like to add special shortcut command like "pyxelexporter". Anyway we need to check it works or not first.
This was just added to the wiki: Distributing Pyxel game
I'm having problems using PyInstaller with Pyxel.
When freezing a Pyxel project, I get the following warning:
WARNING: library glfw3.dll required via ctypes not found
I'm using Ubuntu 18.04.
I tried adding the binary for glfw with --add-binary
option, but the error persisted.
With this warning, the binary created doesn't open anything.
Yup, glfw is causing me issues on windows too. Pyinstaller builds correctly, but I get this error message when trying to run the file. I'm not building it with --windowed or --onefile yet until I can resolve the issue.
Traceback (most recent call last):
File "pong.py", line 13, in <module>
File "c:\users\mcrouche\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyxel\__init__.py", line 2, in <module>
File "c:\users\mcrouche\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyxel\constants.py", line 1, in <module>
File "c:\users\mcrouche\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\glfw\__init__.py", line 34, in <module>
ImportError: Failed to load GLFW3 shared library.
[13764] Failed to execute script pong
I've found a comment about glfw and pyinstaller in this repo where it mentions that something should be added to the spec file, but I have no idea what it means...
Pyinstaller does usually throw out warnings all over the place.
@timbledum As explained here, sometimes PyInstaller doesn't get a binary by default, I think this is the case with glfw. Then you can add it on your spec file
or directly on the command line.
I'm using Ubuntu 18.04 and I tried adding it with the following argument:
--add-binary '/usr/lib/x86_64-linux-gnu/libglfw.so.3.2:.'
Sadly it didn't work for me.
On Windows maybe you can change it to the path of your glfw dll file.
Thanks @marcelogdeandrade. I got a bit further on windows by adding the following to the spec file, but now getting a new error:
binaries=[('C:\\Users\\somepath\\glfw3.dll', '.')],
Traceback (most recent call last):
File "site-packages\sounddevice.py", line 71, in <module>
OSError: PortAudio library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pong.py", line 294, in <module>
File "pong.py", line 67, in __init__
File "site-packages\pyxel\__init__.py", line 153, in init
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\users\mcrouche\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyxel\app.py", line 13, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\users\mcrouche\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyxel\audio_player.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\users\mcrouche\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\sounddevice.py", line 83, in <module>
OSError: cannot load library 'C:\Users\mcrouche\cmder\pong\dist\pong\_sounddevice_data\portaudio-binaries\libportaudio32bit.dll': error 0x7e
[9128] Failed to execute script pong```
Anyone got any ideas on this one or experiencing the same issue?
@timbledum
I think this is related to the library libportaudio2
required on Debian, but I don't know the DLL name on Windows. Maybe this DLL should be added to the spec file aswell.
After read this thread, I also tried to find a way to export game made with pyxel :
No succes when i tried with pyinstaller as it has been already reported in this thread. I gave some tries with nuitka : Each time, once complied, the game stopped at start with this error :
Traceback (most recent call last):
File "../app.dist/app.py", line 21, in <module>
File "../app.dist/app.py", line 11, in __init__
File "../app.dist/pyxel/pyxel/__init__.py", line 296, in init
File "../app.dist/pyxel/pyxel/app.py", line 169, in __init__
File "../app.dist/pyxel/pyxel/renderer.py", line 38, in __init__
File "../app.dist/pyxel/pyxel/renderer.py", line 38, in <listcomp>
File "../app.dist/pyxel/pyxel/image.py", line 13, in __init__
File "../app.dist/pyxel/pyxel/gl_wrapper.py", line 116, in __init__
File "../app.dist/OpenGL/latebind.py", line 61, in __call__
File "../app.dist/OpenGL/GL/exceptional.py", line 178, in glGenTextures
File "../app.dist/OpenGL/latebind.py", line 45, in __call__
File "../app.dist/OpenGL/wrapper.py", line 654, in wrapperCall
File "../app.dist/OpenGL/wrapper.py", line 457, in calculate_cArgs
File "../app.dist/OpenGL/converters.py", line 252, in __call__
File "../app.dist/OpenGL/arrays/arraydatatype.py", line 149, in asArray
File "../app.dist/OpenGL/arrays/arraydatatype.py", line 51, in __call__
TypeError: ('No array-type handler for type ctypes.type (value: c_uint(0)) registered', 'Failure in cConverter <OpenGL.converters.SizedOutputOrInput object at 0x7f92d93ba9c8>', (1, c_uint(0)), 1, <OpenGL.platform.baseplatform.glGenTextures object at 0x7f92d9311748>)
Hope one day an easy way will exist to export. Thank you Kitao for this great python game engine. So fun to work with it.
Can anyone try to export the app with a new Pyxel which only depends on numpy?
Hey @kitao with which version of python are you working?
I tried with Python 3.7.0b5 64bit
py -m pip install pyxel --user
py -m pip install PyOpenGL-3.1.3b2-cp37-cp37m-win_amd64.whl PyOpenGL_accelerate-3.1.3b2-cp37-cp37m-win_amd64.whl --user
py -m pip install cx_Freeze-5.1.1-cp37-cp37m-win_amd64.whl --user
py setup.py build
It builds and runs successfully! I just had to move the assets into the correct folder and it's working with cx_Freeze.
Let's discuss about this enhancement in #154
this could be labeled as an enhancement. I don't see anywhere in the docs that talks about exporting your game and what platforms you can target?