From 34dc8c604d781237d0772513dc5ab1b97ca59ac8 Mon Sep 17 00:00:00 2001 From: Hyunsu Philip Cho Date: Tue, 2 May 2023 17:00:56 -0700 Subject: [PATCH] Fix flag use_system_libtl2cgen --- python/packager/nativelib.py | 15 ++++++++------- python/packager/pep517.py | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/python/packager/nativelib.py b/python/packager/nativelib.py index 6a59bdb..a888463 100644 --- a/python/packager/nativelib.py +++ b/python/packager/nativelib.py @@ -132,20 +132,21 @@ def locate_or_build_libtl2cgen( """Locate libtl2cgen; if not exist, build it""" logger = logging.getLogger("tl2cgen.packager.locate_or_build_libtl2cgen") - libtl2cgen = locate_local_libtl2cgen(toplevel_dir, logger=logger) - if libtl2cgen is not None: - return libtl2cgen if build_config.use_system_libtl2cgen: # Find libtl2cgen from system prefix sys_prefix = pathlib.Path(sys.prefix).absolute().resolve() - libtl2cgen = sys_prefix / "lib" / _lib_name() - if not libtl2cgen.exists(): + libtl2cgen_sys = sys_prefix / "lib" / _lib_name() + if not libtl2cgen_sys.exists(): raise RuntimeError( f"use_system_libtl2cgen was specified but {_lib_name()} is " - f"not found in {libtl2cgen.parent}" + f"not found in {libtl2cgen_sys.parent}" ) - logger.info("Using system tl2cgen: %s", str(libtl2cgen)) + logger.info("Using system tl2cgen: %s", str(libtl2cgen_sys)) + return libtl2cgen_sys + + libtl2cgen = locate_local_libtl2cgen(toplevel_dir, logger=logger) + if libtl2cgen is not None: return libtl2cgen if toplevel_dir.joinpath("cpp_src").exists(): diff --git a/python/packager/pep517.py b/python/packager/pep517.py index 3ac3568..5fe9f20 100644 --- a/python/packager/pep517.py +++ b/python/packager/pep517.py @@ -79,7 +79,8 @@ def build_wheel( libtl2cgen = locate_or_build_libtl2cgen( TOPLEVEL_DIR, build_dir=build_dir, build_config=build_config ) - copy_with_logging(libtl2cgen, lib_path, logger=logger) + if not build_config.use_system_libtl2cgen: + copy_with_logging(libtl2cgen, lib_path, logger=logger) with cd(workspace): wheel_name = hatchling.build.build_wheel(