diff --git a/scripts/mk_nuget_release.py b/scripts/mk_nuget_release.py index 98a7c6362..1db75cd69 100644 --- a/scripts/mk_nuget_release.py +++ b/scripts/mk_nuget_release.py @@ -14,6 +14,10 @@ import urllib.request import zipfile import sys import os.path +import shutil +import subprocess +import mk_util +import mk_project data = json.loads(urllib.request.urlopen("https://api.github.com/repos/Z3Prover/z3/releases/latest").read().decode()) @@ -27,36 +31,83 @@ def download_installs(): for asset in data['assets']: url = asset['browser_download_url'] name = asset['name'] + if "x64" not in name: + continue print("Downloading ", url) sys.stdout.flush() urllib.request.urlretrieve(url, "packages/%s" % name) -os_names = ["ubuntu-14", "ubuntu-16", "win", "debian", "osx"] +os_info = {"ubuntu-14" : ('so', 'ubuntu.14.04-x64'), + 'ubuntu-16' : ('so', 'ubuntu.16.04-x64'), + 'win' : ('dll', 'win-x64'), + 'debian' : ('so', 'debian.8-x64') } +def classify_package(f): + for os_name in os_info: + if os_name in f: + ext, dst = os_info[os_name] + return os_name, f[:-4], ext, dst + return None + def unpack(): - for f in os.listdir("packages"): - if f.endswith("zip") and "x64" in f: - print(f) - # determine os from os_names - # instead of this string manipulation. - - name = os.path.splitext(f)[0] - os_name = name[name.find("x64")+4:] - os_name = os_name[:os_name.find("-")] - print(os_name) - - zip_ref = zipfile.ZipFile("packages/%s" % f, 'r') - path = "out/%s" % os_name - zip_ref.extract("%s/bin/libz3.so" % name) - # unzip files in packages - pass + # out + # +- runtimes + # +- win-x64 + # +- ubuntu.16.04-x64 + # +- ubuntu.14.04-x64 + # +- debian.8-x64 + # + + for f in os.listdir("packages"): + if f.endswith("zip") and "x64" in f and classify_package(f): + print(f) + os_name, package_dir, ext, dst = classify_package(f) + zip_ref = zipfile.ZipFile("packages/%s" % f, 'r') + zip_ref.extract("%s/bin/libz3.%s" % (package_dir, ext), "tmp") + mk_dir("out/runtimes/%s" % dst) + shutil.move("tmp/%s/bin/libz3.%s" % (package_dir, ext), "out/runtimes/%s/." % dst) + if "win" in f: + mk_dir("out/lib/netstandard1.0/") + for b in ["Microsoft.Z3.dll"]: + zip_ref.extract("%s/bin/%s" % (package_dir, b), "tmp") + shutil.move("tmp/%s/bin/%s" % (package_dir, b), "out/lib/netstandard1.0/%s" % b) + +def create_nuget_spec(): + mk_project.init_version() + contents = """ + + + Microsoft.Z3.x64 + %s + Microsoft + Z3 is a satisfiability modulo theories solver from Microsoft Research. + Copyright Microsoft Corporation. All rights reserved. + smt constraint solver theorem prover + https://raw.githubusercontent.com/Z3Prover/z3/master/package/icon.jpg + https://github.com/Z3Prover/z3 + https://raw.githubusercontent.com/Z3Prover/z3/master/LICENSE.txt + + true + en + +""" + + with open("out/Microsoft.Z3.x64.nuspec", 'w') as f: + f.write(contents % mk_util.get_version_string(3)) + +def create_nuget_package(): + subprocess.call(["nuget", "pack"], cwd="out") def main(): mk_dir("packages") -# download_installs() -# create_nuget_dir() + #download_installs() unpack() -# create_nuget_package() - + create_nuget_spec() + create_nuget_package() + + main() diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 5bd96c0fc..e70a094a0 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -7,9 +7,12 @@ ############################################ from mk_util import * +def init_version(): + set_version(4, 8, 3, 0) + # Z3 Project definition def init_project_def(): - set_version(4, 8, 3, 0) + init_version() add_lib('util', [], includes2install = ['z3_version.h']) add_lib('polynomial', ['util'], 'math/polynomial') add_lib('sat', ['util'])