forked from vhernandez/jwsProcessor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
95 lines (76 loc) · 3.09 KB
/
setup.py
File metadata and controls
95 lines (76 loc) · 3.09 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
#!/usr/bin/env python
#encoding: utf-8
#
# This setup file is to create an msi installer for Windows, to install on unixes
# refer to README.
#
from distutils.core import setup
from distutils.core import Command
from distutils.file_util import copy_file
import sys, glob, os
# The msgfmt.py script comes from Python distribution.
sys.path.append("buildtools")
import msgfmt
class build_mo (Command):
# Brief (40-50 characters) description of the command
description = "Builds the message catalog files for internationalization."
# List of option tuples: long name, short name (None if no short
# name), and help string.
user_options = [('po-dir', None,
"Directory where po files are kept"
"(default 'po'"),
('locale-dir', None,
"Directory where the catalog will be built"
"Default 'share/locale'"),
]
def initialize_options (self):
self.po_dir = None
self.locale_dir = None
def finalize_options (self):
if self.po_dir is None:
self.po_dir = 'po'
if self.locale_dir is None:
self.locale_dir = 'share/locale'
def run (self):
self.mkpath(self.locale_dir)
for po in glob.glob(os.path.join(self.po_dir, '*.po')):
lang = os.path.splitext(os.path.basename(po))[0]
gmo = po.replace('.po', '.gmo')
msgfmt.make(po, gmo)
destdir = os.path.join(self.locale_dir, lang, 'LC_MESSAGES')
destfile = os.path.join(destdir, "jwsprocessor.mo")
self.mkpath(destdir)
self.copy_file(gmo, destfile)
self.distribution.data_files.append( (destdir, [destfile]))
def read_version():
f = file("VERSION", "r")
v = f.read()
f.close()
return v.strip()
#make sure build_mo is called when the package is built
import distutils.command.build
distutils.command.build.build.sub_commands.append( ('build_mo', None) )
mo_catalog = []
for dirpath, dirnames, filenames in os.walk('share/locale'):
if 'LC_MESSAGES' in dirnames:
modir = os.path.join(dirpath,'LC_MESSAGES')
mofile = os.path.join(modir, "jwsprocessor.mo")
if os.path.isfile(mofile):
mo_catalog.append( (modir, [mofile,]) )
data_files = [('pixmaps', ['pixmaps/jwsprocessor.svg', 'pixmaps/jwsprocessor.png']),
('etc', ['etc/debugpath.cfg']),
('doc', ['README', 'AUTHORS', 'LICENSE', 'ChangeLog']),
('bin', ['bin/jwsprocessor.py', 'bin/this_is_a_repository']),
]
data_files.extend(mo_catalog)
setup(cmdclass={'build_mo':build_mo},
name='jwsProcessor',
version=read_version(),
description='A program to convert and process Jasco SpectraManager (JWS) files.',
author='Victor M. Hernandez-Rocamora',
author_email='victor.hr@gmail.com',
url='http://victor_hr.googlepages.com',
package_dir = { 'jwsprocessor': 'src/jwsprocessor' },
packages=['jwsprocessor'],
data_files = data_files
)