Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 560681c

Browse files
authored
Merge pull request #22647 from meeseeksmachine/auto-backport-of-pr-22429-on-v3.5.x
Backport PR #22429 on branch v3.5.x (Enable windows/arm64 platform)
2 parents 34e6c97 + d324055 commit 560681c

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Windows on Arm Support
2+
----------------------
3+
4+
Preliminary support for windows on arm64 target added.
5+
6+
Matplotlib for windows/arm64 requires FreeType 2.11 or above.
7+
8+
No binary wheels are available yet but can be built from source.

setupext.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,21 @@ def get_and_extract_tarball(urls, sha, dirname):
167167
'955e17244e9b38adb0c98df66abb50467312e6bb70eac07e49ce6bd1a20e809a',
168168
'2.10.1':
169169
'3a60d391fd579440561bf0e7f31af2222bc610ad6ce4d9d7bd2165bca8669110',
170+
'2.11.1':
171+
'f8db94d307e9c54961b39a1cc799a67d46681480696ed72ecf78d4473770f09b'
170172
}
171173
# This is the version of FreeType to use when building a local version. It
172174
# must match the value in lib/matplotlib.__init__.py and also needs to be
173175
# changed below in the embedded windows build script (grep for "REMINDER" in
174176
# this file). Also update the cache path in `.circleci/config.yml`.
175-
LOCAL_FREETYPE_VERSION = '2.6.1'
177+
TESTING_VERSION_OF_FREETYPE = '2.6.1'
178+
if sys.platform.startswith('win') and platform.machine() == 'ARM64':
179+
# older versions of freetype are not supported for win/arm64
180+
# Matplotlib tests will not pass
181+
LOCAL_FREETYPE_VERSION = '2.11.1'
182+
else:
183+
LOCAL_FREETYPE_VERSION = TESTING_VERSION_OF_FREETYPE
184+
176185
LOCAL_FREETYPE_HASH = _freetype_hashes.get(LOCAL_FREETYPE_VERSION, 'unknown')
177186

178187
# Also update the cache path in `.circleci/config.yml`.
@@ -646,9 +655,16 @@ def do_custom_build(self, env):
646655
subprocess.check_call([make], env=env, cwd=src_path)
647656
else: # compilation on windows
648657
shutil.rmtree(src_path / "objs", ignore_errors=True)
649-
msbuild_platform = (
650-
'x64' if platform.architecture()[0] == '64bit' else 'Win32')
651-
base_path = Path("build/freetype-2.6.1/builds/windows")
658+
is_x64 = platform.architecture()[0] == '64bit'
659+
if platform.machine() == 'ARM64':
660+
msbuild_platform = 'ARM64'
661+
elif is_x64:
662+
msbuild_platform = 'x64'
663+
else:
664+
msbuild_platform = 'Win32'
665+
base_path = Path(
666+
f"build/freetype-{LOCAL_FREETYPE_VERSION}/builds/windows"
667+
)
652668
vc = 'vc2010'
653669
sln_path = (
654670
base_path / vc / "freetype.sln"
@@ -678,14 +694,29 @@ def do_custom_build(self, env):
678694

679695
cc = get_ccompiler()
680696
cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
697+
# Freetype 2.10.0+ support static builds.
698+
msbuild_config = (
699+
"Release Static"
700+
if [*map(int, LOCAL_FREETYPE_VERSION.split("."))] >= [2, 10]
701+
else "Release"
702+
)
703+
681704
cc.spawn(["msbuild", str(sln_path),
682705
"/t:Clean;Build",
683-
f"/p:Configuration=Release;Platform={msbuild_platform}"])
706+
f"/p:Configuration={msbuild_config};"
707+
f"Platform={msbuild_platform}"])
684708
# Move to the corresponding Unix build path.
685709
(src_path / "objs" / ".libs").mkdir()
686710
# Be robust against change of FreeType version.
687-
lib_path, = (src_path / "objs" / vc / msbuild_platform).glob(
688-
"freetype*.lib")
711+
lib_paths = Path(src_path / "objs").rglob('freetype*.lib')
712+
# Select FreeType library for required platform
713+
lib_path, = [
714+
p for p in lib_paths
715+
if msbuild_platform in p.resolve().as_uri()
716+
]
717+
print(
718+
f"Copying {lib_path} to {src_path}/objs/.libs/libfreetype.lib"
719+
)
689720
shutil.copy2(lib_path, src_path / "objs/.libs/libfreetype.lib")
690721

691722

0 commit comments

Comments
 (0)