-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathfix_pkg.py
More file actions
16 lines (16 loc) · 773 Bytes
/
fix_pkg.py
File metadata and controls
16 lines (16 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pkg = '/mnt/c/Users/timmy/Downloads/LLM-Hub/ios/LLMHub/.build/checkouts/mlx-swift/Package.swift'
text = open(pkg, encoding='latin-1').read()
EXCL = ['GPU+Metal.swift', 'MLXArray+Metal.swift', 'MLXFast.swift', 'MLXFastKernel.swift']
indent = ' '
lines = ',\n'.join(indent + '"' + x + '"' for x in EXCL)
old_pkg = ' let mlxSwiftExcludes: [String] = []\n#else'
new_pkg = ' let mlxSwiftExcludes: [String] = [\n' + lines + ',\n ]\n#else'
if old_pkg in text:
text2 = text.replace(old_pkg, new_pkg, 1)
open(pkg, 'w', encoding='latin-1').write(text2)
print('Package.swift: reverted')
elif new_pkg in text:
print('Package.swift: already original')
else:
idx = text.find('mlxSwiftExcludes')
print('unrecognized: ' + repr(text[idx:idx+100]))