Skip to content

test_embed.test_init_pyvenv_cfg() fails #128690

Closed

Description

@WolframAlph

Bug report

Bug description:

Trying to build Python from main branch and running tests on MacOS 15.2 fails on test_embed.test_init_pyvenv_cfg.

./configure && make -j && ./python.exe -m test test_embed
FAIL: test_init_pyvenv_cfg (test.test_embed.InitConfigTests.test_init_pyvenv_cfg)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/yyanchii/Desktop/cpython/Lib/test/test_embed.py", line 1671, in test_init_pyvenv_cfg
    self.check_all_configs("test_init_compat_config", config,
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           api=API_COMPAT, env=env,
                           ^^^^^^^^^^^^^^^^^^^^^^^^
                           ignore_stderr=True, cwd=tmpdir)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yyanchii/Desktop/cpython/Lib/test/test_embed.py", line 939, in check_all_configs
    self.check_config(configs, expected_config)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yyanchii/Desktop/cpython/Lib/test/test_embed.py", line 865, in check_config
    self.assertEqual(config, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
AssertionError: {'argv': [''], 'base_exec_prefix': '/usr/lo[2028 chars]None} != {'_config_init': 1, 'isolated': False, 'use[2128 chars]alse}
  {'_config_init': 1,
   '_init_main': True,
   '_install_importlib': True,
   'argv': [''],
-  'base_exec_prefix': '/usr/local',
+  'base_exec_prefix': '/var/folders/z9/tt4sxxm159zbh6xlm2mhrg4r0000gp/T/tmp_o9bmpp_',
   'base_executable': '/var/folders/z9/tt4sxxm159zbh6xlm2mhrg4r0000gp/T/tmp_o9bmpp_/_testembed',
   'base_prefix': '/usr/local',
   'buffered_stdio': True,
   'bytes_warning': 0,
   'check_hash_pycs_mode': 'default',
   'code_debug_ranges': True,
   'configure_c_stdio': False,
   'cpu_count': -1,
   'dev_mode': False,
   'dump_refs': False,
   'dump_refs_file': None,
   'exec_prefix': '/private/var/folders/z9/tt4sxxm159zbh6xlm2mhrg4r0000gp/T/tmp_7n79vly',
   'executable': '/private/var/folders/z9/tt4sxxm159zbh6xlm2mhrg4r0000gp/T/tmp_7n79vly/_testembed',
   'faulthandler': False,
   'hash_seed': 0,
   'home': None,
   'import_time': False,
   'inspect': False,
   'install_signal_handlers': True,
   'int_max_str_digits': 4300,
   'interactive': False,
   'isolated': False,
   'malloc_stats': False,
   'module_search_paths': ['/usr/local/lib/python314.zip',
                           '/Users/yyanchii/Desktop/cpython/Lib',
                           '/Users/yyanchii/Desktop/cpython/build/lib.macosx-15.2-arm64-3.14',
                           '/usr/local/lib/python314.zip',
                           '/usr/local/lib/python3.14',
-                          '/usr/local/lib/python3.14/lib-dynload'],
+                          '/var/folders/z9/tt4sxxm159zbh6xlm2mhrg4r0000gp/T/tmp_o9bmpp_/lib/python3.14/lib-dynload'],
   'module_search_paths_set': True,
   'optimization_level': 0,
   'orig_argv': [],
   'parse_argv': False,
   'parser_debug': False,
   'pathconfig_warnings': True,
   'perf_profiling': 0,
   'platlibdir': 'lib',
   'prefix': '/private/var/folders/z9/tt4sxxm159zbh6xlm2mhrg4r0000gp/T/tmp_7n79vly',
   'program_name': './_testembed',
   'pycache_prefix': None,
   'pythonpath_env': '/usr/local/lib/python314.zip:/Users/yyanchii/Desktop/cpython/Lib:/Users/yyanchii/Desktop/cpython/build/lib.macosx-15.2-arm64-3.14',
   'quiet': False,
   'run_command': None,
   'run_filename': None,
   'run_module': None,
   'run_presite': None,
   'safe_path': False,
   'show_ref_count': False,
   'site_import': True,
   'skip_source_first_line': False,
   'sys_path_0': None,
   'tracemalloc': 0,
   'use_environment': True,
   'use_frozen_modules': False,
   'use_hash_seed': False,
   'use_system_logger': False,
   'user_site_directory': True,
   'verbose': 0,
   'warn_default_encoding': False,
   'warnoptions': [],
   'write_bytecode': True,
   'xoptions': {}}

----------------------------------------------------------------------
Ran 82 tests in 5.051s

FAILED (failures=1, skipped=3)
test test_embed failed
test_embed failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_embed

Total duration: 5.1 sec
Total tests: run=82 failures=1 skipped=3
Total test files: run=1/1 failed=1
Result: FAILURE

After bisecting found out 34e840f9ddd commit to be the reason. cc @FFY00

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. FFY00 commented on Jan 11, 2025

    @FFY00
    Member

    The test is mocking an installation, and we now return more accurate information since the prefix comes from the runtime library instead of pyvenv.cfg, so we can just skip the test when running with a shared library, since pyvenv.cfg is no longer relevant here.

  2. added a commit that references this issue on Jan 11, 2025
  3. added a commit that references this issue on Jan 13, 2025
  4. ned-deily commented on Jan 13, 2025

    @ned-deily
    Member

    FWIW, this failure apparently can also arise in non-shared builds and can have a fatal impact on builds where it does fail since test_embed is one of the tests run for PGO profiling with --enable-optimizations. See #128771 for more details.

  5. added a commit that references this issue on Jan 13, 2025
  6. ned-deily commented on Jan 13, 2025

    @ned-deily
    Member

    With release manager approval, #128771 was merged to temporarily avoid using test_embed in the PGO profile builds which are used in some release builds. I'm marking this as a deferred blocker so we don't forget to resolve the main issue and restore use of test_embed.

  7. changed the title [-]`test_embed.test_init_pyvenv_cfg` fails[/-] [+][macOS] `test_embed.test_init_pyvenv_cfg` fails[/+] on Jan 21, 2025
  8. vstinner commented on Jan 21, 2025

    @vstinner
    Member

    Is it possible to reproduce this issue on operating systems other than macOS? Or is the issue specific to macOS?

  9. befeleme commented on Jan 21, 2025

    @befeleme
    Contributor

    This test fails also on Fedora Linux

  10. changed the title [-][macOS] `test_embed.test_init_pyvenv_cfg` fails[/-] [+]`test_embed.test_init_pyvenv_cfg()` fails[/+] on Jan 21, 2025
  11. vstinner commented on Jan 21, 2025

    @vstinner
    Member

    This test fails also on Fedora Linux

    Oh ok, I managed to reproduce the bug on Fedora 41 using commands:

    ./configure --prefix=/usr --exec-prefix=/usr --with-platlibdir=lib64 --enable-shared --with-pydebug
    make clean
    make
    LD_LIBRARY_PATH=$PWD ./python -m test -v test_embed -m test_init_pyvenv_cfg
    
  12. added 2 commits that reference this issue on Jan 21, 2025
  13. vstinner commented on Jan 21, 2025

    @vstinner
    Member

    I wrote PR #129137 to update test_embed for the getpath.py exec_prefix change.

  14. added a commit that references this issue on Jan 23, 2025
  15. vstinner commented on Jan 23, 2025

    @vstinner
    Member

    I updated test_embed with the change b23b27b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferred-blockertestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions