8000 Fix FreeType build. · matplotlib/matplotlib@4b2df55 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b2df55

Browse files
anntzertacaswell
authored andcommitted
Fix FreeType build.
1 parent c747359 commit 4b2df55

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

setupext.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import configparser
2-
from distutils import sysconfig
2+
from distutils import ccompiler, sysconfig
33
from distutils.core import Extension
44
import functools
55
import glob
@@ -569,26 +569,27 @@ def do_custom_build(self):
569569
subprocess.check_call(["make"], env=env, cwd=src_path)
570570
else:
571571
# compilation on windows
572-
shutil.rmtree(pathlib.Path(src_path, "objs"), ignore_errors=True)
573-
import distutils.msvc9compiler as msvc
574-
# FreeType has no build profile for 2014, so we don't bother.
575-
vc = 'vc2010'
576-
WinXX = 'x64' if platform.architecture()[0] == '64bit' else 'Win32'
577-
xXX = 'x64' if platform.architecture()[0] == '64bit' else 'x86'
578-
vcvarsall = msvc.find_vcvarsall(10.0)
579-
if vcvarsall is None:
580-
raise RuntimeError('Microsoft VS 2010 required')
581-
cmdfile = pathlib.Path("build/build_freetype.cmd")
582-
cmdfile.write_text(fr"""
583-
call "%ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd" ^
584-
/Release /{xXX} /xp
585-
call "{vcvarsall}" {xXX}
586-
set MSBUILD=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
587-
%MSBUILD% "builds\windows\{vc}\freetype.sln" ^
588-
/t:Clean;Build /p:Configuration="Release";Platform={WinXX}
572+
shutil.rmtree(str(pathlib.Path(src_path, "objs")),
573+
ignore_errors=True)
574+
msbuild_platform = (
575+
'x64' if platform.architecture()[0] == '64bit' else 'Win32')
576+
sln_path = pathlib.Path(
577+
"build/freetype-2.6.1/builds/windows/vc2010/freetype.sln")
578+
# https://developercommunity.visualstudio.com/comments/190992/view.html
579+
(sln_path.parent / "Directory.Build.props").write_text("""
580+
<Project>
581+
<PropertyGroup>
582+
<!-- The following line *cannot* be split over multiple lines. -->
583+
<WindowsTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
584+
</PropertyGroup>
585+
</Project>
589586
""")
590-
subprocess.check_call([str(cmdfile.resolve())],
591-
shell=True, cwd=src_path)
587+
cc = ccompiler.new_compiler()
588+
cc.initialize() # Get devenv & msbuild in the %PATH% of cc.spawn.
589+
cc.spawn(["devenv", str(sln_path), "/upgrade"])
590+
cc.spawn(["msbuild", str(sln_path),
591+
"/t:Clean;Build",
592+
f"/p:Configuration=Release;Platform={msbuild_platform}"])
592593
# Move to the corresponding Unix build path.
593594
(src_path / "objs" / ".libs").mkdir()
594595
# Be robust against change of FreeType version.

0 commit comments

Comments
 (0)
0