Skip to content
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

Convert _sysconfigdata to a JSON file #127178

Open
FFY00 opened this issue Nov 22, 2024 · 7 comments
Open

Convert _sysconfigdata to a JSON file #127178

FFY00 opened this issue Nov 22, 2024 · 7 comments
Labels
stdlib Python modules in the Lib dir topic-sysconfig type-feature A feature request or enhancement

Comments

@FFY00
Copy link
Member

FFY00 commented Nov 22, 2024

Feature or enhancement

Proposal:

Currently, as part of the sysconfig internals, we generate a _sysconfigdata Python module containing the variables for sysconfig.get_config_vars(). This data is consists of all Makefile variables, which can be encoded as JSON data.

The use of a module instead of a text file is historic, and adds unnecessary complexity. Converting _sysconfigdata to a JSON file would simplify the sysconfig implementation. Additionally, it also makes it easier for tools to introspect the Python installation, as this would remove the necessity to execute Python code to read _sysconfigdata.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@FFY00 FFY00 added type-feature A feature request or enhancement topic-sysconfig labels Nov 22, 2024
FFY00 added a commit to FFY00/cpython that referenced this issue Nov 22, 2024
Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00
Copy link
Member Author

FFY00 commented Nov 26, 2024

Converting the module to a JSON file seems to be causing some issues on special platforms, such as WASM. Let's install a JSON file together with the module as a starting point, which will enable the introspection use-case, and then explore the possibility of replacing the module with it.

FFY00 added a commit to FFY00/cpython that referenced this issue Nov 26, 2024
…irectory

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/cpython that referenced this issue Nov 26, 2024
@picnixz picnixz added the stdlib Python modules in the Lib dir label Nov 27, 2024
@nascheme
Copy link
Member

It seems this change causes the JIT build bots to fail:

FAIL: test_sysconfigdata_json (test.test_sysconfig.TestSysConfig.test_sysconfigdata_json)
11766
----------------------------------------------------------------------
11767
Traceback (most recent call last):
11768
  File "/home/runner/work/cpython/cpython/Lib/test/test_sysconfig.py", line 654, in test_sysconfigdata_json
11769
    self.assertEqual(system_config_vars, json_config_vars)
[...]
-  'base': '/usr/local',
+  'base': '/home/runner/work/cpython/build',
   'datarootdir': '/usr/local/share',
-  'exec_prefix': '/usr/local',
+  'exec_prefix': '/home/runner/work/cpython/build',
   'host_exec_prefix': '/usr/local',
   'host_prefix': '/usr/local',
   'implementation': 'Python',
   'implementation_lower': 'python',
-  'installed_base': '/usr/local',
-  'installed_platbase': '/usr/local',
-  'platbase': '/usr/local',
+  'installed_base': '/home/runner/work/cpython/build',
+  'installed_platbase': '/home/runner/work/cpython/build',
+  'platbase': '/home/runner/work/cpython/build',
   'platlibdir': 'lib',
-  'prefix': '/usr/local',
+  'prefix': '/home/runner/work/cpython/build',
   'py_version': '3.14.0a2+',
   'py_version_nodot': '314',
   'py_version_nodot_plat': '',
   'py_version_short': '3.14',
   'userbase': '/home/runner/.local'}

https://github.com/python/cpython/actions/runs/12090193539/job/33716932397?pr=127426

@FFY00
Copy link
Member Author

FFY00 commented Nov 29, 2024

How does the prefix change from /usr/local (what is configured in the Makefile) to /home/runner/work/cpython/build? Are you setting DESTDIR?

@FFY00
Copy link
Member Author

FFY00 commented Nov 29, 2024

Hum... no. It is setting the prefix.

./configure --prefix="$(pwd)/../build"

Let me do some debugging.

@FFY00
Copy link
Member Author

FFY00 commented Nov 29, 2024

Ah, no. I think you are getting python from a following build, which does not set the prefix, having it default to /usr/local.

./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes

This seems to me like a bug in the --with-build-python option which keeps the installation directory, but not the prefix.

@FFY00
Copy link
Member Author

FFY00 commented Nov 29, 2024

Ah, I got it. The sysconfig data is generated by the interpreter passed to --with-build-python, but doesn't match the running interpreter.

@FFY00
Copy link
Member Author

FFY00 commented Nov 29, 2024

I opened GH-127429.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-sysconfig type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants