Skip to content

Commit 3998921

Browse files
authored
Merge pull request #9 from ross-mcnairn-dev/main
Add ARM support
2 parents a834070 + 10fa4f9 commit 3998921

File tree

4 files changed

+46
-30
lines changed

4 files changed

+46
-30
lines changed

build_differ.py

+34-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import re
21
import subprocess
32
import os
43
import tarfile
@@ -50,35 +49,56 @@ def cleanup_old_builds(dist_dir, current_version):
5049
os.remove(file_path)
5150
print(f"Deleted old build file: {file}")
5251

52+
5353
def main():
5454
version = get_version()
5555
print(f"Version: {version}")
5656

5757
dist_dir = "./src/python_redlines/dist/"
5858

59-
# Build for Linux
60-
print("Building for Linux...")
59+
# Build for Linux x64
60+
print("Building for Linux x64...")
6161
run_command('dotnet publish ./csproj -c Release -r linux-x64 --self-contained')
6262

63-
# Build for Windows
64-
print("Building for Windows...")
63+
# Build for Linux ARM64
64+
print("Building for Linux ARM64...")
65+
run_command('dotnet publish ./csproj -c Release -r linux-arm64 --self-contained')
66+
67+
# Build for Windows x64
68+
print("Building for Windows x64...")
6569
run_command('dotnet publish ./csproj -c Release -r win-x64 --self-contained')
6670

67-
# Build for macOS
68-
print("Building for macOS...")
71+
# Build for Windows ARM64
72+
print("Building for Windows ARM64...")
73+
run_command('dotnet publish ./csproj -c Release -r win-arm64 --self-contained')
74+
75+
# Build for macOS x64
76+
print("Building for macOS x64...")
6977
run_command('dotnet publish ./csproj -c Release -r osx-x64 --self-contained')
7078

71-
# Compress the Linux build
72-
linux_build_dir = './csproj/bin/Release/net8.0/linux-x64'
73-
compress_files(linux_build_dir, f"{dist_dir}/linux-x64-{version}.tar.gz")
79+
# Build for macOS ARM64
80+
print("Building for macOS ARM64...")
81+
run_command('dotnet publish ./csproj -c Release -r osx-arm64 --self-contained')
7482

75-
# Compress the Windows build
83+
# Compress the Linux x64 build
84+
linux_x64_build_dir = './csproj/bin/Release/net8.0/linux-x64'
85+
compress_files(linux_x64_build_dir, f"{dist_dir}/linux-x64-{version}.tar.gz")
86+
87+
# Compress the Linux ARM64 build
88+
linux_arm64_build_dir = './csproj/bin/Release/net8.0/linux-arm64'
89+
compress_files(linux_arm64_build_dir, f"{dist_dir}/linux-arm64-{version}.tar.gz")
90+
91+
# Compress the Windows x64 build
7692
windows_build_dir = './csproj/bin/Release/net8.0/win-x64'
7793
compress_files(windows_build_dir, f"{dist_dir}/win-x64-{version}.zip")
7894

79-
# Compress the macOS build
80-
macos_build_dir = './csproj/bin/Release/net8.0/osx-x64'
81-
compress_files(macos_build_dir, f"{dist_dir}/osx-x64-{version}.tar.gz")
95+
# Compress the macOS x64 build
96+
macos_x64_build_dir = './csproj/bin/Release/net8.0/osx-x64'
97+
compress_files(macos_x64_build_dir, f"{dist_dir}/osx-x64-{version}.tar.gz")
98+
99+
# Compress the macOS ARM64 build
100+
macos_arm64_build_dir = './csproj/bin/Release/net8.0/osx-arm64'
101+
compress_files(macos_arm64_build_dir, f"{dist_dir}/osx-arm64-{version}.tar.gz")
82102

83103
cleanup_old_builds(dist_dir, version)
84104

docs/developer-guide.md

-11
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,6 @@ dotnet publish -c Release -r osx-x64 --self-contained
9090
## Running Tests
9191

9292
To ensure everything is set up correctly and working as expected, run the tests included in the `tests/` directory.
93-
94-
### Step 1: Navigate to the Test Directory
95-
96-
Change to the `tests/` directory in your project:
97-
98-
```bash
99-
cd path/to/tests
100-
```
101-
102-
### Step 2: Run the Tests
103-
10493
Execute the tests using pytest:
10594

10695
```bash

docs/quickstart.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ with open('/path/to/modified.docx', 'rb') as f:
2828
modified_bytes = f.read()
2929

3030
# This is a tuple, bytes @ element 0
31-
output = wrapper.run_redlines('AuthorTag', original_bytes, modified_bytes)
31+
output = wrapper.run_redline('AuthorTag', original_bytes, modified_bytes)
3232
```
3333

3434
In both cases, `output` will contain the byte content of the resulting redline - a .docx with changes in tracked

src/python_redlines/engines.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,26 @@ def __get_binaries_info(self):
6464
zip_name: str - The name of the zip file
6565
"""
6666
os_name = platform.system().lower()
67-
arch = 'x64' # Assuming x64 architecture
67+
arch = platform.machine().lower()
68+
69+
if arch in ('x86_64', 'amd64'):
70+
arch = 'x64'
71+
elif arch in ('arm64', 'aarch64'):
72+
arch = 'arm64'
73+
else:
74+
raise EnvironmentError(f"Unsupported architecture: {arch}")
6875

6976
if os_name == 'linux':
7077
zip_name = f"linux-{arch}-{__version__}.tar.gz"
71-
binary_name = 'linux-x64/redlines'
78+
binary_name = f'linux-{arch}/redlines'
7279

7380
elif os_name == 'windows':
7481
zip_name = f"win-{arch}-{__version__}.zip"
75-
binary_name = 'win-x64/redlines.exe'
82+
binary_name = f'win-{arch}/redlines.exe'
7683

7784
elif os_name == 'darwin':
7885
zip_name = f"osx-{arch}-{__version__}.tar.gz"
79-
binary_name = 'osx-x64/redlines'
86+
binary_name = f'osx-{arch}/redlines'
8087

8188
else:
8289
raise EnvironmentError("Unsupported OS")

0 commit comments

Comments
 (0)