Skip to content

Commit 9019833

Browse files
committed
pray for me
1 parent 3fb70df commit 9019833

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

hatch_build.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from contextlib import suppress
55
from distutils.extension import Extension
66
from glob import glob
7+
from pathlib import Path
78

9+
from find_libpython import find_libpython
810
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
911
from hatchling.plugin import hookimpl
1012
from setuptools._distutils.ccompiler import new_compiler
@@ -30,17 +32,20 @@ def initialize(self, version: str, data: dict):
3032
# logic taken from distutils
3133
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
3234
if not sysconfig.is_python_build():
33-
self.app.display_info(sysconfig.get_config_var('LIBDIR'))
3435
compiler.add_library_dir(sysconfig.get_config_var('LIBDIR'))
3536
else:
3637
compiler.add_library_dir('.')
3738

39+
libpython_path = find_libpython()
40+
if not libpython_path:
41+
self.app.abort("failed to find libpython")
42+
43+
compiler.add_library_dir(str(Path(libpython_path).parent.absolute()))
44+
3845
compiler.add_include_dir(
3946
os.path.join(sysconfig.get_path("platstdlib"), "lib")
4047
)
41-
self.app.display_info(
42-
os.path.join(sysconfig.get_path("platstdlib"), "lib")
43-
)
48+
4449
compiler.add_include_dir(sysconfig.get_path("include"))
4550
compiler.define_macro("PY_SSIZE_T_CLEAN")
4651

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling", "setuptools"]
2+
requires = ["hatchling", "setuptools", "find-libpython"]
33
build-backend = "hatchling.build"
44

55
[project]

0 commit comments

Comments
 (0)