Skip to content

Commit 055acbc

Browse files
committed
Update cx_Freeze example.
1 parent c7281c9 commit 055acbc

File tree

5 files changed

+74
-31
lines changed

5 files changed

+74
-31
lines changed

examples/distribution/cx_Freeze/README.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
cx_Freeze Example
22
=================
33

4-
First, install the packages: ``tdl`` and ``cx_Freeze``.
4+
It's recommended to use a virtual environment to package Python executables.
5+
Use the following guide on how to set one up:
6+
https://docs.python.org/3/tutorial/venv.html
57

6-
Then run the command::
8+
Once the virtual environment is active you should install `tcod` and `cx_Freeze` from the `requirements.txt` file, then build using `setup.py`:
79

8-
python setup.py build_exe
10+
pip install -r requirements.txt
11+
python setup.py build
912

1013
An executable package will be placed in ``build/<platform>/``
1114

examples/distribution/cx_Freeze/hello_world.py

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
import tcod
3+
4+
WIDTH, HEIGHT = 80, 60
5+
console = None
6+
7+
8+
def main():
9+
tileset = tcod.tileset.load_tilesheet(
10+
"data/terminal8x8_gs_ro.png", 16, 16, tcod.tileset.CHARMAP_CP437
11+
)
12+
with tcod.context.new(
13+
columns=WIDTH, rows=HEIGHT, tileset=tileset
14+
) as context:
15+
while True:
16+
console = tcod.console.Console(WIDTH, HEIGHT)
17+
console.print(0, 0, "Hello World")
18+
context.present(console)
19+
for event in tcod.event.wait():
20+
if isinstance(event, tcod.event.Quit):
21+
raise SystemExit()
22+
23+
24+
if __name__ == "__main__":
25+
main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tcod==12.0.0
2+
cx-freeze==6.5.3
Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
1-
1+
#!/usr/bin/env python3
22
import sys
33

44
from cx_Freeze import Executable, setup
55

6-
# cx_Freeze options, see documentation.
6+
# cx_Freeze options, see documentation:
7+
# https://cx-freeze.readthedocs.io/en/latest/distutils.html#build-exe
78
build_exe_options = {
8-
'packages': ['cffi'],
9-
'excludes': [],
10-
'include_files': ['data'],
11-
}
9+
"packages": [],
10+
"excludes": [
11+
"numpy.core.tests",
12+
"numpy.distutils",
13+
"numpy.doc",
14+
"numpy.f2py.tests",
15+
"numpy.lib.tests",
16+
"numpy.ma.tests",
17+
"numpy.ma.testutils",
18+
"numpy.matrixlib.tests",
19+
"numpy.polynomial.tests",
20+
"numpy.random.tests",
21+
"numpy.testing",
22+
"numpy.tests",
23+
"numpy.typing.tests",
24+
"distutils",
25+
"setuptools",
26+
"msilib",
27+
"test",
28+
"tkinter",
29+
"unittest",
30+
],
31+
"include_files": ["data"], # Bundle the data directory.
32+
"optimize": 1, # Enable release mode.
33+
"include_msvcr": False,
34+
}
1235

1336
# Hide the terminal on Windows apps.
1437
base = None
1538
if sys.platform == "win32":
1639
base = "Win32GUI"
1740

1841
setup(
19-
name='tdl cxfreeze example',
20-
options = {'build_exe': build_exe_options},
21-
executables = [Executable('hello_world.py', base=base)],
22-
)
42+
name="tcod cx_Freeze example",
43+
options={"build_exe": build_exe_options},
44+
executables=[
45+
# cx_Freeze Executable options:
46+
# https://cx-freeze.readthedocs.io/en/latest/distutils.html#cx-freeze-executable
47+
Executable(
48+
script="main.py",
49+
base=base,
50+
target_name="start", # Name of the target executable.
51+
)
52+
],
53+
)

0 commit comments

Comments
 (0)