MCPcopy Index your code
hub / github.com/python/cpython / _create_underpth_exe

Method _create_underpth_exe

Lib/test/test_site.py:655–673  ·  view source on GitHub ↗
(self, lines, exe_pth=True)

Source from the content-addressed store, hash-verified

653
654 if sys.platform == 'win32':
655 def _create_underpth_exe(self, lines, exe_pth=True):
656 import _winapi
657 temp_dir = tempfile.mkdtemp()
658 self.addCleanup(os_helper.rmtree, temp_dir)
659 exe_file = os.path.join(temp_dir, os.path.split(sys.executable)[1])
660 dll_src_file = _winapi.GetModuleFileName(sys.dllhandle)
661 dll_file = os.path.join(temp_dir, os.path.split(dll_src_file)[1])
662 shutil.copy(sys.executable, exe_file)
663 shutil.copy(dll_src_file, dll_file)
664 for fn in glob.glob(os.path.join(os.path.split(dll_src_file)[0], "vcruntime*.dll")):
665 shutil.copy(fn, os.path.join(temp_dir, os.path.split(fn)[1]))
666 if exe_pth:
667 _pth_file = os.path.splitext(exe_file)[0] + '._pth'
668 else:
669 _pth_file = os.path.splitext(dll_file)[0] + '._pth'
670 with open(_pth_file, 'w', encoding='utf8') as f:
671 for line in lines:
672 print(line, file=f)
673 return exe_file
674 else:
675 def _create_underpth_exe(self, lines, exe_pth=True):
676 if not exe_pth:

Callers 5

test_underpth_basicMethod · 0.95
test_underpth_fileMethod · 0.95

Calls 8

mkdtempMethod · 0.80
addCleanupMethod · 0.80
splitextMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
splitMethod · 0.45
copyMethod · 0.45
globMethod · 0.45

Tested by

no test coverage detected