|
14 | 14 | import tarfile
|
15 | 15 | import textwrap
|
16 | 16 | import urllib.request
|
| 17 | +from packaging import version |
17 | 18 |
|
18 | 19 | from setuptools import Distribution, Extension
|
19 | 20 |
|
@@ -167,12 +168,21 @@ def get_and_extract_tarball(urls, sha, dirname):
|
167 | 168 | '955e17244e9b38adb0c98df66abb50467312e6bb70eac07e49ce6bd1a20e809a',
|
168 | 169 | '2.10.1':
|
169 | 170 | '3a60d391fd579440561bf0e7f31af2222bc610ad6ce4d9d7bd2165bca8669110',
|
| 171 | + '2.11.1': |
| 172 | + 'f8db94d307e9c54961b39a1cc799a67d46681480696ed72ecf78d4473770f09b' |
170 | 173 | }
|
171 | 174 | # This is the version of FreeType to use when building a local version. It
|
172 | 175 | # must match the value in lib/matplotlib.__init__.py and also needs to be
|
173 | 176 | # changed below in the embedded windows build script (grep for "REMINDER" in
|
174 | 177 | # this file). Also update the cache path in `.circleci/config.yml`.
|
175 |
| -LOCAL_FREETYPE_VERSION = '2.6.1' |
| 178 | +TESTING_VERSION_OF_FREETYPE = '2.6.1' |
| 179 | +if sys.platform.startswith('win') and platform.machine() == 'ARM64': |
| 180 | + # older versions of freetype are not supported for win/arm64 |
| 181 | + # Matplotlib tests will not pass |
| 182 | + LOCAL_FREETYPE_VERSION = '2.11.1' |
| 183 | +else: |
| 184 | + LOCAL_FREETYPE_VERSION = TESTING_VERSION_OF_FREETYPE |
| 185 | + |
176 | 186 | LOCAL_FREETYPE_HASH = _freetype_hashes.get(LOCAL_FREETYPE_VERSION, 'unknown')
|
177 | 187 |
|
178 | 188 | # Also update the cache path in `.circleci/config.yml`.
|
@@ -646,9 +656,16 @@ def do_custom_build(self, env):
|
646 | 656 | subprocess.check_call([make], env=env, cwd=src_path)
|
647 | 657 | else: # compilation on windows
|
648 | 658 | 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") |
| 659 | + is_x64 = platform.architecture()[0] == '64bit' |
| 660 | + if platform.machine() == 'ARM64': |
| 661 | + msbuild_platform = 'ARM64' |
| 662 | + elif is_x64: |
| 663 | + msbuild_platform = 'x64' |
| 664 | + else: |
| 665 | + msbuild_platform = 'Win32' |
| 666 | + base_path = Path( |
| 667 | + f"build/freetype-{LOCAL_FREETYPE_VERSION}/builds/windows" |
| 668 | + ) |
652 | 669 | vc = 'vc2010'
|
653 | 670 | sln_path = (
|
654 | 671 | base_path / vc / "freetype.sln"
|
@@ -678,14 +695,30 @@ def do_custom_build(self, env):
|
678 | 695 |
|
679 | 696 | cc = get_ccompiler()
|
680 | 697 | cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
|
| 698 | + # Freetype 2.10.0+ support static builds. |
| 699 | + msbuild_config = ( |
| 700 | + "Release Static" |
| 701 | + if version.parse(LOCAL_FREETYPE_VERSION) >= |
| 702 | + version.parse("2.10.0") |
| 703 | + else "Release" |
| 704 | + ) |
| 705 | + |
681 | 706 | cc.spawn(["msbuild", str(sln_path),
|
682 | 707 | "/t:Clean;Build",
|
683 |
| - f"/p:Configuration=Release;Platform={msbuild_platform}"]) |
| 708 | + f"/p:Configuration={msbuild_config};" |
| 709 | + f"Platform={msbuild_platform}"]) |
684 | 710 | # Move to the corresponding Unix build path.
|
685 | 711 | (src_path / "objs" / ".libs").mkdir()
|
686 | 712 | # Be robust against change of FreeType version.
|
687 |
| - lib_path, = (src_path / "objs" / vc / msbuild_platform).glob( |
688 |
| - "freetype*.lib") |
| 713 | + lib_paths = Path(src_path / "objs").rglob('freetype*.lib') |
| 714 | + # Select FreeType library for required platform |
| 715 | + lib_path, = [ |
| 716 | + p for p in lib_paths |
| 717 | + if msbuild_platform in p.resolve().as_uri() |
| 718 | + ] |
| 719 | + print( |
| 720 | + f"Copying {lib_path} to {src_path}/objs/.libs/libfreetype.lib" |
| 721 | + ) |
689 | 722 | shutil.copy2(lib_path, src_path / "objs/.libs/libfreetype.lib")
|
690 | 723 |
|
691 | 724 |
|
|
0 commit comments