You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

82 lines
2.4 KiB

  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. # setup.py --- Setup script for calculate-install
  4. # Copyright 2010 Calculate Ltd. http://www.calculate-linux.org
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. import os
  18. from os import path
  19. import stat
  20. import distutils
  21. import glob
  22. import sys
  23. from distutils.core import setup, Extension
  24. import distutils.command.build
  25. import distutils.command.install
  26. import distutils.command.install_egg_info
  27. locales = ("ru","bg")
  28. def cout(string):
  29. sys.stdout.write(string)
  30. sys.stdout.flush()
  31. class build_po( distutils.core.Command ) :
  32. description = "build translation files"
  33. user_options = []
  34. def initialize_options( self ) :
  35. pass
  36. def finalize_options( self ) :
  37. pass
  38. def run( self ) :
  39. self.mkpath("build")
  40. #build.run( self )
  41. for locale in locales:
  42. for po in glob.glob("%s/*.po"%locale) :
  43. cmd = "msgfmt -c -o build/%s %s" % \
  44. (path.basename(po)[:-2]+'mo',po)
  45. cout( cmd + "\n" )
  46. os.system(cmd)
  47. class empty_egg_info( distutils.command.install_egg_info.install_egg_info ):
  48. def run(self):
  49. pass
  50. class build( distutils.command.build.build ) :
  51. def run( self ) :
  52. distutils.command.build.build.run( self )
  53. def has_po( self ) :
  54. return len(glob.glob("ru/*.po")) > 0
  55. sub_commands = distutils.command.build.build.sub_commands + [
  56. ('build_po',has_po),
  57. ]
  58. setup(
  59. name = "calculate-i18n",
  60. version = "2.2.20",
  61. description = "Calculate Linux internationalization",
  62. author = "Calculate Ltd.",
  63. author_email = "support@calculate.ru",
  64. url = "http://calculate-linux.org",
  65. license = "http://www.apache.org/licenses/LICENSE-2.0",
  66. data_files = [("",(glob.glob("build/*.mo")))],
  67. cmdclass = {'build':build,'build_po':build_po,'install_egg_info':empty_egg_info}
  68. )