Skip to content

Commit 98f67da

Browse files
committed
Refactor make-bindist script to generate tarballs on Unix
1 parent 0abe995 commit 98f67da

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

scripts/make-bindist

+12-13
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@ from pathlib import Path
44

55
import argparse
66
import platform
7+
import shutil
78
import subprocess
89
import zipfile
910

1011
ROOT_DIR = Path(__file__).resolve().parent.parent
1112

1213
def main():
1314
parser = argparse.ArgumentParser(description='Creates a binary distribution of the language server')
14-
parser.add_argument('-o', '--output', type=Path, default=ROOT_DIR / 'bindists' / f'curry-language-server-{platform.machine().lower()}-{platform.system().lower()}.zip', help='The name of the output zip.')
15+
parser.add_argument('-f', '--format', type=str, default='zip' if platform.system() == 'Windows' else 'gztar', help='The format of the output archive.')
16+
parser.add_argument('-o', '--output', type=Path, default=ROOT_DIR / 'bindists' / f'curry-language-server-{platform.machine().lower()}-{platform.system().lower()}', help='The name of the output archive.')
1517

1618
args = parser.parse_args()
17-
bin_dir = 'bin'
18-
output = args.output
19+
format: str = args.format
20+
output: Path = args.output
21+
22+
output.mkdir(parents=True, exist_ok=True)
1923

2024
print('==> Building...')
21-
subprocess.run(['stack', 'install', '--local-bin-path', bin_dir], check=True, cwd=ROOT_DIR)
25+
subprocess.run(['stack', 'install', '--local-bin-path', output / 'bin'], check=True, cwd=ROOT_DIR)
26+
27+
print('==> Packaging...')
28+
shutil.copy('LICENSE', output)
2229

2330
print('==> Archiving...')
24-
output.parent.mkdir(parents=True, exist_ok=True)
25-
with zipfile.ZipFile(output, mode='w') as zip:
26-
for f in [bin_dir, 'LICENSE']:
27-
path = ROOT_DIR / f
28-
if path.is_dir():
29-
for child in path.rglob('*'):
30-
zip.write(child, child.relative_to(ROOT_DIR))
31-
else:
32-
zip.write(path, path.relative_to(ROOT_DIR))
31+
shutil.make_archive(output, format, output.parent, output.name)
3332

3433
if __name__ == '__main__':
3534
main()

0 commit comments

Comments
 (0)