setup.py
branchstable
changeset 6517 c991ad161d8f
parent 6516 6b2e1e8d3a22
child 6522 c46b3b3291e8
child 6534 eb8dd7b0bd9d
equal deleted inserted replaced
6516:6b2e1e8d3a22 6517:c991ad161d8f
   162                 base = modname
   162                 base = modname
   163             for directory in include_dirs:
   163             for directory in include_dirs:
   164                 dest = join(self.install_dir, base, directory)
   164                 dest = join(self.install_dir, base, directory)
   165                 export(directory, dest, verbose=False)
   165                 export(directory, dest, verbose=False)
   166 
   166 
       
   167 # write required share/cubicweb/cubes/__init__.py
   167 class MyInstallData(install_data.install_data):
   168 class MyInstallData(install_data.install_data):
       
   169     """A class That manages data files installation"""
   168     def run(self):
   170     def run(self):
   169         """overridden from install_data class"""
   171         """overridden from install_data class"""
   170         install_data.install_data.run(self)
   172         install_data.install_data.run(self)
   171         path = join(self.install_dir, 'share', 'cubicweb', 'cubes', '__init__.py')
   173         path = join(self.install_dir, 'share', 'cubicweb', 'cubes', '__init__.py')
   172         ini = open(path, 'w')
   174         ini = open(path, 'w')
   173         ini.write('# Cubicweb cubes directory\n')
   175         ini.write('# Cubicweb cubes directory\n')
   174         ini.close()
   176         ini.close()
   175 
   177 
       
   178 # re-enable copying data files in sys.prefix
       
   179 if USE_SETUPTOOLS:
       
   180     # overwrite MyInstallData to use sys.prefix instead of the egg directory
       
   181     MyInstallMoreData = MyInstallData
       
   182     class MyInstallData(MyInstallMoreData):
       
   183         """A class that manages data files installation"""
       
   184         def run(self):
       
   185             _old_install_dir = self.install_dir
       
   186             if self.install_dir.endswith('egg'):
       
   187                 self.install_dir = sys.prefix
       
   188             MyInstallMoreData.run(self)
       
   189             self.install_dir = _old_install_dir
       
   190     try:
       
   191         import setuptools.command.easy_install # only if easy_install avaible
       
   192         # monkey patch: Crack SandboxViolation verification
       
   193         from setuptools.sandbox import DirectorySandbox as DS
       
   194         old_ok = DS._ok
       
   195         def _ok(self, path):
       
   196             """Return True if ``path`` can be written during installation."""
       
   197             out = old_ok(self, path)
       
   198             realpath = os.path.normcase(os.path.realpath(path))
       
   199             if realpath.startswith(sys.prefix):
       
   200                 out = True
       
   201             return out
       
   202         DS._ok = _ok
       
   203     except ImportError:
       
   204         pass
   176 
   205 
   177 def install(**kwargs):
   206 def install(**kwargs):
   178     """setup entry point"""
   207     """setup entry point"""
   179     if USE_SETUPTOOLS:
   208     if USE_SETUPTOOLS:
   180         if '--force-manifest' in sys.argv:
   209         if '--force-manifest' in sys.argv:
   198     return setup(name=distname, version=version, license=license, url=web,
   227     return setup(name=distname, version=version, license=license, url=web,
   199                  description=description, long_description=long_description,
   228                  description=description, long_description=long_description,
   200                  author=author, author_email=author_email,
   229                  author=author, author_email=author_email,
   201                  scripts=ensure_scripts(scripts), data_files=data_files,
   230                  scripts=ensure_scripts(scripts), data_files=data_files,
   202                  ext_modules=ext_modules,
   231                  ext_modules=ext_modules,
   203                  cmdclass={'install_lib': MyInstallLib, 'install_data': MyInstallData},
   232                  cmdclass={'install_lib': MyInstallLib,
       
   233                            'install_data': MyInstallData},
   204                  **kwargs
   234                  **kwargs
   205                  )
   235                  )
   206 
   236 
   207 if __name__ == '__main__' :
   237 if __name__ == '__main__' :
   208     install()
   238     install()