user/pylib
ui
...
project2/pylib
ui
...
project3/pylib
ui
...
python-packages/user => /user/pylib
project2 => /project2/pylib
project3 => /project3/pylib
The idea is that "python-packages" is added to sys.path and then every
project can import the library package from every other project. NOTE: I
think that this structure is crazy but I'm just the poor maintenance
programmer.
Anyway, the problem is that Windows does not have a symlink facility to
accommodate this (AFAIK) and the Python import mechanism does not
resolve shortcuts.
Therefore, I wrote a very simple import hook to get around that problem.
If you are interested, the code is here:
http://www.sweetapp.com/shortcut/shortcutimporter.py
BTW, does anyone else think that this functionality should be part of
core Python?
Cheers,
Brian
I wonder (but haven't yet figured out) if something similar can be achived
with pkgutil and one or more .pkg files.
Thomas
> Anyway, the problem is that Windows does not have a symlink facility to
> accommodate this (AFAIK) and the Python import mechanism does not
> resolve shortcuts.
Windows does have the equivalent of symlinks provided you are running on
NTFS with Windows 2000 or later (Google for 'XP junction'). However, by
default the system provides no support for manipulating junction points, so
they are only really useful in an environment where you can control the
tools on the system, not something you can expect to use on arbitrary
systems.
Roger
"Brian Quinlan" <br...@sweetapp.com> wrote in message news:mailman.5014.1146058...@python.org...
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
| You can use win32file.DeviceIoControl to link directories.
| I can post some code to do so if anyone's interested.
I'd certainly be interested...
Thanks
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
import win32con, winioctlcon, winnt
import win32file, win32api
import os, struct
temp_dir=win32api.GetTempPath()
temp1=win32api.GetTempFileName(temp_dir,'rpp')[0]
win32file.DeleteFile(temp1)
os.mkdir(temp1)
temp2=win32api.GetTempFileName(temp_dir,'rpp')[0]
win32file.DeleteFile(temp2)
os.mkdir(temp2)
print temp1, temp2
temp2_abs=u'\\??\\'+temp2
printname=unicode(os.path.split(temp2)[1])
temp2buf=buffer(temp2_abs)[:]
printnamebuf=buffer(printname)[:]
## ???? need figure out how print name should be placed in the buffer, think it needs to follow an
## explicit double null terminator after the target string
printnamebuf=''
databufsize=len(temp2buf)+len(printnamebuf) ## final size includes everything past the reparse tag
fmt="LHHHHHH%ss" %(databufsize+4)
buf=struct.pack(fmt, winnt.IO_REPARSE_TAG_MOUNT_POINT,
databufsize+12, 0, 0, len(temp2buf), len(temp2buf)+2,
len(printnamebuf), temp2buf+printnamebuf+'\0\0\0\0')
bufsize=struct.calcsize(fmt)
h = win32file.CreateFile(temp1, win32con.GENERIC_READ|win32con.GENERIC_WRITE,
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE|win32con.FILE_SHARE_DELETE, None,
win32con.OPEN_EXISTING, win32file.FILE_FLAG_BACKUP_SEMANTICS|win32file.FILE_FLAG_OPEN_REPARSE_POINT, 0)
## old_buf=win32file.DeviceIoControl(h, winioctlcon.FSCTL_GET_REPARSE_POINT,'',winnt.MAXIMUM_REPARSE_DATA_BUFFER_SIZE,None)
win32file.DeviceIoControl(h, winioctlcon.FSCTL_SET_REPARSE_POINT, buf, 0, None)
## create a subdir in redirected dir and make sure it shows up in target dir
os.mkdir(os.path.join(temp1,'new_dir'))
assert os.path.isdir(os.path.join(temp2,'new_dir'))
h.Close()
Roger
"Tim Golden" <tim.g...@viacom-outdoor.co.uk> wrote in message news:mailman.5039.1146126...@python.org...
| [... snipped ugly code ...]
Thanks; I'll have to find the time to experiment
with that a bit.