# HG changeset patch # User Alain Leufroy # Date 1287164940 -7200 # Node ID c991ad161d8ff29a1ae8532ec45edb96a0f51a77 # Parent 6b2e1e8d3a2273ddcc2bd530d66c011118e8dc99 [pkg] force copying data files in sys.path * Hack setuptools to copy data files in sys.path instead of egg directory * Hack easy_install's SandboxViolation verification to allow writting files in sys.path (allowed by disutils) diff -r 6b2e1e8d3a22 -r c991ad161d8f setup.py --- a/setup.py Fri Oct 15 19:48:58 2010 +0200 +++ b/setup.py Fri Oct 15 19:49:00 2010 +0200 @@ -164,7 +164,9 @@ dest = join(self.install_dir, base, directory) export(directory, dest, verbose=False) +# write required share/cubicweb/cubes/__init__.py class MyInstallData(install_data.install_data): + """A class That manages data files installation""" def run(self): """overridden from install_data class""" install_data.install_data.run(self) @@ -173,6 +175,33 @@ ini.write('# Cubicweb cubes directory\n') ini.close() +# re-enable copying data files in sys.prefix +if USE_SETUPTOOLS: + # overwrite MyInstallData to use sys.prefix instead of the egg directory + MyInstallMoreData = MyInstallData + class MyInstallData(MyInstallMoreData): + """A class that manages data files installation""" + def run(self): + _old_install_dir = self.install_dir + if self.install_dir.endswith('egg'): + self.install_dir = sys.prefix + MyInstallMoreData.run(self) + self.install_dir = _old_install_dir + try: + import setuptools.command.easy_install # only if easy_install avaible + # monkey patch: Crack SandboxViolation verification + from setuptools.sandbox import DirectorySandbox as DS + old_ok = DS._ok + def _ok(self, path): + """Return True if ``path`` can be written during installation.""" + out = old_ok(self, path) + realpath = os.path.normcase(os.path.realpath(path)) + if realpath.startswith(sys.prefix): + out = True + return out + DS._ok = _ok + except ImportError: + pass def install(**kwargs): """setup entry point""" @@ -200,7 +229,8 @@ author=author, author_email=author_email, scripts=ensure_scripts(scripts), data_files=data_files, ext_modules=ext_modules, - cmdclass={'install_lib': MyInstallLib, 'install_data': MyInstallData}, + cmdclass={'install_lib': MyInstallLib, + 'install_data': MyInstallData}, **kwargs )