Skip to content

Commit 6e67f6e

Browse files
authored
Merge pull request #4 from SpotDraft/main
Incorporate Changes from SpotDraft Fork
2 parents c98e153 + 624990d commit 6e67f6e

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

build_differ.py

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def main():
5252
print("Building for Windows...")
5353
run_command('dotnet publish ./csproj -c Release -r win-x64 --self-contained')
5454

55+
# Build for macOS
56+
print("Building for macOS...")
57+
run_command('dotnet publish ./csproj -c Release -r osx-x64 --self-contained')
58+
5559
# Compress the Linux build
5660
linux_build_dir = './csproj/bin/Release/net8.0/linux-x64'
5761
compress_files(linux_build_dir, f"./dist/linux-x64-{version}.tar.gz")
@@ -60,6 +64,10 @@ def main():
6064
windows_build_dir = './csproj/bin/Release/net8.0/win-x64'
6165
compress_files(windows_build_dir, f"./dist/win-x64-{version}.zip")
6266

67+
# Compress the macOS build
68+
macos_build_dir = './csproj/bin/Release/net8.0/osx-x64'
69+
compress_files(macos_build_dir, f"./dist/osx-x64-{version}.tar.gz")
70+
6371
print("Build and compression complete.")
6472

6573

dist/linux-x64-0.0.1.tar.gz

-36.6 KB
Binary file not shown.

dist/osx-x64-0.0.1.tar.gz

64.7 MB
Binary file not shown.

dist/win-x64-0.0.1.zip

-36 KB
Binary file not shown.

src/python_redlines/engines.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import platform
55
import zipfile
6+
import tarfile
67
from pathlib import Path
78
from typing import Union, Tuple, Optional
89

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

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

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

38-
else:
39-
raise EnvironmentError("Unsupported OS")
40-
41-
full_binary_path = os.path.join(target_path, binary_name)
42-
43-
if not os.path.exists(full_binary_path):
44-
47+
elif os_name == 'darwin':
48+
zip_name = f"osx-{arch}-{__version__}.tar.gz"
49+
binary_name = 'osx-x64/redlines'
4550
zip_path = os.path.join(binaries_path, zip_name)
51+
if not os.path.exists(zip_path):
52+
with tarfile.open(zip_path, 'r:gz') as tar_ref:
53+
tar_ref.extractall(target_path)
4654

47-
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
48-
zip_ref.extractall(target_path)
55+
else:
56+
raise EnvironmentError("Unsupported OS")
4957

5058
return os.path.join(target_path, binary_name)
5159

0 commit comments

Comments
 (0)