2017-03-12 19:00:57 +00:00
|
|
|
# Copyright 2017 Virgil Dupras
|
2014-10-05 20:31:16 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-05 20:31:16 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-12-30 16:34:41 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import os.path as op
|
2011-01-21 13:39:33 +00:00
|
|
|
from optparse import OptionParser
|
2010-01-01 20:42:52 +00:00
|
|
|
import shutil
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-12-28 19:51:33 +00:00
|
|
|
from setuptools import setup, Extension
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-01-12 16:30:57 +00:00
|
|
|
from hscommon import sphinxgen
|
2014-10-13 19:08:59 +00:00
|
|
|
from hscommon.build import (
|
2020-01-01 02:16:27 +00:00
|
|
|
add_to_pythonpath,
|
|
|
|
print_and_do,
|
|
|
|
move_all,
|
|
|
|
fix_qt_resource_file,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon import loc
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2011-01-21 13:39:33 +00:00
|
|
|
def parse_args():
|
|
|
|
usage = "usage: %prog [options]"
|
|
|
|
parser = OptionParser(usage=usage)
|
2014-10-13 19:08:59 +00:00
|
|
|
parser.add_option(
|
2020-01-01 02:16:27 +00:00
|
|
|
"--clean",
|
|
|
|
action="store_true",
|
|
|
|
dest="clean",
|
|
|
|
help="Clean build folder before building",
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
|
|
|
parser.add_option(
|
2020-01-01 02:16:27 +00:00
|
|
|
"--doc", action="store_true", dest="doc", help="Build only the help file"
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
|
|
|
parser.add_option(
|
2020-01-01 02:16:27 +00:00
|
|
|
"--loc", action="store_true", dest="loc", help="Build only localization"
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
|
|
|
parser.add_option(
|
2020-01-01 02:16:27 +00:00
|
|
|
"--updatepot",
|
|
|
|
action="store_true",
|
|
|
|
dest="updatepot",
|
|
|
|
help="Generate .pot files from source code.",
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
|
|
|
parser.add_option(
|
2020-01-01 02:16:27 +00:00
|
|
|
"--mergepot",
|
|
|
|
action="store_true",
|
|
|
|
dest="mergepot",
|
|
|
|
help="Update all .po files based on .pot files.",
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
|
|
|
parser.add_option(
|
2020-01-01 02:16:27 +00:00
|
|
|
"--normpo",
|
|
|
|
action="store_true",
|
|
|
|
dest="normpo",
|
|
|
|
help="Normalize all PO files (do this before commit).",
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2020-12-29 02:59:01 +00:00
|
|
|
parser.add_option(
|
|
|
|
"--modules",
|
|
|
|
action="store_true",
|
|
|
|
dest="modules",
|
|
|
|
help="Build the python modules.",
|
|
|
|
)
|
2011-01-21 13:39:33 +00:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
return options
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2016-06-01 00:21:07 +00:00
|
|
|
def build_help():
|
2011-01-11 16:58:28 +00:00
|
|
|
print("Generating Help")
|
2020-01-01 02:16:27 +00:00
|
|
|
current_path = op.abspath(".")
|
|
|
|
help_basepath = op.join(current_path, "help", "en")
|
|
|
|
help_destpath = op.join(current_path, "build", "help")
|
|
|
|
changelog_path = op.join(current_path, "help", "changelog")
|
2021-01-30 21:17:43 +00:00
|
|
|
tixurl = "https://github.com/arsenetar/dupeguru/issues/{}"
|
2020-01-01 02:16:27 +00:00
|
|
|
confrepl = {"language": "en"}
|
|
|
|
changelogtmpl = op.join(current_path, "help", "changelog.tmpl")
|
|
|
|
conftmpl = op.join(current_path, "help", "conf.tmpl")
|
|
|
|
sphinxgen.gen(
|
|
|
|
help_basepath,
|
|
|
|
help_destpath,
|
|
|
|
changelog_path,
|
|
|
|
tixurl,
|
|
|
|
confrepl,
|
|
|
|
conftmpl,
|
|
|
|
changelogtmpl,
|
|
|
|
)
|
|
|
|
|
2011-01-11 16:58:28 +00:00
|
|
|
|
2012-08-02 16:49:49 +00:00
|
|
|
def build_qt_localizations():
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.compile_all_po(op.join("qtlib", "locale"))
|
|
|
|
loc.merge_locale_dir(op.join("qtlib", "locale"), "locale")
|
|
|
|
|
2012-08-02 16:49:49 +00:00
|
|
|
|
2017-03-12 19:00:57 +00:00
|
|
|
def build_localizations():
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.compile_all_po("locale")
|
2017-03-12 19:00:57 +00:00
|
|
|
build_qt_localizations()
|
2020-01-01 02:16:27 +00:00
|
|
|
locale_dest = op.join("build", "locale")
|
2012-08-02 16:49:49 +00:00
|
|
|
if op.exists(locale_dest):
|
|
|
|
shutil.rmtree(locale_dest)
|
2020-01-01 02:16:27 +00:00
|
|
|
shutil.copytree(
|
|
|
|
"locale", locale_dest, ignore=shutil.ignore_patterns("*.po", "*.pot")
|
|
|
|
)
|
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
|
2011-11-02 19:55:20 +00:00
|
|
|
def build_updatepot():
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building .pot files from source files")
|
|
|
|
print("Building core.pot")
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.generate_pot(["core"], op.join("locale", "core.pot"), ["tr"])
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building columns.pot")
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.generate_pot(["core"], op.join("locale", "columns.pot"), ["coltr"])
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building ui.pot")
|
2013-03-24 14:59:41 +00:00
|
|
|
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs
|
|
|
|
# We want to merge the generated pot with the old pot in the most preserving way possible.
|
2020-01-01 02:16:27 +00:00
|
|
|
ui_packages = ["qt", op.join("cocoa", "inter")]
|
|
|
|
loc.generate_pot(ui_packages, op.join("locale", "ui.pot"), ["tr"], merge=True)
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building qtlib.pot")
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.generate_pot(["qtlib"], op.join("qtlib", "locale", "qtlib.pot"), ["tr"])
|
|
|
|
|
2011-11-02 19:55:20 +00:00
|
|
|
|
|
|
|
def build_mergepot():
|
|
|
|
print("Updating .po files using .pot files")
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.merge_pots_into_pos("locale")
|
|
|
|
loc.merge_pots_into_pos(op.join("qtlib", "locale"))
|
|
|
|
loc.merge_pots_into_pos(op.join("cocoalib", "locale"))
|
|
|
|
|
2011-06-14 17:43:29 +00:00
|
|
|
|
2013-08-03 21:13:24 +00:00
|
|
|
def build_normpo():
|
2020-01-01 02:16:27 +00:00
|
|
|
loc.normalize_all_pos("locale")
|
|
|
|
loc.normalize_all_pos(op.join("qtlib", "locale"))
|
|
|
|
loc.normalize_all_pos(op.join("cocoalib", "locale"))
|
|
|
|
|
2013-08-03 21:13:24 +00:00
|
|
|
|
2017-03-12 19:00:57 +00:00
|
|
|
def build_pe_modules():
|
2010-08-17 07:30:25 +00:00
|
|
|
print("Building PE Modules")
|
|
|
|
exts = [
|
2016-06-01 02:32:37 +00:00
|
|
|
Extension(
|
|
|
|
"_block",
|
2020-01-01 02:16:27 +00:00
|
|
|
[
|
|
|
|
op.join("core", "pe", "modules", "block.c"),
|
|
|
|
op.join("core", "pe", "modules", "common.c"),
|
|
|
|
],
|
2016-06-01 02:32:37 +00:00
|
|
|
),
|
|
|
|
Extension(
|
|
|
|
"_cache",
|
2020-01-01 02:16:27 +00:00
|
|
|
[
|
|
|
|
op.join("core", "pe", "modules", "cache.c"),
|
|
|
|
op.join("core", "pe", "modules", "common.c"),
|
|
|
|
],
|
2016-06-01 02:32:37 +00:00
|
|
|
),
|
2010-08-17 07:30:25 +00:00
|
|
|
]
|
2020-01-01 02:16:27 +00:00
|
|
|
exts.append(Extension("_block_qt", [op.join("qt", "pe", "modules", "block.c")]))
|
2010-08-17 07:30:25 +00:00
|
|
|
setup(
|
2020-01-01 02:16:27 +00:00
|
|
|
script_args=["build_ext", "--inplace"], ext_modules=exts,
|
2010-08-17 07:30:25 +00:00
|
|
|
)
|
2020-01-01 02:16:27 +00:00
|
|
|
move_all("_block_qt*", op.join("qt", "pe"))
|
|
|
|
move_all("_block*", op.join("core", "pe"))
|
|
|
|
move_all("_cache*", op.join("core", "pe"))
|
|
|
|
|
2010-02-09 14:32:52 +00:00
|
|
|
|
2017-03-12 19:00:57 +00:00
|
|
|
def build_normal():
|
|
|
|
print("Building dupeGuru with UI qt")
|
2020-01-01 02:16:27 +00:00
|
|
|
add_to_pythonpath(".")
|
2010-08-11 14:39:06 +00:00
|
|
|
print("Building dupeGuru")
|
2017-03-12 19:00:57 +00:00
|
|
|
build_pe_modules()
|
|
|
|
print("Building localizations")
|
|
|
|
build_localizations()
|
|
|
|
print("Building Qt stuff")
|
2020-01-01 02:16:27 +00:00
|
|
|
print_and_do(
|
|
|
|
"pyrcc5 {0} > {1}".format(op.join("qt", "dg.qrc"), op.join("qt", "dg_rc.py"))
|
|
|
|
)
|
|
|
|
fix_qt_resource_file(op.join("qt", "dg_rc.py"))
|
2017-03-12 19:00:57 +00:00
|
|
|
build_help()
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2011-01-21 13:39:33 +00:00
|
|
|
def main():
|
|
|
|
options = parse_args()
|
2019-08-29 19:01:04 +00:00
|
|
|
if options.clean:
|
2020-01-01 02:16:27 +00:00
|
|
|
if op.exists("build"):
|
|
|
|
shutil.rmtree("build")
|
|
|
|
if not op.exists("build"):
|
|
|
|
os.mkdir("build")
|
2011-06-14 17:43:29 +00:00
|
|
|
if options.doc:
|
2016-06-01 00:21:07 +00:00
|
|
|
build_help()
|
2011-06-14 17:43:29 +00:00
|
|
|
elif options.loc:
|
2017-03-12 19:00:57 +00:00
|
|
|
build_localizations()
|
2011-11-02 19:55:20 +00:00
|
|
|
elif options.updatepot:
|
|
|
|
build_updatepot()
|
|
|
|
elif options.mergepot:
|
|
|
|
build_mergepot()
|
2013-08-03 21:13:24 +00:00
|
|
|
elif options.normpo:
|
|
|
|
build_normpo()
|
2020-12-29 02:59:01 +00:00
|
|
|
elif options.modules:
|
|
|
|
build_pe_modules()
|
2011-01-21 13:39:33 +00:00
|
|
|
else:
|
2017-03-12 19:00:57 +00:00
|
|
|
build_normal()
|
2011-01-21 13:39:33 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2009-12-30 16:34:41 +00:00
|
|
|
main()
|