I have a Linux machine (Parrot OS 4.9) where I am developing a project. I am working on the compiling part of it, and I want to use cx_Freeze
for that purpose.
I want to be able to compile both for Linux and for Windows, but I do not have a Windows machine, so I installed Python 3.7 (the python version that my project is written on) and tried to run the setup.py file.
When I do so, I get this output:
F:\Programming\Python\GameDev\VoidShips>python setup.py build
running build
running build_exe
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "setup.py", line 26, in <module>
executables=executables,
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\site-packages\cx_Freeze\di
st.py", line 342, in setup
distutils.core.setup(**attrs)
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\distutils\core.py", line 1
48, in setup
dist.run_commands()
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\distutils\dist.py", line 9
66, in run_commands
self.run_command(cmd)
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\distutils\dist.py", line 9
85, in run_command
cmd_obj.run()
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\distutils\command\build.py
", line 135, in run
self.run_command(cmd_name)
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\distutils\cmd.py", line 31
3, in run_command
self.distribution.run_command(command)
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\distutils\dist.py", line 9
85, in run_command
cmd_obj.run()
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\site-packages\cx_Freeze\di
st.py", line 217, in run
freezer.Freeze()
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\site-packages\cx_Freeze\fr
eezer.py", line 640, in Freeze
self._FreezeExecutable(executable)
File "C:\users\root\Local Settings\Application Data\Programs\Python\Python37\lib\site-packages\cx_Freeze\fr
eezer.py", line 199, in _FreezeExecutable
sourceDir = os.path.dirname(dependentFiles[0])
IndexError: list index out of range
However, if I try again from a real Windows machine, it compiles without problems.
This is my setup.py script:
from cx_Freeze import setup, Executable
import sys
version = "0.0.0.3"
modules = ["pygame", "noise", "random", "sys", "pytweening", "pickle"]
files = ["objects/", "scripts/", "textures/", "settings.py", "PhysicsEngine.py"]
outputdir = "C:\\VoidShips" if sys.platform == "win32" else "/home/kolterdyx/PythonBuilds/VoidBoats"
build_options = {
"packages": [],
"excludes": [],
"includes": modules,
"build_exe": outputdir,
"include_files": files,
}
base = "Win32GUI" if sys.platform == "win32" else None
executables = [Executable("main.py", base=base, targetName="VoidShips")]
setup(
name="Void Ships",
author="Kolterdyx",
version=version,
options={"build_exe": build_options},
executables=executables,
)
This is my project folder:
Project
- objects
- scripts
- textures
main.py
PhysicsEngine.py
settings.py
setup.py
Is there anything that I'm missing or doing wrong?