From 8183e9d3effe8260ca3bc21f0d52019db5c827b4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Apr 2024 08:08:07 +0530 Subject: [PATCH] Fix CI build failure on macOS Also update simde to version 0.8. Accidental was using it to debug issues with building against simde, but now that it's done, keep it. --- .github/workflows/ci.py | 2 +- Brewfile | 1 + bypy/sources.json | 6 +++--- setup.py | 18 +++++++++++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.py b/.github/workflows/ci.py index 7ca33e17c..4dd392043 100644 --- a/.github/workflows/ci.py +++ b/.github/workflows/ci.py @@ -69,7 +69,7 @@ def install_deps(): import ssl if ssl.OPENSSL_VERSION_INFO[0] == 1: openssl += '@1.1' - run('brew', 'install', 'fish', 'simde', openssl, *items) + run('brew', 'install', 'fish', openssl, *items) else: run('sudo apt-get update') run('sudo apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev ca-certificates' diff --git a/Brewfile b/Brewfile index ad7a38fb3..f74c7ad51 100644 --- a/Brewfile +++ b/Brewfile @@ -1,6 +1,7 @@ brew "pkg-config" brew "zlib" brew "xxhash" +brew "simde" brew "python" brew "imagemagick" brew "harfbuzz" diff --git a/bypy/sources.json b/bypy/sources.json index 8754b5336..3ab682b4d 100644 --- a/bypy/sources.json +++ b/bypy/sources.json @@ -253,9 +253,9 @@ { "name": "simde", "unix": { - "filename": "simde-amalgamated-0.7.6.tar.xz", - "hash": "sha256:703eac1f2af7de1f7e4aea2286130b98e1addcc0559426e78304c92e2b4eb5e1", - "urls": ["https://github.com/simd-everywhere/simde/releases/download/v0.7.6/{filename}"] + "filename": "simde-amalgamated-0.8.0.tar.xz", + "hash": "sha256:7c8dd4d613b18724b7ef3dcd1d58739a91501ed80ace916cbca9b8c13e5b92bb", + "urls": ["https://github.com/simd-everywhere/simde/releases/download/v0.8.0/{filename}"] } }, diff --git a/setup.py b/setup.py index 61352c2a6..d0923b861 100755 --- a/setup.py +++ b/setup.py @@ -267,11 +267,15 @@ def libcrypto_flags() -> Tuple[List[str], List[str]]: openssl_dirs = glob.glob(f'/opt/homebrew/{q}') + glob.glob(f'/usr/local/{q}') if openssl_dirs: break - if not openssl_dirs: + else: raise SystemExit(f'Failed to find OpenSSL version {v[0]}.{v[1]} on your system') extra_pc_dir = os.pathsep.join(openssl_dirs) cflags = pkg_config('libcrypto', '--cflags-only-I', extra_pc_dir=extra_pc_dir) - return cflags, pkg_config('libcrypto', '--libs', extra_pc_dir=extra_pc_dir) + ldflags = pkg_config('libcrypto', '--libs', extra_pc_dir=extra_pc_dir) + # Workaround bug in homebrew openssl package. This bug appears in CI only + if is_macos and ldflags and 'homebrew/Cellar' in ldflags[0] and not ldflags[0].endswith('/lib'): + ldflags.insert(0, ldflags[0] + '/lib') + return cflags, ldflags def at_least_version(package: str, major: int, minor: int = 0) -> None: @@ -593,16 +597,20 @@ def kitty_env(args: Options) -> Env: ans = env.copy() cflags = ans.cflags cflags.append('-pthread') + cppflags = ans.cppflags # We add 4000 to the primary version because vim turns on SGR mouse mode # automatically if this version is high enough - libcrypto_cflags, libcrypto_ldflags = libcrypto_flags() - cppflags = ans.cppflags cppflags.append(f'-DPRIMARY_VERSION={version[0] + 4000}') cppflags.append(f'-DSECONDARY_VERSION={version[1]}') cppflags.append('-DXT_VERSION="{}"'.format('.'.join(map(str, version)))) at_least_version('harfbuzz', 1, 5) cflags.extend(pkg_config('libpng', '--cflags-only-I')) cflags.extend(pkg_config('lcms2', '--cflags-only-I')) + # simde doesnt come with pkg-config files but some Linux distros add + # them and on macOS when building with homebrew it is required + with suppress(SystemExit, subprocess.CalledProcessError): + cflags.extend(pkg_config('simde', '--cflags-only-I', fatal=False)) + libcrypto_cflags, libcrypto_ldflags = libcrypto_flags() cflags.extend(libcrypto_cflags) if is_macos: platform_libs = [ @@ -969,7 +977,7 @@ def compile_kittens(args: Options) -> None: files('transfer', 'rsync', libraries=pkg_config('libxxhash', '--libs'), includes=pkg_config('libxxhash', '--cflags-only-I')), ): final_env = kenv.copy() - final_env.cflags.extend(f'-I{x}' for x in includes) + final_env.cflags.extend(includes) final_env.ldpaths[:0] = list(libraries) compile_c_extension( final_env, dest, args.compilation_database, sources, all_headers + ['kitty/data-types.h'], build_dsym=args.build_dsym)