mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-06 17:09:49 +00:00
Minor Updates
- Cleanup extension modules in setup.py to use correct namespaces - Update build.py to leverage setup.py for modules - Roll mutagen required version back to 1.44.0 to support more distros - Change build.py and sphinxgen.py to use pathlib - Remove hsaudiotag from package list for debian and arch
This commit is contained in:
parent
814d145366
commit
83f401595d
81
build.py
81
build.py
@ -4,19 +4,16 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
import os
|
from pathlib import Path
|
||||||
import os.path as op
|
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
from setuptools import sandbox
|
||||||
|
|
||||||
from hscommon import sphinxgen
|
from hscommon import sphinxgen
|
||||||
from hscommon.build import (
|
from hscommon.build import (
|
||||||
add_to_pythonpath,
|
add_to_pythonpath,
|
||||||
print_and_do,
|
print_and_do,
|
||||||
move_all,
|
|
||||||
fix_qt_resource_file,
|
fix_qt_resource_file,
|
||||||
)
|
)
|
||||||
from hscommon import loc
|
from hscommon import loc
|
||||||
@ -63,14 +60,14 @@ def parse_args():
|
|||||||
|
|
||||||
def build_help():
|
def build_help():
|
||||||
print("Generating Help")
|
print("Generating Help")
|
||||||
current_path = op.abspath(".")
|
current_path = Path(".").absolute()
|
||||||
help_basepath = op.join(current_path, "help", "en")
|
help_basepath = current_path.joinpath("help", "en")
|
||||||
help_destpath = op.join(current_path, "build", "help")
|
help_destpath = current_path.joinpath("build", "help")
|
||||||
changelog_path = op.join(current_path, "help", "changelog")
|
changelog_path = current_path.joinpath("help", "changelog")
|
||||||
tixurl = "https://github.com/arsenetar/dupeguru/issues/{}"
|
tixurl = "https://github.com/arsenetar/dupeguru/issues/{}"
|
||||||
confrepl = {"language": "en"}
|
confrepl = {"language": "en"}
|
||||||
changelogtmpl = op.join(current_path, "help", "changelog.tmpl")
|
changelogtmpl = current_path.joinpath("help", "changelog.tmpl")
|
||||||
conftmpl = op.join(current_path, "help", "conf.tmpl")
|
conftmpl = current_path.joinpath("help", "conf.tmpl")
|
||||||
sphinxgen.gen(
|
sphinxgen.gen(
|
||||||
help_basepath,
|
help_basepath,
|
||||||
help_destpath,
|
help_destpath,
|
||||||
@ -83,15 +80,15 @@ def build_help():
|
|||||||
|
|
||||||
|
|
||||||
def build_qt_localizations():
|
def build_qt_localizations():
|
||||||
loc.compile_all_po(op.join("qtlib", "locale"))
|
loc.compile_all_po(Path("qtlib", "locale"))
|
||||||
loc.merge_locale_dir(op.join("qtlib", "locale"), "locale")
|
loc.merge_locale_dir(Path("qtlib", "locale"), "locale")
|
||||||
|
|
||||||
|
|
||||||
def build_localizations():
|
def build_localizations():
|
||||||
loc.compile_all_po("locale")
|
loc.compile_all_po("locale")
|
||||||
build_qt_localizations()
|
build_qt_localizations()
|
||||||
locale_dest = op.join("build", "locale")
|
locale_dest = Path("build", "locale")
|
||||||
if op.exists(locale_dest):
|
if locale_dest.exists():
|
||||||
shutil.rmtree(locale_dest)
|
shutil.rmtree(locale_dest)
|
||||||
shutil.copytree("locale", locale_dest, ignore=shutil.ignore_patterns("*.po", "*.pot"))
|
shutil.copytree("locale", locale_dest, ignore=shutil.ignore_patterns("*.po", "*.pot"))
|
||||||
|
|
||||||
@ -99,57 +96,35 @@ def build_localizations():
|
|||||||
def build_updatepot():
|
def build_updatepot():
|
||||||
print("Building .pot files from source files")
|
print("Building .pot files from source files")
|
||||||
print("Building core.pot")
|
print("Building core.pot")
|
||||||
loc.generate_pot(["core"], op.join("locale", "core.pot"), ["tr"])
|
loc.generate_pot(["core"], Path("locale", "core.pot"), ["tr"])
|
||||||
print("Building columns.pot")
|
print("Building columns.pot")
|
||||||
loc.generate_pot(["core"], op.join("locale", "columns.pot"), ["coltr"])
|
loc.generate_pot(["core"], Path("locale", "columns.pot"), ["coltr"])
|
||||||
print("Building ui.pot")
|
print("Building ui.pot")
|
||||||
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs
|
# 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.
|
# We want to merge the generated pot with the old pot in the most preserving way possible.
|
||||||
ui_packages = ["qt", op.join("cocoa", "inter")]
|
ui_packages = ["qt", Path("cocoa", "inter")]
|
||||||
loc.generate_pot(ui_packages, op.join("locale", "ui.pot"), ["tr"], merge=True)
|
loc.generate_pot(ui_packages, Path("locale", "ui.pot"), ["tr"], merge=True)
|
||||||
print("Building qtlib.pot")
|
print("Building qtlib.pot")
|
||||||
loc.generate_pot(["qtlib"], op.join("qtlib", "locale", "qtlib.pot"), ["tr"])
|
loc.generate_pot(["qtlib"], Path("qtlib", "locale", "qtlib.pot"), ["tr"])
|
||||||
|
|
||||||
|
|
||||||
def build_mergepot():
|
def build_mergepot():
|
||||||
print("Updating .po files using .pot files")
|
print("Updating .po files using .pot files")
|
||||||
loc.merge_pots_into_pos("locale")
|
loc.merge_pots_into_pos("locale")
|
||||||
loc.merge_pots_into_pos(op.join("qtlib", "locale"))
|
loc.merge_pots_into_pos(Path("qtlib", "locale"))
|
||||||
# loc.merge_pots_into_pos(op.join("cocoalib", "locale"))
|
# loc.merge_pots_into_pos(Path("cocoalib", "locale"))
|
||||||
|
|
||||||
|
|
||||||
def build_normpo():
|
def build_normpo():
|
||||||
loc.normalize_all_pos("locale")
|
loc.normalize_all_pos("locale")
|
||||||
loc.normalize_all_pos(op.join("qtlib", "locale"))
|
loc.normalize_all_pos(Path("qtlib", "locale"))
|
||||||
# loc.normalize_all_pos(op.join("cocoalib", "locale"))
|
# loc.normalize_all_pos(Path("cocoalib", "locale"))
|
||||||
|
|
||||||
|
|
||||||
def build_pe_modules():
|
def build_pe_modules():
|
||||||
print("Building PE Modules")
|
print("Building PE Modules")
|
||||||
exts = [
|
# Leverage setup.py to build modules
|
||||||
Extension(
|
sandbox.run_setup("setup.py", ["build_ext", "--inplace"])
|
||||||
"_block",
|
|
||||||
[
|
|
||||||
op.join("core", "pe", "modules", "block.c"),
|
|
||||||
op.join("core", "pe", "modules", "common.c"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Extension(
|
|
||||||
"_cache",
|
|
||||||
[
|
|
||||||
op.join("core", "pe", "modules", "cache.c"),
|
|
||||||
op.join("core", "pe", "modules", "common.c"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
exts.append(Extension("_block_qt", [op.join("qt", "pe", "modules", "block.c")]))
|
|
||||||
setup(
|
|
||||||
script_args=["build_ext", "--inplace"],
|
|
||||||
ext_modules=exts,
|
|
||||||
)
|
|
||||||
move_all("_block_qt*", op.join("qt", "pe"))
|
|
||||||
move_all("_block*", op.join("core", "pe"))
|
|
||||||
move_all("_cache*", op.join("core", "pe"))
|
|
||||||
|
|
||||||
|
|
||||||
def build_normal():
|
def build_normal():
|
||||||
@ -160,8 +135,8 @@ def build_normal():
|
|||||||
print("Building localizations")
|
print("Building localizations")
|
||||||
build_localizations()
|
build_localizations()
|
||||||
print("Building Qt stuff")
|
print("Building Qt stuff")
|
||||||
print_and_do("pyrcc5 {0} > {1}".format(op.join("qt", "dg.qrc"), op.join("qt", "dg_rc.py")))
|
print_and_do("pyrcc5 {0} > {1}".format(Path("qt", "dg.qrc"), Path("qt", "dg_rc.py")))
|
||||||
fix_qt_resource_file(op.join("qt", "dg_rc.py"))
|
fix_qt_resource_file(Path("qt", "dg_rc.py"))
|
||||||
build_help()
|
build_help()
|
||||||
|
|
||||||
|
|
||||||
@ -169,10 +144,10 @@ def main():
|
|||||||
if sys.version_info < (3, 6):
|
if sys.version_info < (3, 6):
|
||||||
sys.exit("Python < 3.6 is unsupported.")
|
sys.exit("Python < 3.6 is unsupported.")
|
||||||
options = parse_args()
|
options = parse_args()
|
||||||
if options.clean and op.exists("build"):
|
if options.clean and Path("build").exists():
|
||||||
shutil.rmtree("build")
|
shutil.rmtree("build")
|
||||||
if not op.exists("build"):
|
if not Path("build").exists():
|
||||||
os.mkdir("build")
|
Path("build").mkdir()
|
||||||
if options.doc:
|
if options.doc:
|
||||||
build_help()
|
build_help()
|
||||||
elif options.loc:
|
elif options.loc:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
import os.path as op
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .build import read_changelog_file, filereplace
|
from .build import read_changelog_file, filereplace
|
||||||
@ -48,9 +48,9 @@ def gen(
|
|||||||
if confrepl is None:
|
if confrepl is None:
|
||||||
confrepl = {}
|
confrepl = {}
|
||||||
if confpath is None:
|
if confpath is None:
|
||||||
confpath = op.join(basepath, "conf.tmpl")
|
confpath = Path(basepath, "conf.tmpl")
|
||||||
if changelogtmpl is None:
|
if changelogtmpl is None:
|
||||||
changelogtmpl = op.join(basepath, "changelog.tmpl")
|
changelogtmpl = Path(basepath, "changelog.tmpl")
|
||||||
changelog = read_changelog_file(changelogpath)
|
changelog = read_changelog_file(changelogpath)
|
||||||
tix = tixgen(tixurl)
|
tix = tixgen(tixurl)
|
||||||
rendered_logs = []
|
rendered_logs = []
|
||||||
@ -62,13 +62,13 @@ def gen(
|
|||||||
rendered = CHANGELOG_FORMAT.format(version=log["version"], date=log["date_str"], description=description)
|
rendered = CHANGELOG_FORMAT.format(version=log["version"], date=log["date_str"], description=description)
|
||||||
rendered_logs.append(rendered)
|
rendered_logs.append(rendered)
|
||||||
confrepl["version"] = changelog[0]["version"]
|
confrepl["version"] = changelog[0]["version"]
|
||||||
changelog_out = op.join(basepath, "changelog.rst")
|
changelog_out = Path(basepath, "changelog.rst")
|
||||||
filereplace(changelogtmpl, changelog_out, changelog="\n".join(rendered_logs))
|
filereplace(changelogtmpl, changelog_out, changelog="\n".join(rendered_logs))
|
||||||
if op.exists(confpath):
|
if Path(confpath).exists():
|
||||||
conf_out = op.join(basepath, "conf.py")
|
conf_out = Path(basepath, "conf.py")
|
||||||
filereplace(confpath, conf_out, **confrepl)
|
filereplace(confpath, conf_out, **confrepl)
|
||||||
# Call the sphinx_build function, which is the same as doing sphinx-build from cli
|
# Call the sphinx_build function, which is the same as doing sphinx-build from cli
|
||||||
try:
|
try:
|
||||||
sphinx_build([basepath, destpath])
|
sphinx_build([str(basepath), str(destpath)])
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
print("Sphinx called sys.exit(), but we're cancelling it because we don't actually want to exit")
|
print("Sphinx called sys.exit(), but we're cancelling it because we don't actually want to exit")
|
||||||
|
14
package.py
14
package.py
@ -71,7 +71,7 @@ def package_debian_distribution(distribution):
|
|||||||
version = "{}~{}".format(app_version, distribution)
|
version = "{}~{}".format(app_version, distribution)
|
||||||
destpath = op.join("build", "dupeguru-{}".format(version))
|
destpath = op.join("build", "dupeguru-{}".format(version))
|
||||||
srcpath = op.join(destpath, "src")
|
srcpath = op.join(destpath, "src")
|
||||||
packages = ["hscommon", "core", "qtlib", "qt", "send2trash", "hsaudiotag"]
|
packages = ["hscommon", "core", "qtlib", "qt", "send2trash"]
|
||||||
copy_files_to_package(srcpath, packages, with_so=False)
|
copy_files_to_package(srcpath, packages, with_so=False)
|
||||||
os.mkdir(op.join(destpath, "modules"))
|
os.mkdir(op.join(destpath, "modules"))
|
||||||
copy_all(op.join("core", "pe", "modules", "*.*"), op.join(destpath, "modules"))
|
copy_all(op.join("core", "pe", "modules", "*.*"), op.join(destpath, "modules"))
|
||||||
@ -122,14 +122,7 @@ def package_arch():
|
|||||||
# need to include them).
|
# need to include them).
|
||||||
print("Packaging for Arch")
|
print("Packaging for Arch")
|
||||||
srcpath = op.join("build", "dupeguru-arch")
|
srcpath = op.join("build", "dupeguru-arch")
|
||||||
packages = [
|
packages = ["hscommon", "core", "qtlib", "qt", "send2trash"]
|
||||||
"hscommon",
|
|
||||||
"core",
|
|
||||||
"qtlib",
|
|
||||||
"qt",
|
|
||||||
"send2trash",
|
|
||||||
"hsaudiotag",
|
|
||||||
]
|
|
||||||
copy_files_to_package(srcpath, packages, with_so=True)
|
copy_files_to_package(srcpath, packages, with_so=True)
|
||||||
shutil.copy(op.join("images", "dgse_logo_128.png"), srcpath)
|
shutil.copy(op.join("images", "dgse_logo_128.png"), srcpath)
|
||||||
debopts = json.load(open(op.join("pkg", "arch", "dupeguru.json")))
|
debopts = json.load(open(op.join("pkg", "arch", "dupeguru.json")))
|
||||||
@ -233,7 +226,8 @@ def main():
|
|||||||
return
|
return
|
||||||
print("Packaging dupeGuru with UI qt")
|
print("Packaging dupeGuru with UI qt")
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
package_windows()
|
package_debian()
|
||||||
|
# package_windows()
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
package_macos()
|
package_macos()
|
||||||
else:
|
else:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Send2Trash>=1.3.0
|
Send2Trash>=1.3.0
|
||||||
sphinx>=3.0.0
|
sphinx>=3.0.0
|
||||||
polib>=1.1.0
|
polib>=1.1.0
|
||||||
mutagen>=1.45.1
|
mutagen>=1.44.0
|
||||||
distro>=1.5.0
|
distro>=1.5.0
|
||||||
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
|
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
|
||||||
pywin32>=228; sys_platform == 'win32'
|
pywin32>=228; sys_platform == 'win32'
|
11
setup.py
11
setup.py
@ -3,7 +3,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
exts = [
|
exts = [
|
||||||
Extension(
|
Extension(
|
||||||
"_block",
|
"core.pe._block",
|
||||||
[
|
[
|
||||||
str(Path("core", "pe", "modules", "block.c")),
|
str(Path("core", "pe", "modules", "block.c")),
|
||||||
str(Path("core", "pe", "modules", "common.c")),
|
str(Path("core", "pe", "modules", "common.c")),
|
||||||
@ -11,19 +11,16 @@ exts = [
|
|||||||
include_dirs=[str(Path("core", "pe", "modules"))],
|
include_dirs=[str(Path("core", "pe", "modules"))],
|
||||||
),
|
),
|
||||||
Extension(
|
Extension(
|
||||||
"_cache",
|
"core.pe._cache",
|
||||||
[
|
[
|
||||||
str(Path("core", "pe", "modules", "cache.c")),
|
str(Path("core", "pe", "modules", "cache.c")),
|
||||||
str(Path("core", "pe", "modules", "common.c")),
|
str(Path("core", "pe", "modules", "common.c")),
|
||||||
],
|
],
|
||||||
include_dirs=[str(Path("core", "pe", "modules"))],
|
include_dirs=[str(Path("core", "pe", "modules"))],
|
||||||
),
|
),
|
||||||
Extension("_block_qt", [str(Path("qt", "pe", "modules", "block.c"))]),
|
Extension("qt.pe._block_qt", [str(Path("qt", "pe", "modules", "block.c"))]),
|
||||||
]
|
]
|
||||||
|
|
||||||
headers = [str(Path("core", "pe", "modules", "common.h"))]
|
headers = [str(Path("core", "pe", "modules", "common.h"))]
|
||||||
|
|
||||||
setup(
|
setup(ext_modules=exts, headers=headers)
|
||||||
ext_modules=exts,
|
|
||||||
headers=headers,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user