Skip to content

Commit

Permalink
Further reduced app size, zip is now 4.6MB
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrethiault committed Dec 26, 2020
1 parent 79dc187 commit 9081b1d
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 106 deletions.
Binary file modified Nurikabe.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nurikabe
A simple pygame implementation for the Nurikabe grid game provided with a setup.py file to build a standalone Windows 10 exe app with cx_Freeze, and a 5.4 MB zip of a pre-built version.
A simple pygame implementation for the Nurikabe grid game provided with a setup.py file to build a standalone Windows 10 exe app with cx_Freeze, and a 4.6 MB zip of a pre-built version.

## Play the game by executing Nurikabe.py

Expand All @@ -15,4 +15,4 @@ Install the cx_Freeze module with ´pip install cx_Freeze´ and execute the ´py

The remaining installation step doesn't require having a Python environment on your computer as a .msi installer is by nature already standalone.

Simply double click the .msi installer and follow the instructions to install a standalone .exe app. Once this step is completed, only if the .msi installer was created with the pygame version being at least 2.0, double click ´cleanup.bat´ which came next to ´Nurikabe.exe´ (or ´cleanup.sh´ if you prefer). This will remove a lot of unnecessary files and modules that cx_Freeze added, representing two thirds of the total size of the app. The remaining files should be exactly those included in ´Nurikabe.zip´ from this repository, the difference being that simply unzipping it does not create a desktop shortcut
Simply double click the .msi installer and follow the instructions to install a standalone .exe app. Once this step is completed, go to the folder where it has been installed (the default is ´C:/Users/[you]/AppData/Programs/Nurikabe´). If you see a ´cleanup.bat´ next to ´Nurikabe.exe´ (it will only be there if the .msi installer was created with the pygame version being at least 2.0, don't try to add it manually if it's not there), double click it (or ´cleanup.sh´ if you prefer). This will remove a lot of unnecessary files and modules that cx_Freeze added, representing 70%+ of the total size of the app. The remaining files should be exactly those included in ´Nurikabe.zip´ from this repository, the difference being that simply unzipping it does not create a desktop shortcut.
100 changes: 49 additions & 51 deletions cleanup.bat
Original file line number Diff line number Diff line change
@@ -1,85 +1,83 @@
REM These are unneccesary files automatically included when installing the application (sorry, couldn't find a way to avoid including them) which you can remove safely. Running this script should reduce the size of the application significantly.
REM DON'T RUN THIS IF THE APPLICATION WAS BUILT USING A VERSION OF PYGAME THAT IS NOT AT LEAST 2.0.

@echo off

del python3.dll 2>NUL
del api-ms-win-crt-conio-l1-1-0.dll 2>NUL
del api-ms-win-crt-convert-l1-1-0.dll 2>NUL
del api-ms-win-crt-environment-l1-1-0.dll 2>NUL
del api-ms-win-crt-filesystem-l1-1-0.dll 2>NUL
del api-ms-win-crt-heap-l1-1-0.dll 2>NUL
del api-ms-win-crt-locale-l1-1-0.dll 2>NUL
del api-ms-win-crt-math-l1-1-0.dll 2>NUL
del api-ms-win-crt-process-l1-1-0.dll 2>NUL
del api-ms-win-crt-runtime-l1-1-0.dll 2>NUL
del api-ms-win-crt-stdio-l1-1-0.dll 2>NUL
del api-ms-win-crt-string-l1-1-0.dll 2>NUL
del api-ms-win-crt-time-l1-1-0.dll 2>NUL
del api-ms-win-crt-*.dll 2>NUL

del lib\python37.dll 2>NUL
del lib\python38.dll 2>NUL
del lib\python3*.dll 2>NUL
del lib\unicodedata.pyd 2>NUL
del lib\vcruntime140.dll 2>NUL
del lib\api-ms-win-crt-conio-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-convert-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-environment-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-filesystem-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-heap-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-locale-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-math-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-process-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-runtime-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-stdio-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-string-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-time-l1-1-0.dll 2>NUL
del lib\api-ms-win-crt-utility-l1-1-0.dll 2>NUL
del lib\pywintypes37.dll 2>NUL
del lib\pywintypes38.dll 2>NUL

rd /s /q lib\xml 2>NUL
del lib\api-ms-win-crt-*.dll 2>NUL
del lib\pywintypes3*.dll 2>NUL
del lib\_bz2.pyd 2>NUL
del lib\_ctypes_test.pyd 2>NUL
del lib\_hashlib.pyd 2>NUL
del lib\_lzma.pyd 2>NUL
del lib\_queue.pyd 2>NUL
del lib\_socket.pyd 2>NUL
del lib\_testbuffer.pyd 2>NUL
del lib\_testcapi.pyd 2>NUL
del lib\_win32sysloader.pyd 2>NUL
del lib\select.pyd 2>NUL
del lib\win32api.pyd 2>NUL
del lib\win32file.pyd 2>NUL
del lib\win32pipe.pyd 2>NUL

rd /s /q lib\ctypes\test 2>NUL
rd /s /q lib\ctypes\macholib 2>NUL
del lib\ctypes\_aix.pyc 2>NUL
del lib\ctypes\util.pyc 2>NUL
del lib\ctypes\wintypes.pyc 2>NUL

REM Remove every codec or file supplied in lib/encodings except the 5 that are actually used
mkdir lib\tmp 2>NUL
move lib\encodings\__init__.pyc lib\tmp 2>NUL
move lib\encodings\aliases.pyc lib\tmp 2>NUL
move lib\encodings\latin_1.pyc lib\tmp 2>NUL
move lib\encodings\mbcs.pyc lib\tmp 2>NUL
move lib\encodings\utf_8.pyc lib\tmp 2>NUL
rd /s /q lib\encodings 2>NUL
move lib/tmp lib\encodings 2>NUL

del lib\importlib\metadata.pyc 2>NUL
del lib\importlib\_bootstrap.pyc 2>NUL
del lib\importlib\_bootstrap_external.pyc 2>NUL

rd /s /q lib\pygame\__pyinstaller 2>NUL
rd /s /q lib\pygame\_sdl2 2>NUL
rd /s /q lib\pygame\docs 2>NUL
rd /s /q lib\pygame\examples 2>NUL
rd /s /q lib\pygame\tests 2>NUL
rd /s /q lib\pygame\threads 2>NUL
del lib\pygame\python37.dll 2>NUL
del lib\pygame\python38.dll 2>NUL
del lib\pygame\_sprite.cp37-win_amd64.pyd 2>NUL
del lib\pygame\_sprite.cp38-win_amd64.pyd 2>NUL
del lib\pygame\api-ms-win-crt-conio-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-convert-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-environment-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-filesystem-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-heap-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-locale-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-math-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-process-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-runtime-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-stdio-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-string-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-time-l1-1-0.dll 2>NUL
del lib\pygame\api-ms-win-crt-utility-l1-1-0.dll 2>NUL
del lib\pygame\python3*.dll 2>NUL
del lib\pygame\api-ms-win-crt-*.dll 2>NUL
del lib\pygame\libwebp-7.dll 2>NUL
del lib\pygame\libFLAC-8.dll 2>NUL
del lib\pygame\libtiff-5.dll 2>NUL
del lib\pygame\libmpg123-0.dll 2>NUL
del lib\pygame\libmodplug-1.dll 2>NUL
del lib\pygame\libvorbis-0.dll 2>NUL
del lib\pygame\pygame.ico 2>NUL
del lib\pygame\libopus-0.dll 2>NUL
del lib\pygame\sdl2_mixer.dll 2>NUL
del lib\pygame\freesansbold.ttf 2>NUL
del lib\pygame\libvorbisfile-3.dll 2>NUL
del lib\pygame\libogg-0.dll 2>NUL
del lib\pygame\libopusfile-0.dll 2>NUL
del lib\pygame\portmidi.dll 2>NUL
del lib\pygame\pygame.ico 2>NUL
del lib\pygame\pygame_icon.icns 2>NUL
del lib\pygame\pygame_icon.svg 2>NUL
del lib\pygame\pygame_icon.bmp 2>NUL
del lib\pygame\pygame_icon.tiff 2>NUL
del lib\pygame\freesansbold.ttf 2>NUL
del lib\pygame\sprite.pyc 2>NUL
del lib\pygame\_camera*.pyc 2>NUL
del lib\pygame\_dummy*.pyc 2>NUL
del lib\pygame\_numpy*.pyc 2>NUL
del lib\pygame\_sprite.*.pyd 2>NUL
del lib\pygame\_freetype.*.pyd 2>NUL
del lib\pygame\*.pyi 2>NUL

del cleanup.sh 2>NUL
del cleanup.bat 2>NUL
del cleanup.bat 2>NUL
100 changes: 49 additions & 51 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,83 +1,81 @@
# These are unneccesary files automatically included when installing the application (sorry, couldn't find a way to avoid including them) which you can remove safely. Running this script should reduce the size of the application significantly.
# DON'T RUN THIS IF THE APPLICATION WAS BUILT USING A VERSION OF PYGAME THAT IS NOT AT LEAST 2.0.

rm python3.dll
rm api-ms-win-crt-conio-l1-1-0.dll
rm api-ms-win-crt-convert-l1-1-0.dll
rm api-ms-win-crt-environment-l1-1-0.dll
rm api-ms-win-crt-filesystem-l1-1-0.dll
rm api-ms-win-crt-heap-l1-1-0.dll
rm api-ms-win-crt-locale-l1-1-0.dll
rm api-ms-win-crt-math-l1-1-0.dll
rm api-ms-win-crt-process-l1-1-0.dll
rm api-ms-win-crt-runtime-l1-1-0.dll
rm api-ms-win-crt-stdio-l1-1-0.dll
rm api-ms-win-crt-string-l1-1-0.dll
rm api-ms-win-crt-time-l1-1-0.dll
rm api-ms-win-crt-*.dll

rm lib/python37.dll
rm lib/python38.dll
rm lib/python3*.dll
rm lib/unicodedata.pyd
rm lib/vcruntime140.dll
rm lib/api-ms-win-crt-conio-l1-1-0.dll
rm lib/api-ms-win-crt-convert-l1-1-0.dll
rm lib/api-ms-win-crt-environment-l1-1-0.dll
rm lib/api-ms-win-crt-filesystem-l1-1-0.dll
rm lib/api-ms-win-crt-heap-l1-1-0.dll
rm lib/api-ms-win-crt-locale-l1-1-0.dll
rm lib/api-ms-win-crt-math-l1-1-0.dll
rm lib/api-ms-win-crt-process-l1-1-0.dll
rm lib/api-ms-win-crt-runtime-l1-1-0.dll
rm lib/api-ms-win-crt-stdio-l1-1-0.dll
rm lib/api-ms-win-crt-string-l1-1-0.dll
rm lib/api-ms-win-crt-time-l1-1-0.dll
rm lib/api-ms-win-crt-utility-l1-1-0.dll
rm lib/pywintypes37.dll
rm lib/pywintypes38.dll

rm -r lib/xml
rm lib/api-ms-win-crt-*.dll
rm lib/pywintypes3*.dll
rm lib/_bz2.pyd
rm lib/_ctypes_test.pyd
rm lib/_hashlib.pyd
rm lib/_lzma.pyd
rm lib/_queue.pyd
rm lib/_socket.pyd
rm lib/_testbuffer.pyd
rm lib/_testcapi.pyd
rm lib/_win32sysloader.pyd
rm lib/select.pyd
rm lib/win32api.pyd
rm lib/win32file.pyd
rm lib/win32pipe.pyd

rm -r lib/ctypes/test
rm -r lib/ctypes/macholib
rm lib/ctypes/_aix.pyc
rm lib/ctypes/util.pyc
rm lib/ctypes/wintypes.pyc

# Remove every codec or file supplied in lib/encodings except the 5 that are actually used
mkdir lib/tmp
mv lib/encodings/__init__.pyc lib/tmp
mv lib/encodings/aliases.pyc lib/tmp
mv lib/encodings/latin_1.pyc lib/tmp
mv lib/encodings/mbcs.pyc lib/tmp
mv lib/encodings/utf_8.pyc lib/tmp
rm -r lib/encodings
mv lib/tmp lib/encodings

rm lib/importlib/metadata.pyc
rm lib/importlib/_bootstrap.pyc
rm lib/importlib/_bootstrap_external.pyc

rm -r lib/pygame/__pyinstaller
rm -r lib/pygame/_sdl2
rm -r lib/pygame/docs
rm -r lib/pygame/examples
rm -r lib/pygame/tests
rm -r lib/pygame/threads
rm lib/pygame/python37.dll
rm lib/pygame/python38.dll
rm lib/pygame/_sprite.cp37-win_amd64.pyd
rm lib/pygame/_sprite.cp38-win_amd64.pyd
rm lib/pygame/api-ms-win-crt-conio-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-convert-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-environment-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-filesystem-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-heap-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-locale-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-math-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-process-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-runtime-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-stdio-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-string-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-time-l1-1-0.dll
rm lib/pygame/api-ms-win-crt-utility-l1-1-0.dll
rm lib/pygame/python3*.dll
rm lib/pygame/api-ms-win-crt-*.dll
rm lib/pygame/libwebp-7.dll
rm lib/pygame/libFLAC-8.dll
rm lib/pygame/libtiff-5.dll
rm lib/pygame/libmpg123-0.dll
rm lib/pygame/libmodplug-1.dll
rm lib/pygame/libvorbis-0.dll
rm lib/pygame/pygame.ico
rm lib/pygame/libopus-0.dll
rm lib/pygame/sdl2_mixer.dll
rm lib/pygame/freesansbold.ttf
rm lib/pygame/libvorbisfile-3.dll
rm lib/pygame/libogg-0.dll
rm lib/pygame/libopusfile-0.dll
rm lib/pygame/portmidi.dll
rm lib/pygame/pygame.ico
rm lib/pygame/pygame_icon.icns
rm lib/pygame/pygame_icon.svg
rm lib/pygame/pygame_icon.bmp
rm lib/pygame/pygame_icon.tiff
rm lib/pygame/freesansbold.ttf
rm lib/pygame/sprite.pyc
rm lib/pygame/_camera*.pyc
rm lib/pygame/_dummy*.pyc
rm lib/pygame/_numpy*.pyc
rm lib/pygame/_sprite.*.pyd
rm lib/pygame/_freetype.*.pyd
rm lib/pygame/*.pyi

rm cleanup.bat
rm cleanup.sh
rm cleanup.sh
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@

excludes = ["babel", "cryptography", "Cython", "distutils", "docutils", "IPython", "jedi", "llvmlite", "lxml", "markupsafe", "matplotlib", "mkl", "nbconvert", "numba", "numpy", "PIL", "prompt_toolkit", "psutil", "PyQt5", "pytest", "pytz", "scipy", "sphinx", "tkinter", "tornado", "win32com", "zmq", "email", "html", "http", "logging", "pkg_resources", "pydoc_data", "pyreadline", "test", "unittest", "urllib", "xml"]

if pygame.__version__ < "2":
include_files = ["Icones", "Grilles"] + incl_dlls
else:
include_files = ["cleanup.bat", "cleanup.sh", "Icones", "Grilles"] + incl_dlls

base = None
if sys.platform == "win32":
base = "Win32GUI"
Expand All @@ -41,7 +46,7 @@
{
"packages": ["pygame", "ctypes"],
"excludes": excludes,
"include_files": ["cleanup.bat", "cleanup.sh", "Icones", "Grilles"] + incl_dlls
"include_files": include_files
},
"bdist_msi":
{
Expand All @@ -61,4 +66,4 @@
)

# python setup.py build -> exe
# python setup.py bdist_msi -> msi and exe
# python setup.py bdist_msi -> msi and exe

0 comments on commit 9081b1d

Please sign in to comment.