[patch] Alexander's win32 packaging patch

Martin Pool mbp at canonical.com
Wed May 10 08:06:05 BST 2006


This is the patch from http://bzr.onembedding.com/bzr.win/patches/

I've read through it and it seems reasonable to merge; and it shouldn't
break anything on Unix.  Any other comments?

My only query which perhaps Robert can comment on is this new test:

> === modified file 'bzrlib/tests/test_setup.py'
> --- bzrlib/tests/test_setup.py	
> +++ bzrlib/tests/test_setup.py	
> @@ -47,3 +49,37 @@
>          finally:
>              if os.path.exists('build'):
>                  osutils.rmtree(u'build')
> +
> +    def test_metainfo(self):
> +        """Test consistency of META INFO passed to setup() function"""
> +        self.log('test_metainfo running in %s' % os.getcwd())
> +
> +        meta_should_be = {'name':         'bzr',
> +                          # TODO: pick version info from bzrlib itself?
> +                          'version':      '0.8',
> +                          'author':       'Martin Pool',
> +                          'author-email': 'mbp at sourcefrog.net',
> +                          'url':          'http://www.bazaar-ng.org/',
> +                          'description':  'Friendly distributed version control system',
> +                          'license':      'GNU GPL v2',
> +
> +                          # ensure there is no extra info
> +                          'maintainer':       'UNKNOWN',
> +                          'maintainer-email': 'UNKNOWN',
> +                          'long-description': 'UNKNOWN',
> +                          'platforms':        'UNKNOWN',
> +                          'classifiers':      '',
> +                          'keywords':         '',
> +                         }
> +
> +        for key, value in meta_should_be.iteritems():
> +            p = subprocess.Popen([sys.executable, 'setup.py', '--%s' % key],
> +                                 stdout=subprocess.PIPE,
> +                                 stderr=subprocess.PIPE)
> +            stdout, stderr = p.communicate()
> +
> +            self.assertEqual(0, p.returncode,
> +                             'failed to retrive meta info %s from setup.py' % key)
> +            self.assertEqualDiff(value, stdout.rstrip('\r\n'),
> +                                 'returned meta info %s is incorrect\n' % key)
> +            self.assertEqual('', stderr, 'stderr should be clear')

More tests are certainly welcome but I'm just not quite sure this tests
quite the right thing - the most likely thing to go wrong with those
values is that we'll fail to update them and this may not catch it.

-- 
Martin
-------------- next part --------------
=== added file 'bzr.ico'
Binary files /dev/null and bzr.ico differ
=== added file 'doc/default.css'
--- /dev/null	
+++ doc/default.css	
@@ -0,0 +1,142 @@
+/* from John Arbash Meinel's `Short tutorial' */
+
+body {
+  background-color: #ffffff;
+  color: #303030;
+  margin-top: 50px;
+  margin-left: 50px;
+  margin-right: 50px;
+  margin-bottom: 70px;
+  font-family: Verdana, Geneva, Arial, sans-serif;
+  font-size: small;
+  line-height: 180%
+  }
+
+/* p {
+  text-indent: 3em
+} */
+
+h1.title {
+  text-align: center;
+  color: #000000;
+  font-family: Georgia, "Time New Roman", Times, serif;
+  font-size: 1.8em;
+  }
+
+
+div.contents p {
+  font-weight: bold;
+  }
+
+div.contents p a:hover {
+  color: inherit;
+  }
+
+h1 {
+  color: #b52b2b; 
+  /* DKREDcolor: #966b72; */
+  /* GREY color: #444444; */
+  font-family: Georgia, "Time New Roman", Times, serif;
+  font-size: 1.5em;
+  }
+
+h1 a:link {
+  color: inherit;
+  }
+  
+h1 a:hover {
+  color: inherit;
+  }
+
+h1 a:visited {
+  color: inherit;
+  }
+
+h2 {
+  color: #222;
+  /* RED color: #966b72; */
+  text-decoration: underline;
+  font-family: Georgia, "Time New Roman", Times, serif;
+  font-size: 1.4em;
+  }
+
+h2 a:link {
+  color: inherit;
+  }
+
+h2 a:hover {
+  color: inherit;
+  }
+
+h2 a:visited {
+  color: inherit;
+  }
+
+h3 {
+  color: #966b72; 
+  /* color: #966b72; */
+  font-family: Georgia, "Time New Roman", Times, serif;
+  }
+
+h3 a:link {
+  color: inherit;
+  }
+
+h3 a:hover {
+  color: inherit;
+  }
+
+h3 a:visited {
+  color: inherit;
+  }
+
+dt {
+  color: #000000;
+  font-weight: bold;
+  }
+/*
+  border: 4px solid blue;
+  padding: 1ex;
+  background: #7777FF;
+        }
+dt:hover 
+  {
+  background-color: black;
+  }
+dt:active
+  {
+  background-color: red;
+  }
+*/
+
+tt {
+  color: #000000;
+  font-weight: normal;
+  font-family: "Lucida", "Monaco", "Courier", Monospace;
+  }
+
+.literal-block {
+  margin-left: 5em;
+  color: #000000;
+  font-weight: normal;
+  font-family: "Lucida", "Monaco", "Courier", Monospace;
+  background-color: #c1d1ff;
+  background-color: #e5ecf9;
+  border: 1px solid #888888;
+  padding: 1em;
+  }
+
+a:link {
+  color: #4c52ff;
+  text-decoration: none;
+  }
+
+a:visited {
+  color: #4c53ff;
+  text-decoration: none;
+  }
+
+a:hover {
+  color: #b52727;
+  text-decoration: none;
+  }

