Skip to content

Commit 378d8ac

Browse files
authored
Fix the GLPK build on Windows for setuptools>74.0 (#106)
* update the MSVC detection * start debug * start debug * start debug * start debug * try the dumbest thing possible * try the dumbest thing possible * try the dumbest thing possible * try the dumbest thing possible * try the dumbest thing possible * try the dumbest thing possible * try the dumbest thing possible * add a vcvarsall finder * try with best guess and fallback * try with best guess and fallback * use correct path for search * bump cibuildwheel
1 parent 234c338 commit 378d8ac

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

.github/workflows/build-wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
platforms: all
4040

4141
- name: Build wheels
42-
uses: pypa/cibuildwheel@v2.20.0
42+
uses: pypa/cibuildwheel@v2.21.3
4343
env:
4444
NEW_GLPK_VERSION: ${{ inputs.glpk_version }}
4545
GLPK_HEADER_PATH: glpk-${{ inputs.glpk_version }}/src

scripts/build_glpk.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
11
# taken from https://github.com/opencobra/cobrapy/blob/devel/appveyor/build_glpk.py
22

33
import os
4-
import sys
5-
# import hashlib
64
import tarfile
75
import struct
86
import shutil
9-
import setuptools.msvc
107
import urllib.request as urllib2
118
import subprocess
129

10+
GUESS_VCVARS = (
11+
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\"
12+
"VC\\Auxiliary\\Build\\vcvarsall.bat"
13+
)
14+
1315
# these need to be set to the latest glpk version
1416
glpk_version = os.getenv('NEW_GLPK_VERSION')
15-
# glpk_md5 = "eda7965907f6919ffc69801646f13c3e"
1617

1718
glpk_build_dir = "glpk_build/glpk-%s" % glpk_version
1819
url = "http://ftp.gnu.org/gnu/glpk/glpk-%s.tar.gz" % glpk_version
1920
bitness = struct.calcsize("P") * 8
2021
arch = "x86_amd64" if bitness == 64 else "x86"
2122

22-
23-
# def md5(fname):
24-
# hash = hashlib.md5()
25-
# with open(fname, "rb") as f:
26-
# for chunk in iter(lambda: f.read(4096), b""):
27-
# hash.update(chunk)
28-
# return hash.hexdigest()
29-
30-
31-
def get_vcvarsall_cmd():
32-
py_ver = sys.version_info
33-
if py_ver.major == 3 and py_ver.minor >= 5:
34-
vc_ver = 14
35-
elif py_ver.major == 3 and py_ver.minor >= 3:
36-
vc_ver = 10
37-
else:
38-
vc_ver = 9
39-
vc_path = setuptools.msvc.msvc9_find_vcvarsall(vc_ver)
40-
assert vc_path is not None
41-
return '"%s" %s' % (vc_path, " amd64" if bitness == 64 else "")
23+
def find_vcvarsall():
24+
if os.path.isfile(GUESS_VCVARS):
25+
return(GUESS_VCVARS)
26+
for root, _, files in os.walk("C:\\Program Files\\Microsoft Visual Studio\\"):
27+
for f in files:
28+
if f == "vcvarsall.bat":
29+
return(os.path.join(root, f))
30+
raise RuntimeError("Could not find vcvarsall.bat :(")
4231

4332

4433
if not os.path.isdir("glpk_build/"):
@@ -54,10 +43,10 @@ def get_vcvarsall_cmd():
5443
os.chdir("%s/w%d" % (glpk_build_dir, bitness))
5544
if not os.path.isfile("glpk.lib"):
5645
shutil.copy2("config_VC", "config.h")
57-
os.environ.update(setuptools.msvc.msvc14_get_vc_env(arch))
46+
vc_setup = find_vcvarsall()
5847
subprocess.run(
59-
["nmake", "/f", "Makefile_VC"],
60-
check=True,
48+
f'"{vc_setup}" {arch} & nmake /f Makefile_VC',
49+
check=True, shell=True
6150
)
6251
shutil.copy2("glpk.lib", "../../..")
6352
os.chdir("../../..")

0 commit comments

Comments
 (0)