Skip to content

gh-134632: Fix build-details.json to use INCLUDEPY path #134633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lib/test/test_build_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ 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')))
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()
Original file line number Diff line number Diff line change
@@ -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.
Comment on lines +2 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If required by the PEP, we should have a test enforcing this contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have anything specific in mind? Checking that the value in the generated build-details.json ends with pythonX.Y specifically, or something deeper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a test that checks that the values of c_api.include and c_api.pkgconfig_path (if present) point to valid directories with necessary files.

4 changes: 2 additions & 2 deletions Tools/build/generate-build-details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading