From bdae8842047459be2aaf99d513629158bb132c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 24 May 2025 16:59:32 +0200 Subject: [PATCH 1/3] gh-134632: Fix `build-details.json` to use `INCLUDEPY` path Fix ``build-details.json`` generation to use ``INCLUDEPY``, in order to reference the ``pythonX.Y`` subdirectory of the include directory, as required in :pep:`739`, instead of the top-level include directory. --- .../next/Build/2025-05-24-16-59-20.gh-issue-134632.i0W2hc.rst | 3 +++ Tools/build/generate-build-details.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2025-05-24-16-59-20.gh-issue-134632.i0W2hc.rst diff --git a/Misc/NEWS.d/next/Build/2025-05-24-16-59-20.gh-issue-134632.i0W2hc.rst b/Misc/NEWS.d/next/Build/2025-05-24-16-59-20.gh-issue-134632.i0W2hc.rst new file mode 100644 index 00000000000000..f41c8744b8aaa0 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-05-24-16-59-20.gh-issue-134632.i0W2hc.rst @@ -0,0 +1,3 @@ +Fixed ``build-details.json`` generation to use ``INCLUDEPY``, in order to +reference the ``pythonX.Y`` subdirectory of the include directory, as +required in :pep:`739`, instead of the top-level include directory. diff --git a/Tools/build/generate-build-details.py b/Tools/build/generate-build-details.py index 87e262065ec87b..8cd23e2f54f529 100644 --- a/Tools/build/generate-build-details.py +++ b/Tools/build/generate-build-details.py @@ -75,7 +75,7 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: PY3LIBRARY = sysconfig.get_config_var('PY3LIBRARY') LIBPYTHON = sysconfig.get_config_var('LIBPYTHON') LIBPC = sysconfig.get_config_var('LIBPC') - INCLUDEDIR = sysconfig.get_config_var('INCLUDEDIR') + INCLUDEPY = sysconfig.get_config_var('INCLUDEPY') if os.name == 'posix': # On POSIX, LIBRARY is always the static library, while LDLIBRARY is the @@ -123,7 +123,7 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: if has_static_library: data['libpython']['static'] = os.path.join(LIBDIR, LIBRARY) - data['c_api']['headers'] = INCLUDEDIR + data['c_api']['headers'] = INCLUDEPY if LIBPC: data['c_api']['pkgconfig_path'] = LIBPC From cdad9a44b43f1e18c930706a7b463ebbac6ab799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 26 May 2025 19:10:59 +0200 Subject: [PATCH 2/3] test_build_details: Add tests for the c_api section --- Lib/test/test_build_details.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_build_details.py b/Lib/test/test_build_details.py index 05ce163a337881..3d333941a980b4 100644 --- a/Lib/test/test_build_details.py +++ b/Lib/test/test_build_details.py @@ -123,6 +123,14 @@ def test_base_interpreter(self): self.assertEqual(os.path.realpath(value), os.path.realpath(sys.executable)) + @needs_installed_python + def test_c_api(self): + value = self.key('c_api') + self.assertTrue(os.path.exists(os.path.join(value['headers'], 'Python.h'))) + if 'pkgconfig_path' in value: + version = sysconfig.get_config_var('VERSION') + self.assertTrue(os.path.exists(os.path.join(value['pkgconfig_path'], f'python-{version}.pc'))) + if __name__ == '__main__': unittest.main() From d6757c8192e113f9db058a9c811bc8f18542c5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 27 May 2025 19:55:30 +0200 Subject: [PATCH 3/3] test_build_details: Expect pkgconfig for CPython unconditionally --- Lib/test/test_build_details.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_build_details.py b/Lib/test/test_build_details.py index 3d333941a980b4..33ade161fb5058 100644 --- a/Lib/test/test_build_details.py +++ b/Lib/test/test_build_details.py @@ -127,9 +127,8 @@ def test_base_interpreter(self): def test_c_api(self): value = self.key('c_api') self.assertTrue(os.path.exists(os.path.join(value['headers'], 'Python.h'))) - if 'pkgconfig_path' in value: - version = sysconfig.get_config_var('VERSION') - self.assertTrue(os.path.exists(os.path.join(value['pkgconfig_path'], f'python-{version}.pc'))) + version = sysconfig.get_config_var('VERSION') + self.assertTrue(os.path.exists(os.path.join(value['pkgconfig_path'], f'python-{version}.pc'))) if __name__ == '__main__':