Skip to content

Commit

Permalink
Fix flag use_system_libtl2cgen
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed May 3, 2023
1 parent 675d407 commit 34dc8c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions python/packager/nativelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion python/packager/pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 34dc8c6

Please sign in to comment.