=== added file 'doc/index.txt'
--- /dev/null	
+++ doc/index.txt	
@@ -0,0 +1,42 @@
+=========
+Bazaar-NG
+=========
+-------------------
+Documentation index
+-------------------
+
+These documents originally came from the Bazaar-NG wiki hosted at
+http://bazaar-vcs.org. The documents on the wiki take precedence 
+in the event of a discrepancy between what is documented here 
+and what is documented on the wiki.
+
+
+* `Tutorial <tutorial.htm>`_
+
+    Explains how to use bzr. Loaded with examples.
+
+* `Configuration <configuration.htm>`_
+
+    Information on how to configure Bazaar-NG
+
+* `Setting up email <setting_up_email.htm>`_
+
+    The various ways that exist to tell Bazaar-NG your email address for
+    commits
+
+* `Plugins <plugins.htm>`_
+    
+    Information on how to use plugins in Bazaar-NG
+
+* `Specifying revision <specifying_revisions.htm>`_
+
+    Description of the subarguments for ``-r`` as used by commands such as
+    **bzr log** and **bzr merge**
+
+* `Using aliases <using_aliases.htm>`_
+
+    How to setup and use command aliases.
+
+This document automatically created based on output of **bzr help**:
+
+* `Man page (help for bzr commands) <bzr_man.htm>`_

=== added directory 'tools/win32'
=== added file 'tools/win32/bazaar.url'
--- /dev/null	
+++ tools/win32/bazaar.url	
@@ -0,0 +1,7 @@
+[InternetShortcut]
+URL=http://bazaar-vcs.org/
+Hotkey=0
+IconIndex=0
+IconFile=
+WorkingDirectory=
+ShowCommand=1

