Skip to content

Commit

Permalink
add helper script to download xcframework
Browse files Browse the repository at this point in the history
  • Loading branch information
svenpaulsen committed Sep 4, 2022
1 parent 80fb5bc commit 67e33b2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
# -*- coding: utf8 -*-

import os
import re
import shutil
import tarfile
import tempfile
import urllib.request

coresdk_url = "https://github.com/4Players/odin-sdk"
script_path = os.path.dirname(__file__)

def get_xcframework_version():
file = open(os.path.join(script_path, "Sources", "OdinKit.swift"), "r")
text = file.read()
file.close()

return re.findall("let version = \"([^\"]+)\"", text)[0]

if __name__ == "__main__":
xcframework_version = get_xcframework_version()
print("Downloading Odin.xcframework version", xcframework_version)

xcframework_url = coresdk_url + "/releases/download/v" + xcframework_version + "/odin-xcframework.tgz"
with urllib.request.urlopen(xcframework_url) as response:
with tempfile.NamedTemporaryFile(delete = True) as tmp:
shutil.copyfileobj(response, tmp)
tar = tarfile.open(tmp.name)
tar.extractall(os.path.join(script_path, "Frameworks"))
tar.close()

print("All done :-)")

0 comments on commit 67e33b2

Please sign in to comment.