Announcing AppGameKit for Python!

Started by MichaelUK, March 09, 2018, 18:32:36

Previous topic - Next topic

adambiser

Quote from: round157 on March 13, 2018, 01:13:09
Hi, I think that you need to promote this software in the Python community(or the Pygame community) if you want to succeed. Right? Otherwise, not too many Python users will know the existence of this software.
I know.  It's a matter of finding where Python game developers hang out.  I'm not active of any such forum, but I've found a couple places.

MikeHart

Don't forget facebook groups and twitter and don't forget the power of hashtags.

Rick Nasher

_______________________________________
B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

TomToad

Had a heck of a time trying to get Python up and running.  Seems I had an old version (2.7) already installed and it was conflicting with the required version (3.6).  Can't expect the end user to mess around with trying to install Python.  Is there a way to compile everything into an executable, or install a localized Python runtime that won't interfere with other versions?

B4J has B4J packager that will install java runtime locally, a minimal version of java that is used only for your program so it will not interfere with other installed versions.https://www.b4x.com/android/forum/threads/ui-apps-packaging-self-contained-installers.56854/
------------------------------------------------
8 rabbits equals 1 rabbyte.

adambiser

@MikeHart and Rick Nasher: Thanks.

@TomToad:Sorry you had trouble getting Python going, but glad to hear it's working now.

Yes, there is a pretty nice app packager called PyInstaller.  There may be others, but that's the only one I tested with this.  Others may or may not work.

PyInstaller uses a "spec" file which you can modify to set things like the game EXE icon.  It can generate the file for you or you can use this template to get started.


# -*- mode: python -*-

block_cipher = None


