1010import sys
1111
1212from distutils import cmd
13- from distutils .command .install_data import install_data as _install_data
1413from distutils .command .build import build
1514
1615from bpython import __version__
@@ -60,7 +59,8 @@ def run(self):
6059 continue
6160
6261 lang = filename [:- 3 ]
63- dest_path = os .path .join ('build' , 'locale' , lang , 'LC_MESSAGES' )
62+ dest_path = os .path .join ('build' , 'share' , 'locale' ,
63+ lang , 'LC_MESSAGES' )
6464
6565 src = os .path .join (src_path , filename )
6666 dest = os .path .join (dest_path , 'bpython.mo' )
@@ -72,24 +72,24 @@ def run(self):
7272 print ('Adding translation: %s' % lang )
7373 msgfmt .make (src , dest )
7474
75- build .sub_commands .append ( ('build_translation' , None ))
75+ build .sub_commands .insert ( 0 , ('build_translation' , None ))
7676
7777
78- class install_data (_install_data ):
79- """Append to data_files l10n .mo files. Then continue with normal install."""
80-
81- def run (self ):
82- for lang in os .listdir ('po' ):
83- if not lang .endswith ('.mo' ):
84- continue
85-
86- lang_dir = os .path .join ('share' , 'locale' , lang [:- 3 ], 'LC_MESSAGES' )
87- lang_file = os .path .join ('po' , lang )
88- self .data_files .append ((lang_dir , [lang_file ]))
89-
90- _install_data .run (self )
78+ data_files = [
79+ # man pages
80+ (os .path .join (man_dir , 'man1' ), ['doc/bpython.1' ]),
81+ (os .path .join (man_dir , 'man5' ), ['doc/bpython-config.5' ]),
82+ # desktop shorcut
83+ (os .path .join ('share' , 'applications' ), ['data/bpython.desktop' ]),
84+ ]
85+ # localization
86+ l10n_dir = os .path .join ('share' , 'locale' )
87+ for langfile in os .listdir ('po' ):
88+ if not os .path .isfile (langfile ) or not langfile .endswith ('.po' ):
89+ continue
9190
92- build .sub_commands .append (('install_data' , None ))
91+ lang_path = os .path .join (l10n_dir , langfile [:- 3 ], 'LC_MESSAGES' )
92+ data_files .append ((lang_path , ['build/%s/bpython.mo' % lang_path ]))
9393
9494
9595setup (
@@ -106,13 +106,7 @@ def run(self):
106106 'pygments'
107107 ],
108108 packages = ["bpython" ],
109- data_files = [
110- # man pages
111- (os .path .join (man_dir , 'man1' ), ['doc/bpython.1' ]),
112- (os .path .join (man_dir , 'man5' ), ['doc/bpython-config.5' ]),
113- # desktop shorcut
114- (os .path .join ('share' , 'applications' ), ['data/bpython.desktop' ])
115- ],
109+ data_files = data_files ,
116110 package_data = {'bpython' : ['logo.png' ]},
117111 entry_points = {
118112 'console_scripts' : [
@@ -124,8 +118,7 @@ def run(self):
124118 'data/bpython-gtk' ]),
125119 cmdclass = dict (build_py = build_py ,
126120 build = build ,
127- build_translation = build_translation ,
128- install_data = install_data )
121+ build_translation = build_translation )
129122)
130123
131124# vim: encoding=utf-8 sw=4 ts=4 sts=4 ai et sta
0 commit comments