Skip to content

Commit 79d2269

Browse files
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>
1 parent 2b7fc1b commit 79d2269

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/test/test_embed.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,16 @@ def setUp(self):
6868
ext = ("_d" if debug_build(sys.executable) else "") + ".exe"
6969
exename += ext
7070
exepath = builddir
71-
expecteddir = os.path.join(support.REPO_ROOT, builddir)
7271
else:
7372
exepath = os.path.join(builddir, 'Programs')
74-
expecteddir = os.path.join(support.REPO_ROOT, 'Programs')
7573
self.test_exe = exe = os.path.join(exepath, exename)
76-
if exepath != expecteddir or not os.path.exists(exe):
74+
if not os.path.exists(exe):
7775
self.skipTest("%r doesn't exist" % exe)
7876
# This is needed otherwise we get a fatal error:
7977
# "Py_Initialize: Unable to get the locale encoding
8078
# LookupError: no codec search functions registered: can't find encoding"
8179
self.oldcwd = os.getcwd()
82-
os.chdir(support.REPO_ROOT)
80+
os.chdir(builddir)
8381

8482
def tearDown(self):
8583
os.chdir(self.oldcwd)
@@ -1316,10 +1314,11 @@ def test_init_pybuilddir(self):
13161314
with self.tmpdir_with_python() as tmpdir:
13171315
# pybuilddir.txt is a sub-directory relative to the current
13181316
# directory (tmpdir)
1317+
vpath = sysconfig.get_config_var("VPATH") or ''
13191318
subdir = 'libdir'
13201319
libdir = os.path.join(tmpdir, subdir)
13211320
# The stdlib dir is dirname(executable) + VPATH + 'Lib'
1322-
stdlibdir = os.path.join(tmpdir, 'Lib')
1321+
stdlibdir = os.path.normpath(os.path.join(tmpdir, vpath, 'Lib'))
13231322
os.mkdir(libdir)
13241323

13251324
filename = os.path.join(tmpdir, 'pybuilddir.txt')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix ``test_embed`` for out-of-tree builds. Patch by Kumar Aditya.

0 commit comments

Comments
 (0)