~ubuntu-branches/ubuntu/natty/python-support/natty

« back to all changes in this revision

Viewing changes to movemodules

  • Committer: lool at dooz
  • Date: 2010-05-14 12:40:10 UTC
  • mfrom: (1.1.8 sid)
  • Revision ID: lool@dooz.org-20100514124010-ls5237kxyau157gd
Tags: 1.0.7ubuntu1
* Merge with Debian; remaining changes:
  - Move python2.4 and 2.5 to oldversions.
* Fix stripping of empty lines in debian/pyversions; LP: #437593;
  closes: #568171.
* Only search for XS-Python-Version in the debian/control general paragraph
  (the first one, for the source package); see Debian #567941;
  closes: #568173.
* Add tests for parseversions.
* Use ./parseversions --all --long to list supported versions during build
  instead of poking pysupport.py_supported directly.
* Cleanup shell snippet / tabs in rules.
* Explicitly strip spaces after parsing debian/pyversions.
* dh_pysupport: fix syntax errors in previous patch.
* README: document that only python is required for arch: all 
  packages, not python-dev. Also talk about python-support itself.
  Closes: #563749.
* dh_pysupport: print an error if the default Python version cannot be 
  found. Closes: #572155.
* parseversions: I hate regexes.
* dh_pysupport: ensure there is a Python dependency even when no 
  specific versions are required. Closes: #568811.
* Non-maintainer upload.
* update-python-modules: set umask to 022. Closes: #567811.
* movemodules: do not touch symlinks that merely point to another 
  place in the module tree. Closes: #539187.
* Rename .egg-info files the same way .egg-info directories are renamed
* dh_pysupport: use mkdir -p instead of the Perl mkdir function.
  Closes: #558392.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
    return iter(self.d)
66
66
 
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):
78
 
        os.makedirs (destdir)
79
 
      if os.path.lexists (destination):
80
 
        os.remove (destination)
81
 
      os.symlink (linkdest, destination)
82
 
      os.remove (source)
83
 
      try:
84
 
        os.removedirs(os.path.dirname(source))
85
 
      except OSError:
86
 
        pass
87
 
      return
 
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):
 
79
          os.makedirs (destdir)
 
80
        if os.path.lexists (destination):
 
81
          os.remove (destination)
 
82
        os.symlink (linkdest, destination)
 
83
        os.remove (source)
 
84
        try:
 
85
          os.removedirs(os.path.dirname(source))
 
86
        except OSError:
 
87
          pass
 
88
        return
88
89
  os.renames (source, destination)
89
90
 
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))
98
99
  return fileset
99
100
 
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):
130
132
          continue
131
133
        if splitfile:
141
143
          except OSError:
142
144
            pass
143
145
        else:
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))
146
148
  if pyversions:
147
149
    # If we have some versions that appear in the extension path
168
170
      continue
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)