Skip to content

Commit a6efa7b

Browse files
authored
Refactor xdelta to C module (#65)
* initial c module setup * fix: builds * feat: add build instructions to build a c module * ci: checkout subprojects * fix: build issues on windows and mac x86 * ci: try using other python 3.10 * refactor: better reference counting * ci: change macos-13 to 15-intel * feat(xdelta): implement cache for source buffer lookups
1 parent f9b64d6 commit a6efa7b

File tree

13 files changed

+309
-363
lines changed

13 files changed

+309
-363
lines changed

.github/workflows/build.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-13, macos-15, windows-2025]
15+
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-15, windows-2025]
1616
runs-on: ${{ matrix.os }}
1717

1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
20+
with:
21+
submodules: 'true'
2022
- uses: actions/setup-python@v5
2123
with:
22-
python-version: "3.9"
24+
python-version: "3.10"
2325

2426
- name: Install pyinstaller and dependencies
2527
run: pip3 install --upgrade pyinstaller requests
2628

29+
- name: Build C module
30+
run: pip3 install -e .
31+
2732
- name: Set strip on Linux and Mac
2833
id: strip
2934
run: echo "option=--strip" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ build
22
dist
33
*.egg-info
44
*.spec
5-
__pycache__
5+
__pycache__
6+
env
7+
*.so
8+
*.dll

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "xdelta3"]
2+
path = xdelta3
3+
url = git@github.com:jmacd/xdelta.git
4+
branch = release3_0_apl

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ Heroic uses `$XDG_CONFIG_HOME/heroic/gog_store/auth.json`
2323

2424
Here is the command to pull the source code
2525

26-
```
26+
```bash
2727
git clone https://github.com/Heroic-Games-Launcher/heroic-gogdl
2828
cd heroic-gogdl
29-
./bin/gogdl --help
29+
python -m venv venv
30+
. venv/bin/activate
31+
pip install .
32+
gogdl --help
3033
```
3134

3235
If you have any questions ask on our [Discord](https://discord.com/invite/rHJ2uqdquK) or through GitHub issue
@@ -37,13 +40,14 @@ If you wish to test the gogdl in Heroic flatpak you likely need to build `gogdl`
3740

3841
- Get pyinstaller
3942

40-
```
43+
```bash
4144
pip install pyinstaller
4245
```
4346

4447
- Build the binary (assuming you are in heroic-gogdl direcory)
4548

46-
```
49+
```bash
50+
pip install -e . # Ensure you build the C code to python module
4751
pyinstaller --onefile --name gogdl gogdl/cli.py
4852
```
4953

bin/gogdl

Lines changed: 0 additions & 5 deletions
This file was deleted.

gogdl/dl/managers/task_executor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ def interrupt_shutdown(self):
535535
def shutdown(self):
536536
self.logger.debug("Stopping progressbar")
537537
self.progress.completed = True
538+
self.progress.join()
538539

539540
# Clear speed queues
540541
for q in [self.download_speed_updates, self.writer_speed_updates]:

gogdl/dl/workers/task_executor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from enum import Enum, auto
1818
from multiprocessing import Process, Queue
1919
from gogdl.dl.objects.generic import MemorySegment, TaskFlag, TerminateWorker
20-
from gogdl.xdelta import patcher
20+
import gogdl.xdelta3
2121

2222

2323
class FailReason(Enum):
@@ -357,8 +357,7 @@ def run(self):
357357
patch = os.path.join(task.destination, task.patch_file)
358358
patch = dl_utils.get_case_insensitive_name(patch)
359359
target = task_path
360-
361-
patcher.patch(source, patch, target, self.speed_queue)
360+
gogdl.xdelta3.patch(source, patch, target, self.speed_queue)
362361

363362
except Exception as e:
364363
print("Patch failed", e)

gogdl/xdelta/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

gogdl/xdelta/objects.py

Lines changed: 0 additions & 139 deletions
This file was deleted.

0 commit comments

Comments
 (0)