=== added file 'tools/win32/bzr.iss'
--- /dev/null	
+++ tools/win32/bzr.iss	
@@ -0,0 +1,50 @@
+; Script for Inno Setup installer
+
+[Setup]
+AppName=Bazaar-NG (Bzr)
+
+; [[[cog
+; import bzrlib
+; try: 
+;     VERSION = bzrlib.__version__
+;     cog.outl('AppVerName=Bzr %s' % VERSION)  
+;     cog.outl('OutputBaseFilename=bzr-setup-%s' % VERSION)
+; except:
+;     cog.outl('AppVerName=Bzr')
+;     cog.outl('OutputBaseFilename=bzr-setup')
+; ]]]
+AppVerName=Bzr 0.8
+OutputBaseFilename=bzr-setup-0.8
+;[[[end]]]
+
+DefaultDirName={pf}\Bazaar-NG
+DefaultGroupName=Bazaar-NG
+SolidCompression=yes
+OutputDir="..\"
+SourceDir="..\..\win32_bzr.exe"
+
+[Files]
+Source: "*.*"; DestDir: "{app}"; Flags: ignoreversion
+Source: "lib\*.*"; DestDir: "{app}\lib"; Flags: createallsubdirs ignoreversion recursesubdirs
+Source: "doc\*.*"; DestDir: "{app}\doc"; Flags: createallsubdirs ignoreversion recursesubdirs
+
+[Dirs]
+Name: "{userappdata}\bazaar\2.0"
+
+[Icons]
+Name: "{group}\Documentation index"; Filename: "{app}\doc\index.htm"; WorkingDir: "{app}\doc";
+Name: "{group}\Bazaar-NG Home Page"; Filename: "{app}\bazaar.url";
+Name: "{group}\Start Bzr in cmd shell"; Filename: "{app}\start_bzr.bat"; WorkingDir: "{app}"; IconFilename: "{app}\bzr.exe"
+Name: "{group}\Uninstall Bzr"; Filename: "{uninstallexe}"
+
+[Run]
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--start-bzr"; Flags: skipifdoesntexist
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--add-path"; Description: "Add {app} directory to PATH environment variable"; Flags: skipifdoesntexist postinstall skipifsilent;
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--add-path --silent"; Description: "Add {app} directory to PATH environment variable"; Flags: skipifdoesntexist postinstall skipifnotsilent;
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--add-shell-menu"; Description: "Add Bzr context menu to shell"; Flags: skipifdoesntexist postinstall skipifsilent;
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--add-shell-menu --silent"; Description: "Add Bzr context menu to shell"; Flags: skipifdoesntexist postinstall skipifnotsilent;
+
+[UninstallRun]
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--delete-path"; Flags: skipifdoesntexist;
+Filename: "{app}\bzr_postinstall.exe"; Parameters: "--delete-shell-menu"; Flags: skipifdoesntexist;
+

