The best of both worlds: packaging python for the game

I am currently trying to package a game done with python and pygame and am having some problems.

I am using py2exe

for packaging and have looked at some questions here but I could not find a great solution. I want to get a folder containing exe

that I can compress and put on the internet. Running setup.py

works fine, except all dependencies are tied to library.zip

. This means that the program does not work at startup.

I found that someone else had this problem and they ended up using the option "skip archive = true"

to solve it. And although, yes, it works for me too. I was hoping there was a method that would still allow the program to run without problems, but would not clutter up the folder with countless files.

To be very precise, the problem I am facing is library.zip

:

ImportError: MemoryLoadLibrary failed loading pygame\mixer.pyd

      

Which, if I understand it correctly, means the program cannot reach / find the Pygame mixer module.

Here's the setup script I'm using (and it doesn't work):

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

data_files = [('resources', ['resources/step.wav',
                    'resources/wind2.wav',
                    'resources/The Steppes.ogg',
                    'resources/warrior3-nosword-notassle.png',
                    'resources/warrior3-sword.png',
                    'resources/warrior2-blood1.png',
                    'resources/warrior2-blood2.png',
                    'resources/warrior2-blood3.png',
                    'resources/warrior2-blood4.png',
                    'resources/warrior3-up.png',
                    'resources/warrior3-kneel.png',
                    'resources/warrior3-kneel-nosword.png',
                    'resources/warrior2-blood2-kneel.png',
                    'resources/warrior2-blood3-kneel.png',
                    'resources/warrior2-blood4-kneel.png',
                    'resources/warrior3-death.png',
                    'resources/warrior3-offarm.png',
                    'resources/menu1.png',
                    'resources/plains3-top-nomount.png',
                    'resources/mountains.png',
                    'resources/plains5-bottom.png',
                    'resources/plains3-bottom.png',
                    'resources/cloud1.png',
                    'resources/warrior2-sword.png',
                    'resources/warrior2-hand.png',
                    'resources/blue-tassle1.png',
                    'resources/blue-tassle2.png',
                    'resources/blue-tassle3.png',
                    'resources/blue-tassle4.png'])]

setup(options = {'py2exe': {"bundle_files": 1}},
    data_files = data_files,
    console = [{'script': "steppes2.0.py"}],
    zipfile = None
    )

      

+3


source to share


1 answer


This code in the setup.py file should do the trick when creating a single executable (you will still have to redistribute the msvc dlls separately)



from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(
      options = {'py2exe': {'bundle_files': 1}},
      console = [{'script': "myscript.py"}],
      zipfile = None,
)

      

+1


source







All Articles