Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Build project with cxfreeze
#1
I'm trying to make and executable from a project I'm working on, to test it on a different computer, without requiring python installed.

I want to use cx freeze to build and exe file, and this is my project tree:

(I used the output markdown to be able to keep the indentation, but this is just a diagram)
Output:
- Project - objects blocks.py enemy.py item.py player.py __init__.py - scripts camera.py chunk_manager.py __init__.py - textures - items - player - terrain - UI - void index.py __init__.py main.py settings.py setup.py map.json
As you can probably tell, this is a game.

Anyways, what I have done is executing just cxfreeze main.py --target-dir=./ dist and it generated a build directory with a lot of stuff in it. It generated a linux executable, but thats fine, I want to test if I can make it python-independent first, and I'll solve the .exe part later.

So, I executed the file, and nothing happened. Then I tried running from the terminal and it said that it was missing the camera.py file. I went into the generated directory and I found out that cxfreeze had not copied that file. I tried moving in in there myself, but it did not work.

I started checking for other files, and I found out that only the textures had been copied. I thought this was just because of the one line command I used, so I am now trying to make a setup.py file (as you can see in the file tree) but I am lost in how to import my custom packages (objects, scripts, and textures) and the files in the same directory as main.py

This is how my setup.py file looks like:

import sys
from cx_Freeze import setup, Executable


options = {
    'build_exe': {
        'includes': ['camera', 'chunk_manager'], 'path': sys.path + ['scripts']
    }
}

setup(
    name = "Void Boats",
    version = "alpha0.1",
    options = options,
    executables = [Executable("main.py")])
I am not sure how would I put all the packages in the 'include' section, and I can't find anything on the internet that uses more than a simple file like helloworld.py, and the samples of cxfreeze on their github only show how to import files from one directory. Do I have to move everything into one single package and put all the files in the same 'include'? Or can I have one include for each package I have? Any help would be pretty much appreciated.
Reply
#2
cross-posted at Stackoverflow: https://stackoverflow.com/q/62373019/4046632
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I got an answer to this question on StackOverflow. You can check it out here
https://stackoverflow.com/a/62373116/13282963
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to build exe/deployable file from Python Project ShikhaJain 1 2,764 Jul-04-2019, 05:37 PM
Last Post: snippsat
  Standlone Tkinter cxFreeze stho 0 1,705 May-23-2018, 03:44 PM
Last Post: stho

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020