[PATCH 6 of 8] extensions: extract official descriptions at build time
Cédric Duval
cedricduval at free.fr
Sat Jul 4 20:05:12 UTC 2009
# HG changeset patch
# User Cédric Duval <cedricduval at free.fr>
# Date 1246176984 -7200
# Node ID 1df45aa6f8119609e43b108a7bff7f632f22f92a
# Parent 9e82cf39c71abc692fa5194ddcbdd35d9cf788ef
extensions: extract official descriptions at build time
A python module containing the descriptions of each official extension
is generated at build time, and updated in case any of the files from
which descriptions are extracted has been modified.
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -24,6 +24,7 @@
doc/*.[0-9].{x,ht}ml
MANIFEST
patches
+mercurial/extdoc_list.py
mercurial/__version__.py
Output/Mercurial-*.exe
.DS_Store
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,11 @@
all: build doc
local:
- $(PYTHON) setup.py $(PURE) build_py -c -d . build_ext -i build_mo
+ $(PYTHON) setup.py $(PURE) \
+ build_extensions_list \
+ build_py -c -d . \
+ build_ext -i \
+ build_mo
$(PYTHON) hg version
build:
@@ -39,6 +43,7 @@
-$(PYTHON) setup.py clean --all # ignore errors from this command
find . -name '*.py[cdo]' -exec rm -f '{}' ';'
rm -f MANIFEST mercurial/__version__.py mercurial/*.so tests/*.err
+ rm -f mercurial/extdoc_list.py
rm -rf locale
$(MAKE) -C doc clean
@@ -63,7 +68,7 @@
MANIFEST: MANIFEST-doc
hg manifest > MANIFEST
- echo mercurial/__version__.py >> MANIFEST
+ echo mercurial/__version__.py mercurial/extdoc_list.py >> MANIFEST
cat doc/MANIFEST >> MANIFEST
dist: tests dist-notests
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -29,6 +29,7 @@
import os, subprocess, time
import shutil
import tempfile
+from mercurial import extdoc
from distutils.core import setup, Extension
from distutils.dist import Distribution
from distutils.command.install_data import install_data
@@ -161,6 +162,26 @@
('install_lib', 'install_dir'))
install_data.finalize_options(self)
+class build_extensions_list(build):
+
+ description = "build the list of Mercurial extensions"
+ target = os.path.join('mercurial', 'extdoc_list.py')
+
+ def generate(self):
+ '''write the descriptions dict in the target file'''
+ descs = extdoc.extract('hgext', raw=True)
+ f = file(self.target, 'w')
+ f.write('# this file is autogenerated by setup.py\n')
+ f.write('descriptions = ' + repr(descs) + '\n')
+ f.close()
+
+ def run(self):
+ '''(re)generate target if some extensions sources are more recent'''
+ deps = extdoc.files('hgext').values()
+ self.make_file(deps, self.target, self.generate, [])
+
+build.sub_commands.insert(0, ('build_extensions_list', None))
+
class build_mo(build):
description = "build translations (.mo files)"
@@ -221,6 +242,7 @@
yield module
cmdclass = {'install_data': install_package_data,
+ 'build_extensions_list': build_extensions_list,
'build_mo': build_mo,
'build_py': hg_build_py}
More information about the Mercurial-devel
mailing list