[packaging] add a __init__.py to cubes directory when installing data stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 15 Oct 2010 11:41:10 +0200
branchstable
changeset 6506 c1661ea815dc
parent 6505 ac4cecb26813
child 6507 df2527c645cd
child 6508 38c2ff52cfca
[packaging] add a __init__.py to cubes directory when installing data
debian/cubicweb-common.install.in
debian/rules
setup.py
--- a/debian/cubicweb-common.install.in	Fri Oct 15 11:40:36 2010 +0200
+++ b/debian/cubicweb-common.install.in	Fri Oct 15 11:41:10 2010 +0200
@@ -1,5 +1,5 @@
 debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/common/ usr/lib/PY_VERSION/site-packages/cubicweb
 debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/entities/ usr/lib/PY_VERSION/site-packages/cubicweb
 debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/ext/ usr/lib/PY_VERSION/site-packages/cubicweb
-debian/tmp/usr/share/cubicweb/cubes/shared/i18n usr/share/cubicweb/cubes/shared/
+debian/tmp/usr/share/cubicweb/cubes/ usr/share/cubicweb/
 debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/*.py usr/share/pyshared/cubicweb
--- a/debian/rules	Fri Oct 15 11:40:36 2010 +0200
+++ b/debian/rules	Fri Oct 15 11:41:10 2010 +0200
@@ -53,8 +53,6 @@
 	rm -rf debian/cubicweb-common/usr/lib/${PY_VERSION}/site-packages/cubicweb/ext/test
 	rm -rf debian/cubicweb-common/usr/lib/${PY_VERSION}/site-packages/cubicweb/entities/test
 
-	# cubes directory must be managed as a valid python module
-	touch debian/cubicweb-common/usr/share/cubicweb/cubes/__init__.py
 
 %: %.in
 	sed "s/PY_VERSION/${PY_VERSION}/g" < $< > $@
--- a/setup.py	Fri Oct 15 11:40:36 2010 +0200
+++ b/setup.py	Fri Oct 15 11:41:10 2010 +0200
@@ -31,10 +31,12 @@
         raise ImportError() # do as there is no setuptools
     from setuptools import setup
     from setuptools.command import install_lib
+    from setuptools.command import install_data
     USE_SETUPTOOLS = True
 except ImportError:
     from distutils.core import setup
     from distutils.command import install_lib
+    from distutils.command import install_data
     USE_SETUPTOOLS = False
 
 # import required features
@@ -163,6 +165,16 @@
                 dest = join(self.install_dir, base, directory)
                 export(directory, dest, verbose=False)
 
+class MyInstallData(install_data.install_data):
+    def run(self):
+        """overridden from install_data class"""
+        install_data.install_data.run(self)
+        path = join(self.install_dir, 'share', 'cubicweb', 'cubes', '__init__.py')
+        ini = open(path, 'w')
+        ini.write('# Cubicweb cubes directory\n')
+        ini.close()
+
+
 def install(**kwargs):
     """setup entry point"""
     if USE_SETUPTOOLS:
@@ -188,7 +200,7 @@
                  author=author, author_email=author_email,
                  scripts=ensure_scripts(scripts), data_files=data_files,
                  ext_modules=ext_modules,
-                 cmdclass={'install_lib': MyInstallLib},
+                 cmdclass={'install_lib': MyInstallLib, 'install_data': MyInstallData},
                  **kwargs
                  )