Skip to content

Commit

Permalink
CI: Build executable for Windows/Linux with cx_Freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
lah7 committed Jun 2, 2024
1 parent 02c0c34 commit b297b87
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 25 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build

on: [push, pull_request]

jobs:
windows_x64:
name: Windows x64
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
architecture: 'x64'

- name: Cache Dependencies
uses: actions/cache@v4
with:
path: venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}

- name: Install Dependencies
run: |
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt
- name: Build
run: |
.\venv\Scripts\activate
python setup.py build
copy version.txt dist\
copy assets\github.url "dist\View on GitHub.url"
- name: Upload
uses: actions/upload-artifact@v4
with:
name: "build-windows-x64"
path: "dist"


linux_x64:
name: Linux x64
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
architecture: 'x64'

- name: Cache Dependencies
uses: actions/cache@v4
with:
path: venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}

- name: Install Dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- name: Build
run: |
source venv/bin/activate
python setup.py build
cp version.txt dist/
echo "https://github.com/lah7/sims2-4k-ui-patch" > "dist/View on GitHub.txt"
- name: Upload
uses: actions/upload-artifact@v4
with:
name: "build-linux-x64"
path: "dist"
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:
python-version: '3.12'
architecture: 'x64'

- name: Cache Python Environment
uses: actions/cache@v3
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-venv

- name: Install Dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__
/tests/files/ui.package
/build/
59 changes: 39 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,39 @@ The program automatically checks this repository for an update, to ensure you ha

### Windows

1. Download the latest version from the [Releases] page.
1. Download the latest `windows-x64` asset from the [Releases] page.
2. Extract the contents and run `sims2-4k-ui-patcher.exe`.
* You'll need to run as administrator to modify the game files.
* If you don't want to do that, change the permissions of your EA GAMES directory, usually at `C:\Program Files (x86)\EA GAMES`.
3. Click "Patch"!

To run the program, you may need to install [Microsoft Visual C++ Redistributable (x64)](https://aka.ms/vs/17/release/vc_redist.x64.exe).

### Linux/macOS (Wine/Proton)

[The Sims 2 is playable under Wine!] For the best patching performance,
run this patch program natively under Python.
### Linux

1. Download the [latest ZIP of this repository](https://github.com/lah7/sims2-4k-ui-patch/archive/refs/heads/master.zip).
For users who play The Sims 2 under the Wine/Proton compatibility layer. [It works well with DXVK!](https://github.com/lah7/sims2-wine-patches/blob/master/README-D9VK.md)

2. Extract the contents and run:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python sims2-4k-ui-patcher.py
1. Download the latest `linux-x64` asset from the [Releases] page.
2. Extract the contents and run `./sims2-4k-ui-patcher`.
* You may need to mark it as executable first (e.g. right click -> Properties -> Permissions tab).
3. Find your "EA GAMES" directory, e.g. a wine prefix at `~/.wine/drive_c/Program Files (x86)/EA GAMES`.
4. Click "Patch"!

Ironically, the patcher interface (built with TK) may not scale well on a 4K display.


### macOS

We don't have a pre-built binary for macOS, but you can run the Python script directly. See [Development](#development) for instructions.

This patch program will work fine if you play the game under a Wine compatibility layer.

If you purchased the [The Sims™ 2: Super Collection](https://apps.apple.com/us/app/the-sims-2-super-collection/id883782620?mt=12),
we don't know whether files are exposed in a way that is compatible with this program. Please let us know!


[Releases]: https://github.com/lah7/sims2-4k-ui-patch/releases/latest
[The Sims 2 is playable under Wine!]: https://github.com/lah7/sims-2-wine-patches


## Compatibility
Expand All @@ -84,26 +92,37 @@ this program. Using such mods may result in mixed UI scaling.
However, any existing UI modifications that were made in the game's installation
folder (like `TSData/Res/UI/ui.package`) are compatible with this program.

**On a Mac?** We don't know whether [The Sims™ 2: Super Collection](https://apps.apple.com/us/app/the-sims-2-super-collection/id883782620?mt=12)
is compatible with this program. Please let us know!


## Development

This project is written in Python. To start hacking, clone this repository
and set up a [virtual environment](https://docs.python.org/3/library/venv.html#creating-virtual-environments)
to install [requirements.txt](requirements.txt).
and set up a [virtual environment](https://docs.python.org/3/library/venv.html#creating-virtual-environments)
to install [requirements.txt](requirements.txt).

For Windows, [install Python], and run:
For Windows, [install Python 3](https://www.python.org/downloads/windows/), and run:

python -m venv venv
venv\Scripts\activate
pip install --upgrade pip
pip install -r requirements.txt
python sims2_4k_ui_patcher.py

For macOS/Linux instructions, [see above](#linuxmacos-wineproton).
For Linux, your distribution likely already has Python 3 installed:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
python3 sims2-4k-ui-patcher.py

For macOS, [install Python 3](https://www.python.org/downloads/macos/), and run:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
python3 sims2-4k-ui-patcher.py

[install Python]: https://www.python.org/downloads/windows/

### Tests

Expand Down
5 changes: 5 additions & 0 deletions assets/github.url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://github.com/lah7/sims2-4k-ui-patch
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Pillow
pyinstaller
requests

# Build only
cx_Freeze
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from cx_Freeze import Executable, setup

build_exe_options = {
"build_exe": "dist",
"excludes": ["unittest"],
"include_files": [
("assets/banner.png", "assets/banner.png"),
("assets/icon.ico", "assets/icon.ico"),
],
"optimize": "2",
}

setup(
name="sims2_4k_ui_patcher",
version="0.1.0",
description="4K UI Patcher for The Sims 2",
options={"build_exe": build_exe_options},
executables=[Executable("sims2_4k_ui_patcher.py", base="gui", icon="assets/icon")],
)

0 comments on commit b297b87

Please sign in to comment.