65
65
return iter(self.d)
67
67
# Rename by preserving relative links
68
def rename_subtle (source, destination):
68
def rename_subtle (source, destination, sourcedir):
69
69
if os.path.islink (source):
70
70
linkdest = os.readlink (source)
71
71
if not os.path.isabs (linkdest):
72
72
linkdest = os.path.normpath(os.path.join(os.path.dirname(source),linkdest))
73
prefix = os.path.dirname(os.path.commonprefix((linkdest, destination)))
74
linkdest = os.path.normpath(destination)[len(prefix)+1:].count('/') * '../' + \
75
linkdest[len(prefix)+1:]
76
destdir = os.path.dirname(destination)
77
if not os.path.isdir (destdir):
79
if os.path.lexists (destination):
80
os.remove (destination)
81
os.symlink (linkdest, destination)
84
os.removedirs(os.path.dirname(source))
73
if not linkdest.startswith(sourcedir+'/'):
74
prefix = os.path.dirname(os.path.commonprefix((linkdest, destination)))
75
linkdest = os.path.normpath(destination)[len(prefix)+1:].count('/') * '../' + \
76
linkdest[len(prefix)+1:]
77
destdir = os.path.dirname(destination)
78
if not os.path.isdir (destdir):
80
if os.path.lexists (destination):
81
os.remove (destination)
82
os.symlink (linkdest, destination)
85
os.removedirs(os.path.dirname(source))
88
89
os.renames (source, destination)
90
91
def do_simple_move (basedir, sourcedir):
93
94
for dir, dirs, files in os.walk (absdir):
94
95
reldir = dir[len(absdir):].lstrip("/")
95
96
for curfile in files:
96
rename_subtle (os.path.join(basedir, sourcedir, reldir, curfile), os.path.join(basedir, modulepath, reldir, curfile))
97
rename_subtle (os.path.join(absdir, reldir, curfile), os.path.join(basedir, modulepath, reldir, curfile), absdir)
97
98
fileset.add(os.path.join("/", modulepath, reldir, curfile))
125
126
destdir=modulepath
126
127
for pyver in file_dict.list(relfile):
127
128
for (pybasedir, suffixdir) in tuples:
128
sourcefile=os.path.join(basedir,pybasedir,pyver,suffixdir,relfile)
129
sourcedir=os.path.join(basedir,pybasedir,pyver,suffixdir)
130
sourcefile=os.path.join(sourcedir,relfile)
129
131
if not os.path.lexists(sourcefile):
144
rename_subtle(sourcefile,os.path.join(basedir,destdir,relfile))
146
rename_subtle(sourcefile,os.path.join(basedir,destdir,relfile),sourcedir)
145
147
files.add(os.path.join("/",destdir,relfile))
147
149
# If we have some versions that appear in the extension path
169
171
for item in os.listdir(pydir):
170
172
item=os.path.join(pydir,item)
171
if os.path.isdir(item) and item.endswith(suffix):
173
if item.endswith(suffix):
172
174
new_item = item[:-len(suffix)]+".egg-info"
173
175
if not os.path.exists(new_item): # You never know
174
176
os.rename(item, new_item)