[Libguestfs] [PATCH 2/3] python: move module to separate directory

Peter Wu peter at lekensteyn.nl
Sat Aug 9 15:33:05 UTC 2014


This allows submodules to be added under the 'hivex' namespace. A new
`pythonmoddir` variable was added for separating libhivexmod.so and the
Python hivex module.
---
 generator/generator.ml |  3 ++-
 python/Makefile.am     | 16 +++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/generator/generator.ml b/generator/generator.ml
index f6c34e9..466efcb 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -3854,7 +3854,8 @@ Run it from the top source directory using the command
   output_to "perl/lib/Win/Hivex.pm" generate_perl_pm;
   output_to "perl/Hivex.xs" generate_perl_xs;
 
-  output_to "python/hivex.py" generate_python_py;
+  (try Unix.mkdir "python/hivex" 0o755 with Unix_error _ -> ());
+  output_to "python/hivex/__init__.py" generate_python_py;
   output_to "python/hivex-py.c" generate_python_c;
 
   output_to "ruby/ext/hivex/_hivex.c" generate_ruby_c;
diff --git a/python/Makefile.am b/python/Makefile.am
index 93a70c4..6bb8ade 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -20,15 +20,17 @@ builddir ?= $(top_builddir)/python
 
 EXTRA_DIST = \
 	run-python-tests \
-	hivex.py \
+	hivex/__init__.py \
 	hivex-py.c \
 	t/*.py
 
 if HAVE_PYTHON
 
 pythondir = $(PYTHON_INSTALLDIR)
+pythonmoddir = $(PYTHON_INSTALLDIR)/hivex
 
-python_DATA = hivex.py
+pythonmod_DATA = \
+	hivex/__init__.py
 
 python_LTLIBRARIES = libhivexmod.la
 
@@ -42,6 +44,14 @@ TESTS_ENVIRONMENT = ../run
 
 TESTS = run-python-tests
 
-CLEANFILES = hivex.pyc
+# hivex.py got moved to hivex/__init.py
+CLEANFILES = \
+	hivex.py \
+	hivex.pyc \
+	hivex/__init__.pyc
+
+# For Python 3
+clean-local:
+	-rm -rf __pycache__/ hivex/__pycache__/
 
 endif
-- 
2.0.2




More information about the Libguestfs mailing list