[PATCH 0 of 6] reStructuredText help output

Dan Villiom Podlaski Christiansen danchr at gmail.com
Fri Jul 10 07:36:13 CDT 2009


On 10/07/2009, at 13.54, Martin Geisler wrote:

> Hello everybody,
>
> I've been talking about using reStructuredText for the help strings
> and a couple of days ago I took at stab at turning the talk into code.

That's very nice indeed!

I once wrote up a small patch for installing the Zsh completion script  
through setup.py, hoping that it could be useful for something like  
this :)

It might be useful for you if you figure out how to integrate the  
generated files with distutils; I've attached it below. (It's a bit of  
a test, too, to see if Mail screws up inline patches.)

--

Dan Villiom Podlaski Christiansen
danchr at gmail.com

----------------------------
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1247229008 -7200
# Node ID 2bd3c7b98188e6c9867c2a0fa0af8457de67bc4a
# Parent  a507bac702f1cb8fd2adef5965a924f1285d461d
setup: allow installation of data files into the regular data dir.

The Zsh completion script is used as an example and test case.
diff --git a/contrib/zsh_completion b/contrib/zsh/_hg
rename from contrib/zsh_completion
rename to contrib/zsh/_hg
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -157,9 +157,16 @@ except ImportError:

  class install_package_data(install_data):
      def finalize_options(self):
+        self.install_lib = None
          self.set_undefined_options('install',
-                                   ('install_lib', 'install_dir'))
+                                   ('install_lib', 'install_lib'))
          install_data.finalize_options(self)
+        self.install_lib = self.install_lib.rstrip(os.sep)
+        def expandoptions((k, v)):
+            if '[install_lib]' in k:
+                k = k.replace('[install_lib]', self.install_lib)
+            return k, v
+        self.data_files = map(expandoptions, self.data_files)

  class build_mo(build):

@@ -189,7 +196,8 @@ class build_mo(build):
                  cmd.append('-c')
              self.mkpath(modir)
              self.make_file([pofile], mofile, spawn, (cmd,))
-            self.distribution.data_files.append((join('mercurial',  
modir),
+            self.distribution.data_files.append((join('[install_lib]',
+                                                      'mercurial',  
modir),
                                                   [mofile]))

  build.sub_commands.append(('build_mo', None))
@@ -245,10 +253,11 @@ if sys.platform == 'linux2' and os.uname
                                       ['hgext/inotify/linux/ 
_inotify.c']))
          packages.extend(['hgext.inotify', 'hgext.inotify.linux'])

-datafiles = []
+datafiles = [('zsh/site-functions', ['contrib/zsh/_hg'])]
+
  for root in ('templates', 'i18n'):
      for dir, dirs, files in os.walk(root):
-        datafiles.append((os.path.join('mercurial', dir),
+        datafiles.append((os.path.join('[install_lib]', 'mercurial',  
dir),
                            [os.path.join(dir, file_) for file_ in  
files]))

  setup(name='mercurial',

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1943 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090710/1f78cd3a/attachment.bin 


More information about the Mercurial-devel mailing list