Packaging For a Distributable Version of a Application

Hi,

I am having a hard time packaging my game with “setuptools”. When I enter the command
"python3 setup.py bdist_apps" nothing happens, no errors, nothing. Following the manual. Pands3D says to type “python setup.py build_apps” and I am then hit with an error, setup.py: Can’t open file 'setup.py: [Errno 2] No such file or directory.

What am I doing wrong? Yes, I have the requirements.txt file, if wondering.

from setuptools import setup

setup(
    name = "Panda-chan and the Endless Horde",
    options = {
        "build_apps" : {
            # Files that we want to include. Specifically:
            #  * All of our image-files (.png)
            #  * All of our sound- and music-files (.ogg)
            #  * All of our text-files (.txt)
            #  * All of our 3D models (.egg)
            #    - These will be automatically converted
            #      to .bam files
            #  * And all of our font-files (in the "Font" folder)
            "include_patterns" : [
                "**/*.png",
                "**/*.ogg",
                "**/*.txt",
                "**/*.egg",
                "Fonts/*"
            ],
            # We want a gui-app, and our "main" Python file
            # is "Game.py"
            "gui_apps" : {
                "Panda-chan and the Endless Horde" : "Game.py"
            },
            # Plugins that we're using. Specifically,
            # we're using OpenGL and OpenAL audio
            "plugins" : [
                "pandagl",
                "p3openal_audio"
            ],
            # Platforms that we're building for.
            # Remove those that you don't want.
            "platforms" : [
                "macosx_10_6_x86_64",
                "win_amd64",
            ]
        }
    }
)

Obviously, you should go to the console directory where it is located setup.py, or run the console from the script folder. As an option to specify the full path to setup.py.

Everything is in one folder so I don’t know why it can’t find it.

Publish the directory path here, and also show what you enter in the console.

But are you running the terminal command from that folder? That is, when you run the command, is the terminal/console pointed at the folder that contains “setup.py”?

Hello again!

I apologize for the late reply. Here is what the terminal tells me in my ide when I enter the command.

Okay, and is “setup.py” in the folder “C:\Users\<your user name>”?

You see, as of that screenshot, the terminal is pointing at the above-mentioned directory. If your “setup.py” file isn’t in that directory, you might want to redirect the terminal to whatever directory it is found in.

So, let’s say that your game, along with the “setup.py” file, is located in “C:\Users\<user name>\MyGames\TheNameOfTheGame\”. In your terminal, presuming that you started in “C:\Users<user name>” as above, you’d enter the following:

cd MyGames\TheNameOfTheGame

This should point the terminal to the “TheNameOfTheGame” directory, being the location of the “setup.py” file, allowing you, hopefully, to run the setup procedure.

(As a convenience, I don’t know about Windows, but I know that in Ubuntu Linux–or at least my current version thereof–you can open a terminal directly to a given directory. This is done by opening the directory in the file manager, then right-clicking on some white-space and selecting “Open in terminal”. Perhaps there’s a similar option in Windows!)

I’m not sure why the terminal isn’t targeting my folder where I have my game located. I am using Microsoft visual studios and I will have to do some googling to figure out how to do it.

Thnk you for your help once again and the many times before that. I couldn’t have gone though without your help, thank you sir!

1 Like

For such purposes, it is better to use bat files, if run from the script folder.

D:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps
pause

To open the console from the script folder, first go to this folder and type cmd in the address bar. Alternatively, hold key the shift while in the script folder and open the console from the context menu.

2 Likes

When I type cmd and run Python.exe I am getting syntax errors when I try to load setup.py from my drive. I am a little confused about what I am supposed to do here. Am I suppose to type -D setup.py build_apps in the console?

What, precisely, is the command that you’re using, and from what directory are you calling it? And what errors are you getting, specifically?

Just a quick correction: serega’s command-line above uses “-E”, not “-D”. If you’ve been trying “-D”, then you may have been getting errors for that reason.

Then you need to use the path variable:

python3 -D setup.py build_apps

But you should note that this version of Python must be installed by Panda. Did you install Panda via Pip?

I installed panda from the website and not by pip. I didn’t know there was a difference. When I type this command in nothing happens, no errors. The terminal just returns blank. Do I have to uninstall and reinstall via pip?

Ok I will uninstall python and download it though panda.

No Pip has nothing to do with it. If you installed Panda as an SDK, this should work.

I opened the folder with asteroids, entered cmd in adress bar.

D:\Panda3D-1.10.7-x64\samples\asteroids>

Type the command.

D:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps

My console output before build.

D:\Panda3D-1.10.7-x64\samples\asteroids>D:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps

Just replace this address with your own with the installed Panda.

D:\Panda3D-1.10.7-x64\python\python.exe

You can also show the address of the example asteroids, then I can give the exact command.

You don’t actually need to delete the installed Python, the SDK version has its own copy. My example uses it. However, if you are using a common Python with VS, you must first install a Panda for it via pip to work.

I am using VS Code. I am able to run my game which is using panda with no problem. I went ahead and installed the new update without using pip. Along with the python. I see no issues loading the game.
This is the error I’m getting unless I am doing something wrong.

Do you see the difference or not ?

C:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps
C:\Panda3D-1.10.7-x64\python\python.exe setup.py build_apps

Or.

C:\Panda3D-1.10.7-x64\python\python.exe -C setup.py build_apps

Your version with the -C key doesn’t work for me either. Unknown parameter.

I repeat again, don’t try to use the IDE or anything. Use BAT file or the Console.

build.bat

C:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps
pause

You need to do this while in the game directory. Note that you are running this from Python, it doesn’t work that way.

How do I do this while in the game directory?

All right, repeat after me.

  1. Create a text file next to the game script.
  2. Rename it like this: build.bat
  3. Open and paste the text:
C:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps
pause
  1. Double-click the file, build.bat

Ohhh my gosh I am sorry I didn’t know that’s what you meant that’s what I had to do. I was totally off and confused. I apologize for not understanding what you were telling me to do before. This whole process of learning everything about python is hard sometimes especially when I can’t figure out what I am doing wrong. I appreciate your help and I will do what you have suggested and hope for the best.

If you use the console, then:

cd C:\Panda3D-1.10.7-x64\samples\asteroids

Then:

C:\Panda3D-1.10.7-x64\python\python.exe -E setup.py build_apps

1 Like