|
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,18 @@ 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 | +if sys.platform.startswith('win') and platform.machine() == 'ARM64': # older versions are not supported for win/arm64 |
| 179 | + LOCAL_FREETYPE_VERSION = '2.11.1' |
| 180 | +else: |
| 181 | + LOCAL_FREETYPE_VERSION = '2.6.1' |
| 182 | + |
176 | 183 | LOCAL_FREETYPE_HASH = _freetype_hashes.get(LOCAL_FREETYPE_VERSION, 'unknown')
|
177 | 184 |
|
178 | 185 | # Also update the cache path in `.circleci/config.yml`.
|
@@ -645,9 +652,10 @@ def do_custom_build(self, env):
|
645 | 652 | subprocess.check_call([make], env=env, cwd=src_path)
|
646 | 653 | else: # compilation on windows
|
647 | 654 | shutil.rmtree(src_path / "objs", ignore_errors=True)
|
| 655 | + is_x64 = platform.architecture()[0] == '64bit' |
648 | 656 | msbuild_platform = (
|
649 |
| - 'x64' if platform.architecture()[0] == '64bit' else 'Win32') |
650 |
| - base_path = Path("build/freetype-2.6.1/builds/windows") |
| 657 | + 'ARM64' if platform.machine() == 'ARM64' else 'x64' if is_x64 else 'Win32') |
| 658 | + base_path = Path("build/freetype-{}/builds/windows".format(LOCAL_FREETYPE_VERSION)) |
651 | 659 | vc = 'vc2010'
|
652 | 660 | sln_path = (
|
653 | 661 | base_path / vc / "freetype.sln"
|
@@ -677,15 +685,23 @@ def do_custom_build(self, env):
|
677 | 685 |
|
678 | 686 | cc = get_ccompiler()
|
679 | 687 | cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
|
| 688 | + # Freetype 2.10.0+ support static builds and use them if available as they are easier to deploy |
| 689 | + msbuild_configuration = 'Release Static' if version.parse(LOCAL_FREETYPE_VERSION) >= version.parse("2.10.0") else 'Release' |
680 | 690 | cc.spawn(["msbuild", str(sln_path),
|
681 | 691 | "/t:Clean;Build",
|
682 |
| - f"/p:Configuration=Release;Platform={msbuild_platform}"]) |
| 692 | + f"/p:Configuration={msbuild_configuration};Platform={msbuild_platform}"]) |
683 | 693 | # Move to the corresponding Unix build path.
|
684 | 694 | (src_path / "objs" / ".libs").mkdir()
|
685 | 695 | # Be robust against change of FreeType version.
|
686 |
| - lib_path, = (src_path / "objs" / vc / msbuild_platform).glob( |
687 |
| - "freetype*.lib") |
688 |
| - shutil.copy2(lib_path, src_path / "objs/.libs/libfreetype.lib") |
| 696 | + lib_paths = Path(src_path / "objs").rglob('freetype*.lib') |
| 697 | + libfreetype_file = None |
| 698 | + for lib_path in lib_paths: |
| 699 | + # check if freetype.lib in required platform directory |
| 700 | + if msbuild_platform in lib_path.resolve().as_uri(): |
| 701 | + libfreetype_file = lib_path |
| 702 | + continue |
| 703 | + print("Copying {} to {}".format(lib_path.resolve(), src_path / "objs/.libs/libfreetype.lib")) |
| 704 | + shutil.copy2(libfreetype_file, src_path / "objs/.libs/libfreetype.lib") |
689 | 705 |
|
690 | 706 |
|
691 | 707 | class Qhull(SetupPackage):
|
|
0 commit comments