a = Analysis(['myscript.py'],
             pathex=['C:\\Path\\To\\Your\\Script'],
             binaries=[],
             datas=[('media', 'media')],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='myscript',
          debug=False,
          strip=False,
          upx=True,
          console=False,
          icon='youricon.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='myscript')

To use this template, change "myscript.py" to your main script file name, Analysis/pathex to your main script file's path, EXE/name to your output EXE name, EXE/icon to point to the icon file for your EXE, and COLLECT/name to be the output folder used when building the distribution package.  All files in the media folder are included (recursively) with this template.

Then generate your app package with "pyinstaller [options] spec-file-name.spec"

PyInstaller can package everything into a single folder or into a single file.  Though this PYD works with both methods, I recommend the former because when packaged as a single file, the contents are unpackaged into a temp folder when executing.  PyInstaller compiles your scripts into the EXE so they are not visible external files.

I'll post this as a topic on the project page community, too.

TomToad

Wow, took forever to figure out how to get PyInstaller working, but I finally did and successfully created an exe.  However, I did seem to get a few warnings.
This is my .spec file
# -*- mode: python -*-

block_cipher = None


a = Analysis(['box2d.py'],
             pathex=['C:\\Users\\James\\Projects\\AppGameKit\\python\\examples'],
             binaries=[],
             datas=[('media', 'media')],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='box2d',
          debug=False,
          strip=False,
          upx=True,
          console=False,
          icon='box2d.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='box2d')

This is the output from running PyInstaller
378 INFO: PyInstaller: 3.3.1
379 INFO: Python: 3.6.4
380 INFO: Platform: Windows-10-10.0.15063-SP0
383 INFO: UPX is not available.
388 INFO: Extending PYTHONPATH with paths
['C:\\Users\\James\\Projects\\AppGameKit\\python\\examples',
'C:\\Users\\James\\Projects\\AppGameKit\\python\\examples']
388 INFO: checking Analysis
389 INFO: Building Analysis because out00-Analysis.toc is non existent
389 INFO: Initializing module dependency graph...
395 INFO: Initializing module graph hooks...
401 INFO: Analyzing base_library.zip ...
10833 INFO: running Analysis out00-Analysis.toc
10840 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Users\James\AppData\Local\Programs\Python\Python36-32\python.exe
12811 WARNING: lib not found: api-ms-win-core-profile-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
12954 WARNING: lib not found: api-ms-win-core-memory-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13098 WARNING: lib not found: api-ms-win-core-timezone-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13240 WARNING: lib not found: api-ms-win-core-heap-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13384 WARNING: lib not found: api-ms-win-core-libraryloader-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13522 WARNING: lib not found: api-ms-win-core-string-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13662 WARNING: lib not found: api-ms-win-core-processthreads-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13801 WARNING: lib not found: api-ms-win-core-file-l1-2-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
13940 WARNING: lib not found: api-ms-win-core-namedpipe-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14079 WARNING: lib not found: api-ms-win-core-util-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14218 WARNING: lib not found: api-ms-win-core-synch-l1-2-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14361 WARNING: lib not found: api-ms-win-core-file-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14499 WARNING: lib not found: api-ms-win-core-interlocked-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14638 WARNING: lib not found: api-ms-win-core-console-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14776 WARNING: lib not found: api-ms-win-core-handle-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
14920 WARNING: lib not found: api-ms-win-core-file-l2-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15058 WARNING: lib not found: api-ms-win-core-localization-l1-2-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15196 WARNING: lib not found: api-ms-win-core-processthreads-l1-1-1.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15337 WARNING: lib not found: api-ms-win-core-datetime-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15474 WARNING: lib not found: api-ms-win-core-rtlsupport-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15611 WARNING: lib not found: api-ms-win-core-sysinfo-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15747 WARNING: lib not found: api-ms-win-core-synch-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
15887 WARNING: lib not found: api-ms-win-core-processenvironment-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
16029 WARNING: lib not found: api-ms-win-core-errorhandling-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
16168 WARNING: lib not found: api-ms-win-core-debug-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
16173 INFO: Caching module hooks...
16200 INFO: Analyzing box2d.py
16213 INFO: Loading module hooks...
16214 INFO: Loading module hook "hook-encodings.py"...
16465 INFO: Loading module hook "hook-pydoc.py"...
16468 INFO: Loading module hook "hook-xml.py"...
17361 INFO: Looking for ctypes DLLs
17362 INFO: Analyzing run-time hooks ...
17382 INFO: Looking for dynamic libraries
17800 INFO: Looking for eggs
17800 INFO: Using Python library C:\Users\James\AppData\Local\Programs\Python\Python36-32\python36.dll
17800 INFO: Found binding redirects:
[]
17808 INFO: Warnings written to C:\Users\James\Projects\AppGameKit\python\examples\build\box2d\warnbox2d.txt
17996 INFO: Graph cross-reference written to C:\Users\James\Projects\AppGameKit\python\examples\build\box2d\xref-box2d.html
18023 INFO: Appending 'datas' from .spec
18079 INFO: checking PYZ
18079 INFO: Building PYZ because out00-PYZ.toc is non existent
18079 INFO: Building PYZ (ZlibArchive) C:\Users\James\Projects\AppGameKit\python\examples\build\box2d\out00-PYZ.pyz
20418 INFO: Building PYZ (ZlibArchive) C:\Users\James\Projects\AppGameKit\python\examples\build\box2d\out00-PYZ.pyz completed successfully.
20445 INFO: checking PKG
20445 INFO: Building PKG because out00-PKG.toc is non existent
20445 INFO: Building PKG (CArchive) out00-PKG.pkg
20488 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
20492 INFO: Bootloader C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyinstaller-3.3.1-py3.6.egg\PyInstaller\bootloader\Windows-32bit\runw.exe
20492 INFO: checking EXE
20493 INFO: Building EXE because out00-EXE.toc is non existent
20493 INFO: Building EXE from out00-EXE.toc
20505 INFO: SRCPATH [('box2d.ico', None)]
20506 INFO: Updating icons from ['box2d.ico'] to C:\Users\James\AppData\Local\Temp\tmpqzpyvv20
20507 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
20507 INFO: Writing RT_ICON 1 resource with 67636 bytes
20516 INFO: Appending archive to EXE C:\Users\James\Projects\AppGameKit\python\examples\build\box2d\box2d.exe
20523 INFO: Building EXE from out00-EXE.toc completed successfully.
20534 INFO: checking COLLECT
20535 INFO: Building COLLECT because out00-COLLECT.toc is non existent
20536 INFO: Building COLLECT out00-COLLECT.toc
21966 INFO: Building COLLECT out00-COLLECT.toc completed successfully.

This is the warnbox2d.txt file
missing module named resource - imported by posix, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named posix - imported by os, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named _posixsubprocess - imported by subprocess, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named readline - imported by cmd, code, pdb, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
excluded module named _frozen_importlib - imported by importlib, importlib.abc, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named _winreg - imported by platform, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named _scproxy - imported by urllib.request
missing module named java - imported by platform, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named 'java.lang' - imported by platform, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py, xml.sax._exceptions
missing module named vms_lib - imported by platform, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named termios - imported by tty, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py, getpass
missing module named grp - imported by shutil, tarfile, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named _dummy_threading - imported by dummy_threading, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named org - imported by copy, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py
missing module named pwd - imported by posixpath, shutil, tarfile, http.server, webbrowser, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py, netrc, getpass
missing module named 'org.python' - imported by pickle, C:\Users\James\Projects\AppGameKit\python\examples\box2d.py, xml.sax

Any idea why I'm getting these errors?  Is it something that I can safely ignore?
------------------------------------------------
8 rabbits equals 1 rabbyte.

adambiser

Did you install PyInstaller using pip or some other way?

My warnings.txt file looks the same.  I assume as long as one doesn't use the modules that are being warning about, they can be ignored and nothing I've written has used them.

These warnings from the output starting with this line look suspicious.
WARNING: lib not found: api-ms-win-core-profile-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
Do you have a bunch of "api-ms-win-core-*.dll" files in your output folder?  (I do.)

Does the generated EXE run correctly?

TomToad

Quote from: adambiser on March 14, 2018, 17:14:26
Did you install PyInstaller using pip or some other way?
Tried using pip and that didn't work, then tried downloading the installer directly and installed it as per readme file
QuoteBefore using any contributed platform, you need to build the PyInstaller
bootloader, as we do not ship binary packages. Download PyInstaller
source, and build the bootloader::
     
        cd bootloader
        python ./waf distclean all

Then install PyInstaller::

        python setup.py install
After that failed, I searched some more and discovered that I needed to add a path to the Python\Scripts directory, which I did and then pip worked correctly, and PyInstaller installed with pip.  Don't know if the long way I did it had messed up anything.  Might just delete python and everything associated with it, then try starting over with installing.
Quote
My warnings.txt file looks the same.  I assume as long as one doesn't use the modules that are being warning about, they can be ignored and nothing I've written has used them.

These warnings from the output starting with this line look suspicious.
WARNING: lib not found: api-ms-win-core-profile-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
Do you have a bunch of "api-ms-win-core-*.dll" files in your output folder?  (I do.)
yes, 13 "api-*.dll" files to be exact.
Quote
Does the generated EXE run correctly?
The exe seems to run without problems.  Trying to test it out on another computer without Python, but I can't even get a tier 1 program to work.  Seems to be a driver issue.
------------------------------------------------
8 rabbits equals 1 rabbyte.

adambiser

To use pip, I've found it necessary to start the cmd command prompt with "Run as Admin", but it sounds like it worked for you in the end.

Since you say 13 files, I think those are "api-ms-win-crt-*.dll" files since I have 13 of those.  I have 25 of those with "core" in the name.
You might try a reinstall.  Try to get PyInstaller to work with pip running in an admin cmd prompt.  I don't remember doing anything with a "Python\Scripts" path, but I might be forgetting.  I'll have to try it with a fresh VM to see.

Do you get an error with the tier 1 program and this Python app on the other computer?
AppGameKit for Python still has the same DirectX requirements that AppGameKit tiers 1 and 2 have. (As an FYI for everyone.)

TomToad

I get OpenGL errors.  Can't remember the exact error, but something like OpenGLFrameEXT missing, and a bunch of other OpenGL*EXT missing errors before finally giving a "Your graphics card does not support the needed features, try updating your driver" error.
Also, I have  no core* .dlls installed.
------------------------------------------------
8 rabbits equals 1 rabbyte.

adambiser

What version of Windows are you using?

TomToad

Windows 10 Home.

Did a little search and it seems that Windows 10 has changed .dll dependencies, so PyInstaller cannot find the proper .dlls.  Not sure if that will be a problem, would have to test it on Win8 or Win7 computers to find out.
------------------------------------------------
8 rabbits equals 1 rabbyte.

TomToad

Some good news.  Finished installing new video drivers on my desktop and now the exe works.  Unfortunately, My desktop is also Windows 10, so still don;t know if the missing .dlls will affect the game on older systems or not.
------------------------------------------------
8 rabbits equals 1 rabbyte.

adambiser

I moved all of the api-ms-win dlls out of my dist folder and it still worked.  PyInstaller appears to be grabbing everything it could possibly need to run the DLLs on a clean Windows install.

It's possible that those files are installed via a C++ redistributable.  I won't have a chance to try things out until this evening.  I have a Windows 10 VM, so I'll start with it.

adambiser

OK. Most of the evening was spent waiting for my Windows 10 VM to update itself after not being turned on for awhile.

In the end, I tried out PyInstaller and didn't get ANY api-ms dll files and only had warnings about the crt files (not core for some reason).
It all centers around the Universal C Runtime, which is needed for C++ applications built with VS 2015 and 2017 and included with Windows 10 by default (without having those api-ms dll files as actual files, but more internalized which is why they aren't found).

This information is useful:
https://github.com/pyinstaller/pyinstaller/blob/develop/doc/usage.rst#windows
It depends on how you want to distribute things:
* If you want to be able to just zip up the folder and distribute, either option 1 or 3 seem best.
* If using an installer then option 2, which might be recommended anyway since AppGameKit requires the Jun2010_XAudio and Oct2005_xinput DirectX items be installed, too.