~virtualbricks/virtualbrick/trunk

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
#!/usr/bin/env python
# Virtualbricks - a vde/qemu gui written in python and GTK/Glade.
# Copyright (C) 2013 Virtualbricks team

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import os.path
import glob

from distutils.command.install_data import install_data as _install_data
from setuptools import setup

def _get_version():
    filename = os.path.join('virtualbricks', '__init__.py')
    var = '__version__'
    glb = {}
    with open(filename) as fp:
        for line in fp:
            if var in line:
                exec(line, glb)
                return glb[var ]
    raise RuntimeError('cannot find version')


class install_data(_install_data):

    def initialize_options(self):
        _install_data.initialize_options(self)
        self.tmpdirs = []

    def compile_mo(self):
        import tempfile
        for filename in glob.iglob("locale/virtualbricks/??.po"):
            lang, _ = os.path.basename(filename).split(".")
            tmpdir = tempfile.mkdtemp()
            self.tmpdirs.append(tmpdir)
            outfile = "{0}/virtualbricks.mo".format(tmpdir)
            self.spawn(["msgfmt", "-o", outfile, filename])
            self.data_files.append(
                ("share/locale/{0}/LC_MESSAGES".format(lang), [outfile])
            )

    def remove_temps(self):
        import shutil
        for tmpdir in self.tmpdirs:
            shutil.rmtree(tmpdir)

    def run(self):
        self.execute(self.compile_mo, ())
        _install_data.run(self)
        self.execute(self.remove_temps, ())


DATA_IMAGES = glob.glob("virtualbricks/gui/data/*.png")
DATA_HELPS = glob.glob("virtualbricks/gui/data/help/*")
DATA_GLADE_UI = glob.glob("virtualbricks/gui/data/*.ui")
DATA_FILES = DATA_IMAGES + DATA_GLADE_UI + DATA_HELPS


setup(
    name="virtualbricks",
    version=_get_version(),
    description="Virtualbricks Virtualization Tools",
    author="Virtualbricks team",
    url="https://launchpad.net/virtualbrick",
    license="GPLv2",
    platforms=["linux2", "linux"],
    packages=[
        "virtualbricks",
        "virtualbricks.gui",
        "virtualbricks.scripts",
        "virtualbricks.tests"
    ],
    package_data={"virtualbricks.tests": ["data/*"]},
    data_files=[
        ("share/applications", ["share/virtualbricks.desktop"]),
        ("share/pixmaps", ["share/virtualbricks.xpm"]),
        ("share/virtualbricks", DATA_FILES),
    ],
    install_requires=[
        "Twisted>=12.0.0",
        "zope.interface>=3.5"
    ],
    entry_points={
        'console_scripts': [
            'virtualbricks = virtualbricks.scripts.virtualbricks:run'
        ]
    },
    cmdclass={
        "install_data": install_data
    },
    classifiers=[
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 2 :: Only',
        'Environment :: X11 Applications :: GTK',
        'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
        'Operating System :: POSIX :: Linux',
    ],
)