forked from bpython/bpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
131 lines (103 loc) · 3.59 KB
/
setup.py
File metadata and controls
131 lines (103 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import glob
import os
import os.path
import platform
import re
import sys
from distutils import cmd
from distutils.command.install_data import install_data as _install_data
from distutils.command.build import build
from bpython import __version__
try:
from setuptools import setup
using_setuptools = True
except ImportError:
from distutils.core import setup
using_setuptools = False
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py
try:
import msgfmt
except ImportError:
pass
if platform.system() == 'FreeBSD':
man_dir = 'man'
else:
man_dir = 'share/man'
class build_translation(cmd.Command):
"""Internationalization suport for bpython.
Compile .po files into .mo files"""
description = __doc__
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
src_path = os.path.join(os.path.realpath(''), 'po')
for filename in os.listdir(src_path):
if (not os.path.isfile(os.path.join(src_path, filename)) or
not filename.endswith('.po')):
continue
lang = filename[:-3]
dest_path = os.path.join('build', 'locale', lang, 'LC_MESSAGES')
src = os.path.join(src_path, filename)
dest = os.path.join(dest_path, 'bpython.mo')
if not os.path.exists(dest_path):
os.makedirs(dest_path)
if (not os.path.exists(dest) or
os.stat(src)[8] > os.stat(dest)[8]):
print ('Adding translation: %s' % lang)
msgfmt.make(src, dest)
build.sub_commands.append(('build_translation', None))
class install_data(_install_data):
"""Append to data_files l10n .mo files. Then continue with normal install."""
def run(self):
for lang in os.listdir('po'):
if not lang.endswith('.mo'):
continue
lang_dir = os.path.join('share', 'locale', lang[:-3], 'LC_MESSAGES')
lang_file = os.path.join('po', lang)
self.data_files.append((lang_dir, [lang_file]))
_install_data.run(self)
build.sub_commands.append(('install_data', None))
setup(
name="bpython",
version = __version__,
author = "Bob Farrell, Andreas Stuehrk et al.",
author_email = "robertanthonyfarrell@gmail.com",
description = "Fancy Interface to the Python Interpreter",
license = "MIT/X",
url = "http://www.bpython-interpreter.org/",
long_description = """bpython is a fancy interface to the Python
interpreter for Unix-like operating systems.""",
install_requires = [
'pygments'
],
packages = ["bpython"],
data_files = [
# man pages
(os.path.join(man_dir, 'man1'), ['doc/bpython.1']),
(os.path.join(man_dir, 'man5'), ['doc/bpython-config.5']),
# desktop shorcut
(os.path.join('share', 'applications'), ['data/bpython.desktop'])
],
package_data = {'bpython': ['logo.png']},
entry_points = {
'console_scripts': [
'bpython = bpython.cli:main',
'bpython-gtk = bpython.gtk_:main',
],
},
scripts = ([] if using_setuptools else ['data/bpython',
'data/bpython-gtk']),
cmdclass=dict(build_py=build_py,
build = build,
build_translation = build_translation,
install_data = install_data)
)
# vim: encoding=utf-8 sw=4 ts=4 sts=4 ai et sta