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

test_embed.test_init_pyvenv_cfg() fails #128690

Closed
WolframAlph opened this issue Jan 9, 2025 · 8 comments
Closed

test_embed.test_init_pyvenv_cfg() fails #128690

WolframAlph opened this issue Jan 9, 2025 · 8 comments
Labels
deferred-blocker tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@WolframAlph
Copy link
Contributor

WolframAlph commented Jan 9, 2025

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

@WolframAlph WolframAlph added the type-bug An unexpected behavior, bug, or error label Jan 9, 2025
@FFY00
Copy link
Member

FFY00 commented Jan 11, 2025

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.

@ned-deily
Copy link
Member

ned-deily commented Jan 13, 2025

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.

ned-deily added a commit that referenced this issue Jan 13, 2025
…128771)

Temporarily do not use test_embed in PGO profile builds until the problem with test_init_pyvenv_cfg failing in some configurations is resolved.
@ned-deily
Copy link
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.

@vstinner vstinner changed the title test_embed.test_init_pyvenv_cfg fails [macOS] test_embed.test_init_pyvenv_cfg fails Jan 21, 2025
@vstinner
Copy link
Member

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

@befeleme
Copy link
Contributor

This test fails also on Fedora Linux

@vstinner vstinner changed the title [macOS] test_embed.test_init_pyvenv_cfg fails test_embed.test_init_pyvenv_cfg() fails Jan 21, 2025
@vstinner
Copy link
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

@vstinner
Copy link
Member

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

@vstinner
Copy link
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
Labels
deferred-blocker tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

6 participants