msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.27k stars 1.22k forks source link

python os.scandir uses raw windows paths, not MSYS2 mingw paths #11155

Open ThosRTanner opened 2 years ago

ThosRTanner commented 2 years ago

For example:

$ ls /
InstallationLog.txt  clangarm64.ico      mingw64          ucrt64
autorebase.bat       components.xml      mingw64.exe      ucrt64.exe
bin                  dev                 mingw64.ico      ucrt64.ico
clang32              dir                 mingw64.ini      ucrt64.ini
clang32.exe          etc                 msys2.exe        uninstall.dat
clang32.ico          home                msys2.ico        uninstall.exe
clang32.ini          installer.dat       msys2.ini        uninstall.ini
clang64              installerResources  msys2_shell.cmd  usr
clang64.exe          mingw32             network.xml      var
clang64.ico          mingw32.exe         opt
clang64.ini          mingw32.ico         proc
clangarm64           mingw32.ini         tmp

try that in python:

>>> import os
>>> print(*(os.scandir("/")))
<DirEntry '$Recycle.Bin'> <DirEntry '$WinREAgent'> <DirEntry 'Apps'> <DirEntry 'Documents and Settings'> <DirEntry 'DumpStack.log'> <DirEntry 'DumpStack.log.tmp'> <DirEntry 'easeus_tb_cloud'> <DirEntry 'end'> <DirEntry 'eula.1028.txt'> <DirEntry 'eula.1031.txt'> <DirEntry 'eula.1033.txt'> <DirEntry 'eula.1036.txt'> <DirEntry 'eula.1040.txt'> <DirEntry 'eula.1041.txt'> <DirEntry 'eula.1042.txt'> <DirEntry 'eula.2052.txt'> <DirEntry 'eula.3082.txt'> <DirEntry 'globdata.ini'> <DirEntry 'hiberfil.sys'> <DirEntry 'install.exe'> <DirEntry 'install.ini'> <DirEntry 'install.res.1028.dll'> <DirEntry 'install.res.1031.dll'> <DirEntry 'install.res.1033.dll'> <DirEntry 'install.res.1036.dll'> <DirEntry 'install.res.1040.dll'> <DirEntry 'install.res.1041.dll'> <DirEntry 'install.res.1042.dll'> <DirEntry 'install.res.2052.dll'> <DirEntry 'install.res.3082.dll'> <DirEntry 'Intel'> <DirEntry 'MSI'> <DirEntry 'Nexon'> <DirEntry 'OneDriveTemp'> <DirEntry 'pagefile.sys'> <DirEntry 'PerfLogs'> <DirEntry 'Program Files'> <DirEntry 'Program Files (x86)'> <DirEntry 'ProgramData'> <DirEntry 'Recovery'> <DirEntry 'swapfile.sys'> <DirEntry 'System Volume Information'> <DirEntry 'Users'> <DirEntry 'vcredist.bmp'> <DirEntry 'VC_RED.cab'> <DirEntry 'VC_RED.MSI'> <DirEntry 'Windows'>

which is basically the contents of c:\

That makes it hard to (e.g.) use shutil.copytree to copy directories around

lazka commented 2 years ago

If you need a python which understands unix paths you have to use "/usr/bin/python".

ThosRTanner commented 2 years ago

that doesn't seem to exist with the default install