from distutils.core import setup
import pyang
import glob
import os

modules = glob.glob(os.path.join('modules', '*.yang'))
xslt = glob.glob(os.path.join('xslt', '*.xsl'))

setup(name='pyang',
      version=pyang.__version__,
      author='Martin Bjorklund',
      author_email='mbj@tail-f.com',
      description="A YANG (RFC 6020) validator and converter",
      url='http://code.google.com/p/pyang',
      scripts=['bin/pyang', 'bin/yang2html', 'bin/yang2dsdl'],
      packages=['pyang', 'pyang.plugins', 'pyang.translators'],
      data_files=[('.', ['LICENSE']),
                  ('share/man/man1', ['man/man1/pyang.1',
                                      'man/man1/yang2dsdl.1']),
                  ('share/yang/modules', modules),
                  ('share/yang/xslt', xslt),
                  ('share/yang/schema', ['schema/yin.rng',
                                         'schema/relaxng-lib.rng'])]
      )
      

@@ -26,16 +26,56 @@
 t setup%0A
+from distutils.dist import Distribution%0A
 import p
@@ -100,16 +100,26 @@
 mport os
+%0Aimport re
 %0A%0Amodule
@@ -216,16 +216,1420 @@
 xsl'))%0A%0A
+class PyangDist(Distribution):%0A%0A      %22%22%22The purpose of this subclass of Distribution is to extend the%0A      install procedure with preprocessing of shell scripts and man%0A      pages so that they reflect the actual installation prefix, which%0A      may be changed through the --prefix option.%0A      %22%22%22%0A%0A      def preprocess_files(self, prefix):%0A            %22%22%22Insert the installation prefix where necessary.%0A%0A            The template files have the '.in' suffix and the locations%0A            are marked with '@prefix@'.%0A            %22%22%22%0A            if prefix is None: return%0A            files = (%22bin/yang2dsdl%22, %22man/man1/yang2dsdl.1%22)%0A            regex = re.compile(%22%5E(.*)/usr/local(.*)$%22)%0A            for f in files:%0A                  inf = open(f)%0A                  cnt = inf.readlines()%0A                  inf.close()%0A                  ouf = open(f,%22w%22)%0A                  for line in cnt:%0A                        mo = regex.search(line)%0A                        if mo is None:%0A                              ouf.write(line)%0A                        else:%0A                              ouf.write(mo.group(1) + prefix + mo.group(2) + %22%5Cn%22)%0A                  ouf.close()%0A%0A      def run_commands(self):%0A            opts = self.command_options%0A            if %22install%22 in opts:%0A                  self.preprocess_files(opts%5B%22install%22%5D.get(%22prefix%22, (%22%22, None))%5B1%5D)%0A            Distribution.run_commands(self)%0A%0A
 setup(na
@@ -1806,16 +1806,16 @@
 erter%22,%0A
-
       ur
@@ -1846,24 +1846,51 @@
 m/p/pyang',%0A
+      distclass=PyangDist,%0A
       script

Fix issue 54: extend the distutils procedure.