From 07e8fc38158c80e9244137700d1ccac3b6b0e4b5 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 3 Jun 2022 11:14:31 +0000 Subject: [PATCH 1/9] fix OOT --- Lib/test/test_embed.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index f1ca6da147376c..d903e195f71d90 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -70,7 +70,7 @@ def setUp(self): expecteddir = os.path.join(support.REPO_ROOT, builddir) else: exepath = os.path.join(builddir, 'Programs') - expecteddir = os.path.join(support.REPO_ROOT, 'Programs') + expecteddir = os.path.join(builddir, 'Programs') self.test_exe = exe = os.path.join(exepath, exename) if exepath != expecteddir or not os.path.exists(exe): self.skipTest("%r doesn't exist" % exe) @@ -78,7 +78,7 @@ def setUp(self): # "Py_Initialize: Unable to get the locale encoding # LookupError: no codec search functions registered: can't find encoding" self.oldcwd = os.getcwd() - os.chdir(support.REPO_ROOT) + os.chdir(builddir) def tearDown(self): os.chdir(self.oldcwd) @@ -497,7 +497,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'pathconfig_warnings': 1, '_init_main': 1, '_isolated_interpreter': 0, - 'use_frozen_modules': not support.Py_DEBUG, + 'use_frozen_modules': int(not support.Py_DEBUG), 'safe_path': 0, '_is_python_build': IGNORE_CONFIG, } @@ -1205,7 +1205,7 @@ def test_init_setpath_config(self): # The current getpath.c doesn't determine the stdlib dir # in this case. 'stdlib_dir': '', - 'use_frozen_modules': not support.Py_DEBUG, + 'use_frozen_modules': int(not support.Py_DEBUG), # overridden by PyConfig 'program_name': 'conf_program_name', 'base_executable': 'conf_executable', @@ -1444,12 +1444,12 @@ def test_init_pyvenv_cfg(self): config['base_prefix'] = pyvenv_home config['prefix'] = pyvenv_home config['stdlib_dir'] = os.path.join(pyvenv_home, 'Lib') - config['use_frozen_modules'] = not support.Py_DEBUG + config['use_frozen_modules'] = int(not support.Py_DEBUG) else: # cannot reliably assume stdlib_dir here because it # depends too much on our build. But it ought to be found config['stdlib_dir'] = self.IGNORE_CONFIG - config['use_frozen_modules'] = not support.Py_DEBUG + config['use_frozen_modules'] = int(not support.Py_DEBUG) env = self.copy_paths_by_env(config) self.check_all_configs("test_init_compat_config", config, From 99fb87413e425e832dc3374dc8f7386e09cc096f Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 3 Jun 2022 11:55:02 +0000 Subject: [PATCH 2/9] fix test --- Lib/test/test_embed.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index d903e195f71d90..2e9d39dc25c78a 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1318,10 +1318,11 @@ def test_init_pybuilddir(self): with self.tmpdir_with_python() as tmpdir: # pybuilddir.txt is a sub-directory relative to the current # directory (tmpdir) + vpath = sysconfig.get_config_var("VPATH") subdir = 'libdir' libdir = os.path.join(tmpdir, subdir) # The stdlib dir is dirname(executable) + VPATH + 'Lib' - stdlibdir = os.path.join(tmpdir, 'Lib') + stdlibdir = os.path.normpath(os.path.join(tmpdir, vpath, 'Lib')) os.mkdir(libdir) filename = os.path.join(tmpdir, 'pybuilddir.txt') From 0cdf8fdf39a162399e72bb5212e18b5a36f4469a Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 3 Jun 2022 11:57:02 +0000 Subject: [PATCH 3/9] reduce diff --- Lib/test/test_embed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 2e9d39dc25c78a..20b83c75945e3d 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -497,7 +497,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'pathconfig_warnings': 1, '_init_main': 1, '_isolated_interpreter': 0, - 'use_frozen_modules': int(not support.Py_DEBUG), + 'use_frozen_modules': not support.Py_DEBUG, 'safe_path': 0, '_is_python_build': IGNORE_CONFIG, } @@ -1205,7 +1205,7 @@ def test_init_setpath_config(self): # The current getpath.c doesn't determine the stdlib dir # in this case. 'stdlib_dir': '', - 'use_frozen_modules': int(not support.Py_DEBUG), + 'use_frozen_modules': not support.Py_DEBUG, # overridden by PyConfig 'program_name': 'conf_program_name', 'base_executable': 'conf_executable', @@ -1445,12 +1445,12 @@ def test_init_pyvenv_cfg(self): config['base_prefix'] = pyvenv_home config['prefix'] = pyvenv_home config['stdlib_dir'] = os.path.join(pyvenv_home, 'Lib') - config['use_frozen_modules'] = int(not support.Py_DEBUG) + config['use_frozen_modules'] = not support.Py_DEBUG else: # cannot reliably assume stdlib_dir here because it # depends too much on our build. But it ought to be found config['stdlib_dir'] = self.IGNORE_CONFIG - config['use_frozen_modules'] = int(not support.Py_DEBUG) + config['use_frozen_modules'] = not support.Py_DEBUG env = self.copy_paths_by_env(config) self.check_all_configs("test_init_compat_config", config, From 09b8b9ab4d3acc199159d499732f2327f5c09a55 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 3 Jun 2022 11:59:09 +0000 Subject: [PATCH 4/9] non OOT --- Lib/test/test_embed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 20b83c75945e3d..f5adcdffe4668e 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1318,7 +1318,7 @@ def test_init_pybuilddir(self): with self.tmpdir_with_python() as tmpdir: # pybuilddir.txt is a sub-directory relative to the current # directory (tmpdir) - vpath = sysconfig.get_config_var("VPATH") + vpath = sysconfig.get_config_var("VPATH") or '' subdir = 'libdir' libdir = os.path.join(tmpdir, subdir) # The stdlib dir is dirname(executable) + VPATH + 'Lib' From 912fed36a47f70ff987df40133f5aab79ebe5ae0 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 12:22:45 +0000 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2022-06-03-12-22-44.gh-issue-89858.ftBvjE.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2022-06-03-12-22-44.gh-issue-89858.ftBvjE.rst diff --git a/Misc/NEWS.d/next/Tests/2022-06-03-12-22-44.gh-issue-89858.ftBvjE.rst b/Misc/NEWS.d/next/Tests/2022-06-03-12-22-44.gh-issue-89858.ftBvjE.rst new file mode 100644 index 00000000000000..ef806a93c018cc --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-06-03-12-22-44.gh-issue-89858.ftBvjE.rst @@ -0,0 +1 @@ +Fix ``test_embed`` for out-of-tree builds. Patch by Kumar Aditya. From 390e929f35d4798d5d1951cd10afcecaf952936c Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Wed, 8 Jun 2022 13:07:32 +0000 Subject: [PATCH 6/9] fix windows --- Lib/test/test_embed.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index f5adcdffe4668e..647ce6879687f5 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -78,7 +78,10 @@ def setUp(self): # "Py_Initialize: Unable to get the locale encoding # LookupError: no codec search functions registered: can't find encoding" self.oldcwd = os.getcwd() - os.chdir(builddir) + if MS_WINDOWS: + os.chdir(support.REPO_ROOT) + else: + os.chdir(builddir) def tearDown(self): os.chdir(self.oldcwd) From 72fdd2d88d40f6d169de838caaa567f695fec524 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 10 Jun 2022 10:15:29 +0000 Subject: [PATCH 7/9] remove windows --- Lib/test/test_embed.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 647ce6879687f5..ef6443406b6ccb 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1321,11 +1321,10 @@ def test_init_pybuilddir(self): with self.tmpdir_with_python() as tmpdir: # pybuilddir.txt is a sub-directory relative to the current # directory (tmpdir) - vpath = sysconfig.get_config_var("VPATH") or '' subdir = 'libdir' libdir = os.path.join(tmpdir, subdir) # The stdlib dir is dirname(executable) + VPATH + 'Lib' - stdlibdir = os.path.normpath(os.path.join(tmpdir, vpath, 'Lib')) + stdlibdir = os.path.join(tmpdir, 'Lib') os.mkdir(libdir) filename = os.path.join(tmpdir, 'pybuilddir.txt') From 5c2e3e828763c8bc4b71429b2e8d61065d7e1a14 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 10 Jun 2022 10:38:40 +0000 Subject: [PATCH 8/9] fix it --- Lib/test/test_embed.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index ef6443406b6ccb..647ce6879687f5 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1321,10 +1321,11 @@ def test_init_pybuilddir(self): with self.tmpdir_with_python() as tmpdir: # pybuilddir.txt is a sub-directory relative to the current # directory (tmpdir) + vpath = sysconfig.get_config_var("VPATH") or '' subdir = 'libdir' libdir = os.path.join(tmpdir, subdir) # The stdlib dir is dirname(executable) + VPATH + 'Lib' - stdlibdir = os.path.join(tmpdir, 'Lib') + stdlibdir = os.path.normpath(os.path.join(tmpdir, vpath, 'Lib')) os.mkdir(libdir) filename = os.path.join(tmpdir, 'pybuilddir.txt') From ac481bf7317a8494b1415209af10009ba0d25b4c Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 17 Jun 2022 16:21:17 +0530 Subject: [PATCH 9/9] rebase --- Lib/test/test_embed.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 6493ee9055e528..c7e5663566b06f 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -67,21 +67,16 @@ def setUp(self): ext = ("_d" if debug_build(sys.executable) else "") + ".exe" exename += ext exepath = builddir - expecteddir = os.path.join(support.REPO_ROOT, builddir) else: exepath = os.path.join(builddir, 'Programs') - expecteddir = os.path.join(builddir, 'Programs') self.test_exe = exe = os.path.join(exepath, exename) - if exepath != expecteddir or not os.path.exists(exe): + if not os.path.exists(exe): self.skipTest("%r doesn't exist" % exe) # This is needed otherwise we get a fatal error: # "Py_Initialize: Unable to get the locale encoding # LookupError: no codec search functions registered: can't find encoding" self.oldcwd = os.getcwd() - if MS_WINDOWS: - os.chdir(support.REPO_ROOT) - else: - os.chdir(builddir) + os.chdir(builddir) def tearDown(self): os.chdir(self.oldcwd)