=== added file 'tools/win32/bzr_postinstall.py'
--- /dev/null	
+++ tools/win32/bzr_postinstall.py	
@@ -0,0 +1,218 @@
+# bzr postinstall helper for win32 installation
+# Written by Alexander Belchenko, 2006
+
+import sys
+
+
+##
+# CONSTANTS
+
+VERSION = "1.0.20060508"
+
+USAGE = """Bzr postinstall helper for win32 installation
+%s [options]
+
+OPTIONS:
+    -h, --help                  - help message
+    -v, --version               - version info
+
+    -n, --dry-run               - print actions rather than execute them
+    -q, --silent                - no messages for user
+
+    --start-bzr                 - update start_bzr.bat
+    --add-path                  - add bzr directory to environment PATH
+    --delete-path               - delete bzr directory to environment PATH
+    --add-shell-menu            - add shell context menu to start bzr session
+    --delete-shell-menu         - delete context menu from shell
+""" % sys.argv[0]
+
+##
+# INTERNAL VARIABLES
+
+(OK, ERROR) = range(2)
+VERSION_FORMAT = "%-50s%s"
+
+
+def main():
+    import getopt
+    import os
+    import _winreg
+
+    import locale
+    user_encoding = locale.getpreferredencoding() or 'ascii'
+
+    import win32ui      # from pywin32
+
+    hkey_str = {_winreg.HKEY_LOCAL_MACHINE: 'HKEY_LOCAL_MACHINE',
+                _winreg.HKEY_CURRENT_USER: 'HKEY_CURRENT_USER',
+                _winreg.HKEY_CLASSES_ROOT: 'HKEY_CLASSES_ROOT',
+               }
+
+    dry_run = False
+    silent = False
+    start_bzr = False
+    add_path = False
+    delete_path = False
+    add_shell_menu = False
+    delete_shell_menu = False
+
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "hvnq",
+                                   ["help", "version",
+                                    "dry-run",
+                                    "silent",
+                                    "start-bzr",
+                                    "add-path",
+                                    "delete-path",
+                                    "add-shell-menu",
+                                    "delete-shell-menu",
+                                   ])
+
+        for o, a in opts:
+            if o in ("-h", "--help"):
+                print USAGE
+                return OK
+            elif o in ("-v", "--version"):
+                print VERSION_FORMAT % (USAGE.splitlines()[0], VERSION)
+                return OK
+
+            elif o in ('-n', "--dry-run"):
+                dry_run = True
+            elif o in ('-q', '--silent'):
+                silent = True
+
+            elif o == "--start-bzr":
+                start_bzr = True
+            elif o == "--add-path":
+                add_path = True
+            elif o == "--delete-path":
+                delete_path = True
+            elif o == "--add-shell-menu":
+                add_shell_menu = True
+            elif o == "--delete-shell-menu":
+                delete_shell_menu = True
+
+    except getopt.GetoptError, msg:
+        print str(msg)
+        print USAGE
+        return ERROR
+
+    bzr_dir = os.path.dirname(sys.argv[0])
+
+    if start_bzr:
+        fname = os.path.join(bzr_dir, "start_bzr.bat")
+        if os.path.isfile(fname):
+            f = file(fname, "r")
+            s = f.read()
+            f.close()
+        else:
+            s = "@start cmd /K bzr help\n"
+        
+        s = s.replace(' bzr ', ' "%s" ' % os.path.join(bzr_dir, 'bzr'))
+
+        if dry_run:
+            print "*** Write file: start_bzr.bat"
+            print "*** File content:"
+            print s
+        else:
+            f = file(fname, 'w')
+            f.write(s)
+            f.close()
+
+    if add_path or delete_path:
+        # find appropriate registry key:
+        # 1. HKLM\System\CurrentControlSet\Control\SessionManager\Environment
+        # 2. HKCU\Environment
+        keys = ((_winreg.HKEY_LOCAL_MACHINE, (r'System\CurrentControlSet\Control'
+                                              r'\Session Manager\Environment')),
+                (_winreg.HKEY_CURRENT_USER, r'Environment'),
+               )
+
+        hkey = None
+        for key, subkey in keys:
+            try:
+                hkey = _winreg.OpenKey(key, subkey, 0, _winreg.KEY_ALL_ACCESS)
+                try:
+                    path_u, type_ = _winreg.QueryValueEx(hkey, 'Path')
+                except WindowsError:
+                    if key != _winreg.HKEY_CURRENT_USER:
+                        _winreg.CloseKey(hkey)
+                        hkey = None
+                        continue
+                    else:
+                        path_u = u''
+                        type_ = _winreg.REG_SZ
+            except EnvironmentError:
+                continue
+            break
+
+        if hkey is None:
+            print "Cannot find appropriate registry key for PATH"
+        else:
+            path_list = [i for i in path_u.split(os.pathsep) if i != '']
+            f_change = False
+            for ix, item in enumerate(path_list[:]):
+                if item == bzr_dir:
+                    if delete_path:
+                        del path_list[ix]
+                        f_change = True
+                    elif add_path:
+                        print "*** Bzr already in PATH"
+                    break
+            else:
+                if add_path and not delete_path:
+                    path_list.append(bzr_dir.decode(user_encoding))
+                    f_change = True
+
+            if f_change:
+                path_u = os.pathsep.join(path_list)
+                if dry_run:
+                    print "*** Registry key %s\\%s" % (hkey_str[key], subkey)
+                    print "*** Modify PATH variable. New value:"
+                    print path_u
+                else:
+                    _winreg.SetValueEx(hkey, 'Path', 0, type_, path_u)
+                    _winreg.FlushKey(hkey)
+                    if add_path and not silent:
+                        win32ui.MessageBox('Please, reboot your machine',
+                                           'PATH changed')
+
+        if not hkey is None:
+            _winreg.CloseKey(hkey)
+
+    if add_shell_menu and not delete_shell_menu:
+        hkey = None
+        try:
+            hkey = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
+                                     r'Folder\shell\bzr')
+        except EnvironmentError:
+            if not silent:
+                win32ui.MessageBox('Unable to create registry key for context menu',
+                                   'EnvironmentError')
+
+        if not hkey is None:
+            _winreg.SetValue(hkey, '', _winreg.REG_SZ, 'Bzr Here')
+            hkey2 = _winreg.CreateKey(hkey, 'command')
+            _winreg.SetValue(hkey2, '', _winreg.REG_SZ,
+                             os.path.join(bzr_dir, 'start_bzr.bat'))
+            _winreg.CloseKey(hkey2)
+            _winreg.CloseKey(hkey)
+
+    if delete_shell_menu:
+        try:
+            _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
+                              r'Folder\shell\bzr\command')
+        except EnvironmentError:
+            pass
+
+        try:
+            _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
+                              r'Folder\shell\bzr')
+        except EnvironmentError:
+            pass
+
+    return OK
+
+
+if __name__ == "__main__":
+    sys.exit(main())

