Skip to content

Incorporate Changes from SpotDraft Fork #4

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 3 commits into from
Apr 1, 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
8 changes: 8 additions & 0 deletions build_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def main():
print("Building for Windows...")
run_command('dotnet publish ./csproj -c Release -r win-x64 --self-contained')

# Build for macOS
print("Building for macOS...")
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/linux-x64-{version}.tar.gz")
Expand All @@ -60,6 +64,10 @@ def main():
windows_build_dir = './csproj/bin/Release/net8.0/win-x64'
compress_files(windows_build_dir, f"./dist/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/osx-x64-{version}.tar.gz")

print("Build and compression complete.")


Expand Down
Binary file modified dist/linux-x64-0.0.1.tar.gz
Binary file not shown.
Binary file added dist/osx-x64-0.0.1.tar.gz
Binary file not shown.
Binary file modified dist/win-x64-0.0.1.zip
Binary file not shown.
30 changes: 19 additions & 11 deletions src/python_redlines/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import platform
import zipfile
import tarfile
from pathlib import Path
from typing import Union, Tuple, Optional

Expand All @@ -28,24 +29,31 @@ def _unzip_binary(self):
arch = 'x64' # Assuming x64 architecture

if os_name == 'linux':
zip_name = f"linux-{arch}-{__version__}.zip"
binary_name = 'linux-64/redlines'
zip_name = f"linux-{arch}-{__version__}.tar.gz"
binary_name = 'linux-x64/redlines'
zip_path = os.path.join(binaries_path, zip_name)
if not os.path.exists(zip_path):
with tarfile.open(zip_path, 'r:gz') as tar_ref:
tar_ref.extractall(target_path)

elif os_name == 'windows':
zip_name = f"win-{arch}-{__version__}.zip"
binary_name = 'win-x64/redlines.exe'
zip_path = os.path.join(binaries_path, zip_name)
if not os.path.exists(zip_path):
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(target_path)

else:
raise EnvironmentError("Unsupported OS")

full_binary_path = os.path.join(target_path, binary_name)

if not os.path.exists(full_binary_path):

elif os_name == 'darwin':
zip_name = f"osx-{arch}-{__version__}.tar.gz"
binary_name = 'osx-x64/redlines'
zip_path = os.path.join(binaries_path, zip_name)
if not os.path.exists(zip_path):
with tarfile.open(zip_path, 'r:gz') as tar_ref:
tar_ref.extractall(target_path)

with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(target_path)
else:
raise EnvironmentError("Unsupported OS")

return os.path.join(target_path, binary_name)

Expand Down