Skip to content

Commit 3599121

Browse files
committed
Use package_data for mo files.
1 parent 91cf334 commit 3599121

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

setup.py

100644100755
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44

55
import os
6-
import os.path
76
import platform
87
import re
98
import sys
10-
from fnmatch import fnmatch
119

1210
from distutils import cmd
1311
from distutils.command.build import build
@@ -26,12 +24,12 @@
2624
except ImportError:
2725
from distutils.command.build_py import build_py
2826

27+
translations_dir = os.path.join(package_dir, 'translations')
28+
2929
try:
3030
from babel.messages.frontend import compile_catalog as _compile_catalog
3131
from babel.messages.frontend import extract_messages
3232

33-
translations_dir = os.path.join(package_dir, 'translations', '')
34-
3533
class compile_catalog(_compile_catalog):
3634
def initialize_options(self):
3735
"""Simply set default domain and directory attributes to the
@@ -63,18 +61,15 @@ def initialize_options(self):
6361
# man pages
6462
(os.path.join(man_dir, 'man1'), ['doc/bpython.1']),
6563
(os.path.join(man_dir, 'man5'), ['doc/bpython-config.5']),
66-
# desktop shorcut
64+
# desktop shortcut
6765
(os.path.join('share', 'applications'), ['data/bpython.desktop'])]
68-
# translations
69-
if using_translations:
70-
for language in os.listdir(translations_dir):
71-
if not (fnmatch(language, '[a-z][a-z]_[A-Z][A-Z]') or
72-
fnmatch(language, '[a-z][a-z') or
73-
os.path.isdir(language)):
74-
continue
75-
data_files.append(('bpython/translations/'+language+'/LC_MESSAGES/',
76-
[translations_dir+language+'/LC_MESSAGES/'+'bpython.mo']))
7766

67+
# translations
68+
mo_files = list()
69+
for language in os.listdir(translations_dir):
70+
mo_subpath = os.path.join(language, 'LC_MESSAGES', 'bpython.mo')
71+
if os.path.exists(os.path.join(translations_dir, mo_subpath)):
72+
mo_files.append(mo_subpath)
7873

7974
setup(
8075
name="bpython",
@@ -92,7 +87,9 @@ def initialize_options(self):
9287
packages = ["bpython", "bpython.translations", "bpdb"],
9388
data_files = data_files,
9489
package_data = {
95-
'bpython': ['logo.png']},
90+
'bpython': ['logo.png'],
91+
'bpython.translations': mo_files
92+
},
9693
entry_points = {
9794
'console_scripts': [
9895
'bpython = bpython.cli:main',

0 commit comments

Comments
 (0)