=== added file 'tools/win32/copy_docs.py'
--- /dev/null	
+++ tools/win32/copy_docs.py	
@@ -0,0 +1,15 @@
+import glob
+import os
+import shutil
+
+TGT_DIR = 'win32_bzr.exe/doc'
+
+if not os.path.exists(TGT_DIR):
+    os.makedirs(TGT_DIR)
+
+for i in glob.glob('doc/*.htm'):
+    shutil.copy(i, os.path.join('win32_bzr.exe', i))
+
+CSS = 'doc/default.css'
+if os.path.isfile(CSS):
+    shutil.copy(CSS, os.path.join('win32_bzr.exe', CSS))

=== added file 'tools/win32/start_bzr.bat'
--- /dev/null	
+++ tools/win32/start_bzr.bat	
@@ -0,0 +1,1 @@
+ at start cmd /K bzr help

=== modified file '.bzrignore'
--- .bzrignore	
+++ .bzrignore	
@@ -20,3 +20,7 @@
 ./tags
 .bzr-shelf
 BRANCH-INFO
+fte.dsk
+doc/*.htm
+doc/bzr_man.txt
+py2exe.log

=== modified file 'Makefile'
--- Makefile	
+++ Makefile	
@@ -21,5 +21,35 @@
 TAGS: $(tag_files)
 	ctags-exuberant -e $(tag_files)
 
-tutorial.html: tutorial.txt
-	rest2html tutorial.txt > tutorial.html
+
+# make bzr.exe for win32 with py2exe
+exe:
+	@echo Make bzr.exe
+	setup.py py2exe > py2exe.log
+
+# translate txt docs to html
+doc_dir := doc 
+txt_files := $(wildcard $(addsuffix /*.txt, $(doc_dir)))
+htm_files := $(patsubst %.txt, %.htm, $(txt_files)) doc/bzr_man.htm
+
+%.htm: %.txt
+	rst2html.py $*.txt $*.htm
+
+doc/bzr_man.txt:
+	generate_docs.py -o doc/bzr_man.txt rstx
+
+docs: $(htm_files)
+
+copy_docs: docs
+	copy /Y NEWS win32_bzr.exe\NEWS
+	copy /Y README win32_bzr.exe\README
+	python tools/win32/copy_docs.py
+
+# win32 installer for bzr.exe
+installer: exe copy_docs
+	@echo Make windows installer
+	copy /Y tools\win32\start_bzr.bat win32_bzr.exe\start_bzr.bat
+	copy /Y tools\win32\bazaar.url win32_bzr.exe\bazaar.url
+
+	cog.py -r tools\win32\bzr.iss
+	"C:\Program Files\Inno Setup 5\iscc" /Q tools\win32\bzr.iss

=== modified file 'bzr' (properties changed)
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	
+++ bzrlib/builtins.py	
@@ -1830,7 +1830,7 @@
         if rh:
             print "  revid: %s" % (rh[-1],)
     print bzrlib.__copyright__
-    print "http://bazaar-ng.org/"
+    print "http://bazaar-vcs.org/"
     print
     print "bzr comes with ABSOLUTELY NO WARRANTY.  bzr is free software, and"
     print "you may use, modify and redistribute it under the terms of the GNU"

=== modified file 'bzrlib/tests/test_setup.py'
--- bzrlib/tests/test_setup.py	
+++ bzrlib/tests/test_setup.py	
@@ -32,8 +32,10 @@
 
     def test_build(self):
         """ test cmd `python setup.py build`
-        
-        This typically catches new subdirectories which weren't added to setup.py
+
+        This test ensure that build process run correct.
+        Ensure that man generator works correct.
+        Also can catches new subdirectories which weren't added to setup.py
         """
         self.log('test_build running in %s' % os.getcwd())
         try:
@@ -47,3 +49,37 @@
         finally:
             if os.path.exists('build'):
                 osutils.rmtree(u'build')
+
+    def test_metainfo(self):
+        """Test consistency of META INFO passed to setup() function"""
+        self.log('test_metainfo running in %s' % os.getcwd())
+
+        meta_should_be = {'name':         'bzr',
+                          # TODO: pick version info from bzrlib itself?
+                          'version':      '0.8',
+                          'author':       'Martin Pool',
+                          'author-email': 'mbp at sourcefrog.net',
+                          'url':          'http://www.bazaar-ng.org/',
+                          'description':  'Friendly distributed version control system',
+                          'license':      'GNU GPL v2',
+
+                          # ensure there is no extra info
+                          'maintainer':       'UNKNOWN',
+                          'maintainer-email': 'UNKNOWN',
+                          'long-description': 'UNKNOWN',
+                          'platforms':        'UNKNOWN',
+                          'classifiers':      '',
+                          'keywords':         '',
+                         }
+
+        for key, value in meta_should_be.iteritems():
+            p = subprocess.Popen([sys.executable, 'setup.py', '--%s' % key],
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+            stdout, stderr = p.communicate()
+
+            self.assertEqual(0, p.returncode,
+                             'failed to retrive meta info %s from setup.py' % key)
+            self.assertEqualDiff(value, stdout.rstrip('\r\n'),
+                                 'returned meta info %s is incorrect\n' % key)
+            self.assertEqual('', stderr, 'stderr should be clear')

=== modified file 'bzrlib/weave.py' (properties changed)
=== modified file 'doc/configuration.txt'
--- doc/configuration.txt	
+++ doc/configuration.txt	
@@ -1,3 +1,9 @@
+=======================
+Bazaar-NG configuration
+=======================
+
+Information on how to configure Bazaar-NG.
+
 Location of configuration file
 ==============================
 Each user gets a pair of configurations files in $HOME/.bazaar. The first

=== modified file 'doc/plugins.txt'
--- doc/plugins.txt	
+++ doc/plugins.txt	
@@ -1,3 +1,9 @@
+=================
+Bazaar-NG plugins
+=================
+
+Information on how to use plugins in Bazaar-NG.
+
 What is a Plugin
 ================
 A plugin is an external component for Bazaar-NG that is typically made by

=== modified file 'doc/setting_up_email.txt'
--- doc/setting_up_email.txt	
+++ doc/setting_up_email.txt	
@@ -1,3 +1,10 @@
+================
+Setting up email
+================
+
+The various ways that exist to tell Bazaar-NG your email address for
+commits.
+
 Why set up an email address with Bazaar-NG?
 ===========================================
 Bazaar-NG stores the claimed email address in revisions when they're

=== modified file 'doc/specifying_revisions.txt'
--- doc/specifying_revisions.txt	
+++ doc/specifying_revisions.txt	
@@ -1,3 +1,10 @@
+================================
+Specifying revision in Bazaar-NG
+================================
+
+Description of the subarguments for ``-r`` as used by commands such as
+**bzr log** and **bzr merge**.
+
 Revision specs and ranges
 =========================
 

=== modified file 'doc/using_aliases.txt'
--- doc/using_aliases.txt	
+++ doc/using_aliases.txt	
@@ -1,4 +1,8 @@
-Command aliases are an eay way to customize the behaviour of Bazaar-NG. Aliases
+====================================
+Using aliases for Bazaar-NG commands
+====================================
+
+Command aliases are an easy way to customize the behaviour of Bazaar-NG. Aliases
 are an easy way to create shortcuts for commonly-typed commands, or to set
 defaults for commands.
 

=== modified file 'generate_docs.py'
--- generate_docs.py	
+++ generate_docs.py	
@@ -38,7 +38,13 @@
 import tools.doc_generate
 
 def main(argv):
-    parser = OptionParser(usage="%prog [options] OUTPUT_FORMAT")
+    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
+
+Available OUTPUT_FORMAT:
+
+    man              man page
+    rstx             man page in ReStructuredText format
+    bash_completion  bash completion script""")
 
     parser.add_option("-s", "--show-filename",
                       action="store_true", dest="show_filename", default=False,

=== modified file 'setup.py'
--- setup.py	
+++ setup.py	
@@ -1,13 +1,57 @@
 #! /usr/bin/env python
 
-# This is an installation script for bzr.  Run it with
-# './setup.py install', or
-# './setup.py --help' for more options
+"""Installation script for bzr.
+Run it with
+ './setup.py install', or
+ './setup.py --help' for more options
+"""
 
+##
+# META INFORMATION FOR SETUP
+
+META_INFO = {'name':         'bzr',
+             'version':      '0.8',
+             'author':       'Martin Pool',
+             'author_email': 'mbp at sourcefrog.net',
+             'url':          'http://www.bazaar-ng.org/',
+             'description':  'Friendly distributed version control system',
+             'license':      'GNU GPL v2',
+            }
+
+BZRLIB = {'packages': ['bzrlib',
+                       'bzrlib.doc',
+                       'bzrlib.doc.api',
+                       'bzrlib.export',
+                       'bzrlib.plugins',
+                       'bzrlib.store',
+                       'bzrlib.store.revision',
+                       'bzrlib.store.versioned',
+                       'bzrlib.tests',
+                       'bzrlib.tests.blackbox',
+                       'bzrlib.tests.branch_implementations',
+                       'bzrlib.tests.bzrdir_implementations',
+                       'bzrlib.tests.interrepository_implementations',
+                       'bzrlib.tests.interversionedfile_implementations',
+                       'bzrlib.tests.repository_implementations',
+                       'bzrlib.tests.revisionstore_implementations',
+                       'bzrlib.tests.workingtree_implementations',
+                       'bzrlib.transport',
+                       'bzrlib.transport.http',
+                       'bzrlib.ui',
+                       'bzrlib.util',
+                       'bzrlib.util.elementtree',
+                       'bzrlib.util.effbot.org',
+                       'bzrlib.util.configobj',
+                      ],
+         }
+
+
+##
 # Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
 # including bzrlib.help
 
-import os, sys
+import os
+import sys
 
 try:
     version_info = sys.version_info
@@ -76,44 +120,57 @@
         import generate_docs
         generate_docs.main(argv=["bzr", "man"])
 
+
 ########################
 ## Setup
 ########################
 
-setup(name='bzr',
-      version='0.8pre',
-      author='Martin Pool',
-      author_email='mbp at sourcefrog.net',
-      url='http://www.bazaar-ng.org/',
-      description='Friendly distributed version control system',
-      license='GNU GPL v2',
-      packages=['bzrlib',
-                'bzrlib.doc',
-                'bzrlib.doc.api',
-                'bzrlib.export',
-                'bzrlib.plugins',
-                'bzrlib.store',
-                'bzrlib.store.revision',
-                'bzrlib.store.versioned',
-                'bzrlib.tests',
-                'bzrlib.tests.blackbox',
-                'bzrlib.tests.branch_implementations',
-                'bzrlib.tests.bzrdir_implementations',
-                'bzrlib.tests.interrepository_implementations',
-                'bzrlib.tests.interversionedfile_implementations',
-                'bzrlib.tests.repository_implementations',
-                'bzrlib.tests.revisionstore_implementations',
-                'bzrlib.tests.workingtree_implementations',
-                'bzrlib.transport',
-                'bzrlib.transport.http',
-                'bzrlib.ui',
-                'bzrlib.util',
-                'bzrlib.util.elementtree',
-                'bzrlib.util.effbot.org',
-                'bzrlib.util.configobj',
-                ],
-      scripts=['bzr'],
-      cmdclass={'install_scripts': my_install_scripts, 'build': bzr_build},
-      data_files=[('man/man1', ['bzr.1'])],
-    #   todo: install the txt files from bzrlib.doc.api.
-     )
+if not ('py2exe' in sys.argv):
+    # std setup
+    ARGS = {'scripts': ['bzr'],
+            'cmdclass': {'build': bzr_build,
+                         'install_scripts': my_install_scripts,
+                        },
+            'data_files': [('man/man1', ['bzr.1'])],
+            #   todo: install the txt files from bzrlib.doc.api.
+           }
+    ARGS.update(META_INFO)
+    ARGS.update(BZRLIB)
+    
+    setup(**ARGS)
+
+else:
+    # py2exe setup
+    import py2exe
+
+    # pick real bzr version
+    import bzrlib
+
+    version_number = []
+    for i in bzrlib.version_info[:4]:
+        try:
+            i = int(i)
+        except ValueError:
+            i = 0
+        version_number.append(str(i))
+    version_str = '.'.join(version_number)
+
+    target = py2exe.build_exe.Target(script = "bzr",
+                                     dest_base = "bzr",
+                                     icon_resources = [(0,'bzr.ico')],
+                                     name = META_INFO['name'],
+                                     version = version_str,
+                                     description = META_INFO['description'],
+                                     author = META_INFO['author'],
+                                     copyright = "(c) Canonical Ltd, 2005-2006",
+                                     company_name = "Canonical Ltd.",
+                                     comments = META_INFO['description'],
+                                    )
+    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
+                                           ['elementtree'],
+                               "dist_dir": "win32_bzr.exe",
+                              },
+                   }
+    setup(options=options_list,
+          console=[target, 'tools/win32/bzr_postinstall.py'],
+          zipfile='lib/library.zip')



More information about the bazaar mailing list