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
|
#!/usr/bin/env python3
import distutils.core
import distutils.command.build
import distutils.command.install
import glob
import os
class build_pylock(distutils.command.build.build):
def run(self):
distutils.command.build.build.run(self)
data_files = self.distribution.data_files
if data_files is None:
# in case not data_files are defined in setup.py
self.distribution.data_files = data_files = []
for po_file in glob.glob("po/*.po"):
lang = os.path.basename(po_file[:-3])
mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
mo_file = os.path.join(mo_dir, "%s.mo" % self.distribution.metadata.name)
if not os.path.exists(mo_dir):
os.makedirs(mo_dir)
cmd = ["msgfmt", po_file, "-o", mo_file]
po_mtime = os.path.getmtime(po_file)
mo_mtime = os.path.exists(mo_file) and os.path.getmtime(mo_file) or 0
if po_mtime > mo_mtime:
self.spawn(cmd)
targetpath = os.path.join("share/locale", lang, "LC_MESSAGES")
data_files.append((targetpath, (mo_file,)))
class install_pylock(distutils.command.install.install):
def run(self):
distutils.command.install.install.run(self)
distutils.dir_util.copy_tree('etc', os.path.join(self.root, 'etc'),
preserve_times=0, preserve_symlinks=1, verbose=1)
distutils.core.setup(
name = 'pylock',
version = '1',
author = 'Matthias Schiffer',
author_email = 'mschiffer@universe-factory.net',
url = 'http://git.universe-factory.net/pylock/',
description = 'A lightweight screenlocker for X implemented in Python 3 using Gtk3',
license = 'BSD',
packages = ['pylock'],
package_data = {
'pylock': ['data/unlock.ui', 'data/bg.svg'],
},
scripts = ['scripts/pylock'],
cmdclass = {
'build': build_pylock,
'install': install_pylock,
},
provides = ['pylock'],
requires = [
'gi.repository.Gtk',
'gi.repository.Gdk',
'gi.repository.GdkX11',
'gi.repository.GObject',
'gi.repository.GLib',
],
)
|