Skip to content

Commit

Permalink
switched windows build script to cx_freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
R3tr0BoiDX committed Oct 15, 2023
1 parent 62d5473 commit fb2ea45
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 45 deletions.
5 changes: 4 additions & 1 deletion build.linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# May need to install apt install python3-venv

# Remove previous build
echo "Removing previous build..."
rm -rf dist/

# Create a virtual environment
echo "Creating a virtual environment..."
python3 -m venv .venv
Expand All @@ -23,4 +27,3 @@ cp -r media dist/
# Zipping the dist folder
echo "Zipping the dist folder..."
zip -r dist/smwc-browser.linux.amd64.zip dist/

20 changes: 14 additions & 6 deletions build.windows.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# May need to run in order be be able to execute:
# Set-ExecutionPolicy RemoteSigned

# Remove previous build
Write-Host "Removing previous build..."
Remove-Item -Path ".\build" -Recurse -Force

# Create a virtual environment
Write-Host "Creating a virtual environment..."
python -m venv .venv
Expand All @@ -9,16 +13,20 @@ pip install -r requirements.txt -r requirements-dev.txt

# Build the project
Write-Host "Building the project..."
pyinstaller smwc-browser.spec
python .\setup.py build

# Get the build folder
Write-Host "Getting the build folder..."
$buildFolder = Get-ChildItem -Path ".\build\exe.win-amd64*" -Directory | Select-Object -First 1

# Copy the config file
Write-Host "Copying the config file..."
Copy-Item .\config.example.json .\dist\config.example.json
Copy-Item .\config.example.json $buildFolder\config.example.json

# Copy the media folder
Write-Host "Copying the media folder..."
Copy-Item .\media .\dist\media -Recurse
Copy-Item .\media $buildFolder\media -Recurse

# Zipping the dist folder
Write-Host "Zipping the dist folder..."
Compress-Archive -Path .\dist\ -DestinationPath .\dist\smwc-browser.windows.amd64.zip
# Zipping the build folder
Write-Host "Zipping the build folder..."
Get-ChildItem -Path $buildFolder\* | Compress-Archive -DestinationPath ".\build\smwc-browser.windows.amd64.zip"
60 changes: 22 additions & 38 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
import os

# from cx_Freeze import setup, Executable


def find_all_scripts(directory):
script_list = []
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(".py"):
script_list.append(os.path.relpath(os.path.join(root, file)))
return script_list


def parse_requirements(requirements_file):
with open(requirements_file, mode="r", encoding="utf-8") as file:
return [line.strip() for line in file]


all_scripts = find_all_scripts("source")
print(all_scripts)

required_modules = parse_requirements("requirements.txt")
print(required_modules)


# build_exe_options = {"packages": ["os"], "includes": ["tkinter"]}
# executables=[Executable("source/main.py", base=base)]

# setup(
# name="smwc-browser",
# version="1.0",
# description="A browser for SMW Central",
# executables=[Executable(script) for script in all_scripts],
# options={
# "build_exe": {
# "packages": required_modules,
# }
# },
# )
from cx_Freeze import setup, Executable

# todo: needs some fine tuning
build_exe_options = {
"excludes": [
"tkinter",
"unittest",
"asyncio",
"tk86t",
"tk8.6",
],
}

target = Executable(script="source/main.py", icon="resources\windows_icon.ico")

setup(
name="smwc-browser",
version="1.0",
description="A browser for SMW Central",
executables=[target],
options={"build_exe": build_exe_options},
)

0 comments on commit fb2ea45

Please sign in to comment.