[PATCH] Consolidated patch to install contrib/ on posix platforms

Jonathan S. Shapiro shap at eros-os.com
Fri Aug 31 12:02:41 CDT 2007


# HG changeset patch
# User Jonathan S. Shapiro <shap at eros-os.com>
# Date 1188579402 14400
# Node ID 9085dc8f7de9c2642e1ee690bfc1780b6b2f1a42
# Parent  694eb9ccb54d9f9c2e63a65368df0fdc9843f98f
Consolidated patch to install contrib/ on posix platforms.

This patch causes setup.py to install the contrib/ directory where the
proper target directory is known. I looked briefly at the .iss file in
contrib/win32, but could not determine whether the copy could safely
be handled from here.

This version consolidates my later email post that selects base on
operating system, which will make it easier to update for other
platforms as needed.

diff -r 694eb9ccb54d -r 9085dc8f7de9 setup.py
--- a/setup.py	Fri Aug 31 13:14:03 2007 +0200
+++ b/setup.py	Fri Aug 31 12:56:42 2007 -0400
@@ -52,6 +52,29 @@ mercurial.version.remember_version(versi
 mercurial.version.remember_version(version)
 cmdclass = {'install_data': install_package_data}
 
+# For platforms where the proper target directory is clearly
+# identifiable, arrange to install the contrib/ directory here.
+#
+# The correct install directory for contrib/ is platform dependent. On
+# some platforms, notably Windows, it may get packaged by the
+# installer script rather than here. This seems unfortunate, but it
+# isn't clear that there is a better solution within the framework of
+# distutils. The underlying problem is that python distutils doesn't
+# seem to have a notion of an installation directory available on all
+# platforms that is conceptually equivalent to /usr/share.
+
+contrib_dir = None
+contrib_files = []  # default
+if os.name in ['posix']:
+    contrib_dir = '/usr/share/mercurial'
+    
+if contrib_dir != None:
+    contrib_files = [(os.path.join(contrib_dir, root),
+                      [os.path.join(root, file_) for file_ in files])
+                     for root, dirs, files in os.walk('contrib')]
+    contrib_files = contrib_files + [('/usr/share/mercurial',
+                                      ['hgwebdir.cgi', 'hgweb.cgi'])]
+
 setup(name='mercurial',
       version=mercurial.version.get_version(),
       author='Matt Mackall',
@@ -66,7 +89,8 @@ setup(name='mercurial',
                    Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'])],
       data_files=[(os.path.join('mercurial', root),
                    [os.path.join(root, file_) for file_ in files])
-                  for root, dirs, files in os.walk('templates')],
+                  for root, dirs, files in os.walk('templates')] +
+                 contrib_files,
       cmdclass=cmdclass,
       scripts=['hg', 'hgmerge'],
       options=dict(py2exe=dict(packages=['hgext']),


More information about the Mercurial-devel mailing list