Does anyone know of a way to make/read symbolic links across versions of win32 from Python? Ideally there should be a minimum amount of platform specific code, as I need my app to be cross platform.
Problem is, as explained e.g. here, that Windows' own support for the functionality of symbolic links varies across Windows releases, so that e.g. in Vista (with lots of work) you can get more functionality than in XP or 2000 (nothing AFAIK on other win32 versions). Or you could have shortcuts instead, which of course have their own set of limitations and aren't "really" equivalent to Unix symbolic links. So, you have to specify exactly what functionalities you require, how much of those you are willing to sacrifice on the altar of cross-win32 operation, etc -- THEN, we can work out how to implement the compromise you've chosen in terms of ctypes
or win32all
calls... that's the least of it, in a sense.
NTFS file system has junction points, i think you may use them instead
copied from my answer to http://stackoverflow.com/questions/1143260/create-ntfs-junction-point-in-python
you can use python win32 API modules e.g.
import win32file
win32file.CreateSymbolicLink(fileSrc, fileTarget, 1)
see http://docs.activestate.com/activepython/2.5/pywin32/win32file%5F%5FCreateSymbolicLink%5Fmeth.html for more details
if you do not want to rely on that too, you can always use ctypes and directly call CreateSymbolicLinl win32 API, which is anyway a simple call
here is example call using ctypes
import ctypes
kdll = ctypes.windll.LoadLibrary("kernel32.dll")
kdll.CreateSymbolicLinkA("d:\test.txt", "d:\test_link.txt", 0)
MSDN (http://msdn.microsoft.com/en-us/library/aa363866%28VS.85%29.aspx) says Minimum supported client Windows Vista