setup.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env python
  2. import os
  3. from distutils.core import setup
  4. from distutils.command.build_py import build_py as _build_py
  5. from distutils.command.install_data import install_data as _install_data
  6. from searxqt.version import __version__
  7. ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
  8. LOCALES_PATH = os.path.join(ROOT_PATH, 'locales')
  9. def compileLocales():
  10. cmd = os.path.join(ROOT_PATH, 'utils', 'locale_tool.sh')
  11. cmd += " -m all"
  12. if os.system(cmd) != 0:
  13. print("Failed to compile locales.")
  14. def genMoList():
  15. data_files = []
  16. for langDir in os.listdir(LOCALES_PATH):
  17. path = os.path.join(LOCALES_PATH, langDir)
  18. if not os.path.isdir(path):
  19. continue
  20. moPath = os.path.join(path, "LC_MESSAGES", "searx-qt.mo")
  21. if not os.path.exists(moPath):
  22. continue
  23. targetPath = os.path.join("share/locale", langDir, "LC_MESSAGES")
  24. data_files.append(
  25. (targetPath, [moPath])
  26. )
  27. return data_files
  28. class build_py(_build_py):
  29. def run(self):
  30. compileLocales()
  31. return _build_py.run(self)
  32. class install_data(_install_data):
  33. def run(self):
  34. if os.path.exists(LOCALES_PATH):
  35. self.data_files += genMoList()
  36. return _install_data.run(self)
  37. setup(name='searx-qt',
  38. version=__version__,
  39. license='GPLv3',
  40. description=('Lightweight desktop application for Searx.'),
  41. author='CYBERDEViL',
  42. url='https://notabug.org/cyberdevil',
  43. packages=[
  44. 'searxqt',
  45. 'searxqt.widgets',
  46. 'searxqt.models',
  47. 'searxqt.views',
  48. 'searxqt.core',
  49. 'searxqt.utils'
  50. ],
  51. classifiers=[
  52. 'Development Status :: 3 - Alpha',
  53. 'Environment :: X11 Applications :: Qt',
  54. 'Topic :: Internet',
  55. 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
  56. 'Topic :: Internet :: WWW/HTTP'
  57. ],
  58. scripts=[
  59. 'bin/searx-qt'
  60. ],
  61. data_files=[
  62. ('share/applications', ['share/searx-qt.desktop']),
  63. ('share/doc/searx-qt', ['COPYING', 'README.md', 'CHANGELOG.md'])
  64. ],
  65. cmdclass={
  66. 'build_py': build_py,
  67. 'install_data': install_data
  68. })