Skip to content

Commit 66339b7

Browse files
update setup.py to include redist x64 #2265
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 71d68b8 commit 66339b7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/api/python/setup.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,36 @@ def _build_z3():
116116
env=build_env, cwd=BUILD_DIR) != 0:
117117
raise LibError("Unable to build Z3.")
118118

119+
def _cp_vs_runtime():
120+
platform = "x64"
121+
vcdir = os.environ['VCINSTALLDIR']
122+
path = '%sredist' % vcdir
123+
vs_runtime_files = []
124+
# Everything changes with every release of VS
125+
# Prior versions of VS had DLLs under "redist\x64"
126+
# There are now several variants of redistributables
127+
# The naming convention defies my understanding so
128+
# we use a "check_root" filter to find some hopefully suitable
129+
# redistributable.
130+
def check_root(root):
131+
return platform in root and ("CRT" in root or "MP" in root) and "onecore" not in root and "debug" not in root
132+
for root, dirs, files in os.walk(path):
133+
for filename in files:
134+
if fnmatch(filename, '*.dll') and check_root(root):
135+
print("Checking %s %s" % (root, filename))
136+
for pat in VS_RUNTIME_PATS:
137+
if pat.match(filename):
138+
fname = os.path.join(root, filename)
139+
if not os.path.isdir(fname):
140+
vs_runtime_files.append(fname)
141+
if not vs_runtime_files:
142+
raise MKException("Did not find any runtime files to include")
143+
for f in vs_runtime_files:
144+
shutil.copy(f, bin_dist_path)
145+
if is_verbose():
146+
print("Copied '%s' to '%s'" % (f, LIBS_DIR))
147+
148+
119149
def _copy_bins():
120150
"""
121151
Copy the library and header files into their final destinations
@@ -141,6 +171,7 @@ def _copy_bins():
141171
os.mkdir(HEADERS_DIR)
142172
shutil.copy(os.path.join(BUILD_DIR, LIBRARY_FILE), LIBS_DIR)
143173
shutil.copy(os.path.join(BUILD_DIR, EXECUTABLE_FILE), BINS_DIR)
174+
_cp_vs_runtime()
144175

145176
for header_dir in HEADER_DIRS:
146177
for fname in os.listdir(header_dir):

0 commit comments

Comments
 (0)