Skip to content

Using sf.bat

Bradley Myers edited this page Feb 21, 2021 · 3 revisions

sf.bat is a file which has premade scripts in it to assist you with development. This is the equivalent of a Makefile.

All the commands documented here assume that you are in the root folder. To run a command outside of that folder, use path/to/sf.bat/file/sf command. The file will automatically correct the path so there is no difference as to where you run it from.

For more info on a script, click the appropriate link below.

Build

The build script runs the required pyinstaller command to build your app into an exe for distribution. It does not have any debug info attached to it and is intended for use for building the exe for distribution. For debug info and building for development and testing, look at devbuild.

Usage:

sf build

Overview:

Command part Action
pyinstaller Uses pyinstaller which is what builds our program into an exe.
"Server Forge/Main.py" Specifies what the main/entry file for our app is.
--name="ServerForge" Tells pyinstaller what to name the exe. If not specified, it would end up being Main because that is the entry file's name
--icon="Server Forge/assets/Favicon.ico" Tells pyinstaller to use that as the exe's icon. It will appear in the taskbar, and as the app's icon in file explorer.
--add-data "file/path;destination" Adds the specified path's contents to the destination. We use this to add our favicon and templates to an assets folder that is bundled into the exe.
--onefile Tells pyinstaller to make a single exe file instead of a folder full of dll files and other binaries.
--windowed Doesn't show a terminal when the exe is launched. Used frequently with GUI apps so that there isn't an unnecessary terminal.
--clean Tells pyinstaller to remove previous temporary files before compiling. Still a good idea to use clean before building.

Devbuild

The devbuild script runs the required pyinstaller command to build your app into an exe for development. It includes debug info to assist with development and is intended for use for building the exe for development purposes. To build the exe for distribution without unnecessary debug info, look at build.

Usage:

sf devbuild

Overview:

Command part Action
pyinstaller Uses pyinstaller which is what builds our program into an exe.
"Server Forge/Main.py" Specifies what the main/entry file for our app is.
--name="ServerForge" Tells pyinstaller what to name the exe. If not specified, it would end up being Main because that is the entry file's name
--icon="Server Forge/assets/Favicon.ico" Tells pyinstaller to use that as the exe's icon. It will appear in the taskbar, and as the app's icon in file explorer.
--add-data "file/path;destination" Adds the specified path's contents to the destination. We use this to add our favicon and templates to an assets folder that is bundled into the exe.
--onefile Tells pyinstaller to make a single exe file instead of a folder full of dll files and other binaries.
--windowed Doesn't show a terminal when the exe is launched. Used frequently with GUI apps so that there isn't an unnecessary terminal.
--debug=all Shows debug info for your application. Setting debug=all covers all the debug errors. For more info, click here.
--log-level=DEBUG Info level given in the console when the exe is being built. For more info, click here.
--clean Tells pyinstaller to remove previous temporary files before compiling. Still a good idea to use clean before building.

Clean

The clean script runs commands to delete folders and files created by pyinstaller. This command should be used before building to get rid of previous files which could break the build process.

Usage:

sf clean

Overview:

Command part Action
IF EXIST "build" ( RMDIR /S /Q "build" ) Checks if the build folder exists and deletes it if it does.
IF EXIST "dist" ( RMDIR /S /Q "dist" ) Checks if the dist folder exists and deletes it if it does.
IF EXIST "ServerForge.spec" ( DEL /Q "ServerForge.spec" ) Checks if the .spec file exists and deletes it if it does.
FOR /D /R . %%d IN ("*") DO ( IF EXIST "%%d*.pyo" ( DEL /Q "%%d*.pyo" ) ) Deletes all .pyo (compiled temporary python) files in the project.
FOR /D /R . %%d IN ("__pycache__") DO ( IF EXIST "%%d" ( RMDIR /S /Q "%%d" ) ) Deletes all __pycache__ folders in the project.

Clone this wiki locally