Skip to content

Add ARM support #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions build_differ.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
import subprocess
import os
import tarfile
Expand Down Expand Up @@ -50,35 +49,56 @@ def cleanup_old_builds(dist_dir, current_version):
os.remove(file_path)
print(f"Deleted old build file: {file}")


def main():
version = get_version()
print(f"Version: {version}")

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

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

# Build for Windows
print("Building for Windows...")
# Build for Linux ARM64
print("Building for Linux ARM64...")
run_command('dotnet publish ./csproj -c Release -r linux-arm64 --self-contained')

# Build for Windows x64
print("Building for Windows x64...")
run_command('dotnet publish ./csproj -c Release -r win-x64 --self-contained')

# Build for macOS
print("Building for macOS...")
# Build for Windows ARM64
print("Building for Windows ARM64...")
run_command('dotnet publish ./csproj -c Release -r win-arm64 --self-contained')

# Build for macOS x64
print("Building for macOS x64...")
run_command('dotnet publish ./csproj -c Release -r osx-x64 --self-contained')

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

# Compress the Windows build
# Compress the Linux x64 build
linux_x64_build_dir = './csproj/bin/Release/net8.0/linux-x64'
compress_files(linux_x64_build_dir, f"{dist_dir}/linux-x64-{version}.tar.gz")

# Compress the Linux ARM64 build
linux_arm64_build_dir = './csproj/bin/Release/net8.0/linux-arm64'
compress_files(linux_arm64_build_dir, f"{dist_dir}/linux-arm64-{version}.tar.gz")

# Compress the Windows x64 build
windows_build_dir = './csproj/bin/Release/net8.0/win-x64'
compress_files(windows_build_dir, f"{dist_dir}/win-x64-{version}.zip")

# Compress the macOS build
macos_build_dir = './csproj/bin/Release/net8.0/osx-x64'
compress_files(macos_build_dir, f"{dist_dir}/osx-x64-{version}.tar.gz")
# Compress the macOS x64 build
macos_x64_build_dir = './csproj/bin/Release/net8.0/osx-x64'
compress_files(macos_x64_build_dir, f"{dist_dir}/osx-x64-{version}.tar.gz")

# Compress the macOS ARM64 build
macos_arm64_build_dir = './csproj/bin/Release/net8.0/osx-arm64'
compress_files(macos_arm64_build_dir, f"{dist_dir}/osx-arm64-{version}.tar.gz")

cleanup_old_builds(dist_dir, version)

Expand Down
11 changes: 0 additions & 11 deletions docs/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,6 @@ dotnet publish -c Release -r osx-x64 --self-contained
## Running Tests

To ensure everything is set up correctly and working as expected, run the tests included in the `tests/` directory.

### Step 1: Navigate to the Test Directory

Change to the `tests/` directory in your project:

```bash
cd path/to/tests
```

### Step 2: Run the Tests

Execute the tests using pytest:

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ with open('/path/to/modified.docx', 'rb') as f:
modified_bytes = f.read()

# This is a tuple, bytes @ element 0
output = wrapper.run_redlines('AuthorTag', original_bytes, modified_bytes)
output = wrapper.run_redline('AuthorTag', original_bytes, modified_bytes)
```

In both cases, `output` will contain the byte content of the resulting redline - a .docx with changes in tracked
Expand Down
15 changes: 11 additions & 4 deletions src/python_redlines/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,26 @@ def __get_binaries_info(self):
zip_name: str - The name of the zip file
"""
os_name = platform.system().lower()
arch = 'x64' # Assuming x64 architecture
arch = platform.machine().lower()

if arch in ('x86_64', 'amd64'):
arch = 'x64'
elif arch in ('arm64', 'aarch64'):
arch = 'arm64'
else:
raise EnvironmentError(f"Unsupported architecture: {arch}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can fallback to x64 if you prefer


if os_name == 'linux':
zip_name = f"linux-{arch}-{__version__}.tar.gz"
binary_name = 'linux-x64/redlines'
binary_name = f'linux-{arch}/redlines'

elif os_name == 'windows':
zip_name = f"win-{arch}-{__version__}.zip"
binary_name = 'win-x64/redlines.exe'
binary_name = f'win-{arch}/redlines.exe'

elif os_name == 'darwin':
zip_name = f"osx-{arch}-{__version__}.tar.gz"
binary_name = 'osx-x64/redlines'
binary_name = f'osx-{arch}/redlines'

else:
raise EnvironmentError("Unsupported OS")
Expand Down