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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
#!/usr/bin/env python3
import os
import subprocess
from distutils.core import setup, Extension
def removeall(path):
if not os.path.isdir(path):
return
files = os.listdir(path)
for x in files:
fullpath = os.path.join(path, x)
if os.path.isfile(fullpath):
f = os.remove
rmgeneric(fullpath, f)
elif os.path.isdir(fullpath):
removeall(fullpath)
f = os.rmdir
rmgeneric(fullpath, f)
def rmgeneric(path, __func__):
try:
__func__(path)
except OSError:
pass
# Create mo files:
if not os.path.exists("mo/"):
os.mkdir("mo/")
for lang in (
"it",
"de",
"pl",
"es",
"fr",
"ru",
"hu",
"cs",
"pt",
"pt_BR",
"zh_CN",
"nl",
"uk",
"sv",
):
pofile = "po/" + lang + ".po"
mofile = "mo/" + lang + "/mirage.mo"
if not os.path.exists("mo/" + lang + "/"):
os.mkdir("mo/" + lang + "/")
print("generating", mofile)
os.system("msgfmt %s -o %s" % (pofile, mofile))
print("Generating gresources bundle")
subprocess.call(
[
"glib-compile-resources",
"--sourcedir=resources",
"--target=io.thomasross.mirage.gresource",
"resources/mirage.gresource.xml",
]
)
setup(
name="Mirage",
version="0.11.2",
description="A fast GTK+ image viewer",
author="Scott Horowitz",
author_email="stonecrest@gmail.com",
maintainer="Thomas Ross",
maintainer_email="thomasross@thomasross.io",
url="https://gitlab.com/thomasross/mirage",
classifiers=[
"Environment :: X11 Applications",
"Intended Audience :: End Users/Desktop",
"License :: GNU General Public License (GPL)",
"Operating System :: Linux",
"Programming Language :: Python",
"Topic :: Multimedia :: Graphics :: Viewers",
],
packages=["mirage"],
ext_package="mirage",
ext_modules=[
Extension(name="imgfuncs", sources=["mirage/imgfuncs.c"]),
Extension(name="xmouse", sources=["mirage/xmouse.c"], libraries=["X11"]),
],
scripts=["bin/mirage"],
data_files=[
(
"share/mirage",
[
"README",
"COPYING",
"CHANGELOG",
"TODO",
"TRANSLATORS",
"mirage_blank.png",
"io.thomasross.mirage.gresource",
],
),
("share/applications", ["mirage.desktop"]),
("share/pixmaps", ["mirage.png"]),
("share/locale/ru/LC_MESSAGES", ["mo/ru/mirage.mo"]),
("share/locale/pl/LC_MESSAGES", ["mo/pl/mirage.mo"]),
("share/locale/fr/LC_MESSAGES", ["mo/fr/mirage.mo"]),
("share/locale/es/LC_MESSAGES", ["mo/es/mirage.mo"]),
("share/locale/de/LC_MESSAGES", ["mo/de/mirage.mo"]),
("share/locale/hu/LC_MESSAGES", ["mo/hu/mirage.mo"]),
("share/locale/cs/LC_MESSAGES", ["mo/cs/mirage.mo"]),
("share/locale/nl/LC_MESSAGES", ["mo/nl/mirage.mo"]),
("share/locale/pt/LC_MESSAGES", ["mo/pt/mirage.mo"]),
("share/locale/pt_BR/LC_MESSAGES", ["mo/pt_BR/mirage.mo"]),
("share/locale/zh_CN/LC_MESSAGES", ["mo/zh_CN/mirage.mo"]),
("share/locale/uk/LC_MESSAGES", ["mo/uk/mirage.mo"]),
("share/locale/it/LC_MESSAGES", ["mo/it/mirage.mo"]),
("share/locale/sv/LC_MESSAGES", ["mo/sv/mirage.mo"]),
],
)
# Cleanup (remove /build, /mo, and *.pyc files:
print("Cleaning up...")
try:
removeall("build/")
os.rmdir("build/")
except:
pass
try:
removeall("mo/")
os.rmdir("mo/")
except:
pass
try:
os.remove("io.thomasross.mirage.gresource")
except:
pass
try:
for f in os.listdir("."):
if os.path.isfile(f):
if os.path.splitext(os.path.basename(f))[1] == ".pyc":
os.remove(f)
except:
pass
|