Skip to content
Merged
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
GH-89858: Fix test_embed for out-of-tree builds (GH-93465)
(cherry picked from commit 96464e5)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
kumaraditya303 authored and miss-islington committed Jun 17, 2022
commit 2def8da2adb1329c79e06f870c6ccf0f18e66174
9 changes: 4 additions & 5 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,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(support.REPO_ROOT, '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()
os.chdir(support.REPO_ROOT)
os.chdir(builddir)

def tearDown(self):
os.chdir(self.oldcwd)
Expand Down Expand Up @@ -1316,10 +1314,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')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``test_embed`` for out-of-tree builds. Patch by Kumar Aditya.