From 06cad66925a32634641ae2514412944f719a68f1 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 30 Apr 2024 10:33:28 +0200 Subject: [PATCH] Clean up a bit import in dependencies. --- kiwixbuild/dependencies/icu4c.py | 73 +++++++++++++---------- kiwixbuild/dependencies/libcurl.py | 5 +- kiwixbuild/dependencies/libkiwix.py | 5 +- kiwixbuild/dependencies/libmagic.py | 4 +- kiwixbuild/dependencies/qt.py | 4 +- kiwixbuild/dependencies/tc_android_ndk.py | 4 +- kiwixbuild/dependencies/tc_emsdk.py | 6 +- kiwixbuild/dependencies/tc_flatpak.py | 2 - kiwixbuild/dependencies/zlib.py | 17 ++---- 9 files changed, 53 insertions(+), 67 deletions(-) diff --git a/kiwixbuild/dependencies/icu4c.py b/kiwixbuild/dependencies/icu4c.py index fd0c637..3c7125c 100644 --- a/kiwixbuild/dependencies/icu4c.py +++ b/kiwixbuild/dependencies/icu4c.py @@ -1,10 +1,6 @@ -from .base import ( - Dependency, - ReleaseDownload, - MakeBuilder, MesonBuilder -) +from .base import Dependency, ReleaseDownload, MakeBuilder, MesonBuilder -from kiwixbuild.utils import pj, SkipCommand, Remotefile, extract_archive +from kiwixbuild.utils import pj, Remotefile, extract_archive from kiwixbuild._global import get_target_step, neutralEnv import os, shutil import fileinput @@ -15,16 +11,21 @@ class Icu(Dependency): name = "icu4c" class Source(ReleaseDownload): - archive_src = Remotefile('icu4c-73_2-src.tgz', - '818a80712ed3caacd9b652305e01afc7fa167e6f2e94996da44b90c2ab604ce1', - 'https://github.com/unicode-org/icu/releases/download/release-73-2/icu4c-73_2-src.tgz') - archive_data = Remotefile('icu4c-73_2-data.zip', - 'ca1ee076163b438461e484421a7679fc33a64cd0a54f9d4b401893fa1eb42701', - 'https://github.com/unicode-org/icu/releases/download/release-73-2/icu4c-73_2-data.zip') - meson_patch = Remotefile('icu_73.2-2_patch.zip', - '', - 'https://wrapdb.mesonbuild.com/v2/icu_73.2-2/get_patch') - + archive_src = Remotefile( + "icu4c-73_2-src.tgz", + "818a80712ed3caacd9b652305e01afc7fa167e6f2e94996da44b90c2ab604ce1", + "https://github.com/unicode-org/icu/releases/download/release-73-2/icu4c-73_2-src.tgz", + ) + archive_data = Remotefile( + "icu4c-73_2-data.zip", + "ca1ee076163b438461e484421a7679fc33a64cd0a54f9d4b401893fa1eb42701", + "https://github.com/unicode-org/icu/releases/download/release-73-2/icu4c-73_2-data.zip", + ) + meson_patch = Remotefile( + "icu_73.2-2_patch.zip", + "", + "https://wrapdb.mesonbuild.com/v2/icu_73.2-2/get_patch", + ) archives = [archive_src, archive_data, meson_patch] @@ -48,28 +49,33 @@ class Icu(Dependency): name="data", ) extract_archive( - pj(neutralEnv('archive_dir'), self.meson_patch.name), - neutralEnv('source_dir'), - topdir='icu', - name= self.source_dir + pj(neutralEnv("archive_dir"), self.meson_patch.name), + neutralEnv("source_dir"), + topdir="icu", + name=self.source_dir, ) patches = [ - "icu4c_fix_static_lib_name_mingw.patch", - # "icu4c_android_elf64_st_info.patch", - # "icu4c_custom_data.patch", - # "icu4c_noxlocale.patch", - "icu4c_rpath.patch", - # "icu4c_build_config.patch", - "icu4c_wasm.patch", - ] + "icu4c_fix_static_lib_name_mingw.patch", + # "icu4c_android_elf64_st_info.patch", + # "icu4c_custom_data.patch", + # "icu4c_noxlocale.patch", + "icu4c_rpath.patch", + # "icu4c_build_config.patch", + "icu4c_wasm.patch", + ] + + if platform.system() == "Windows": - if platform.system() == 'Windows': class Builder(MesonBuilder): def set_env(self, env): - env['ICU_DATA_FILTER_FILE'] = pj(os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json") + env["ICU_DATA_FILTER_FILE"] = pj( + os.path.dirname(os.path.realpath(__file__)), + "icu4c_data_filter.json", + ) else: + class Builder(MakeBuilder): subsource_dir = "source" make_install_targets = ["install"] @@ -100,14 +106,17 @@ class Icu(Dependency): def set_env(self, env): env["ICU_DATA_FILTER_FILE"] = pj( - os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json" + os.path.dirname(os.path.realpath(__file__)), + "icu4c_data_filter.json", ) def _post_configure_script(self, context): if self.buildEnv.configInfo.build != "wasm": context.skip() context.try_skip(self.build_path) - for line in fileinput.input(pj(self.build_path, "Makefile"), inplace=True): + for line in fileinput.input( + pj(self.build_path, "Makefile"), inplace=True + ): if line == "#DATASUBDIR = data\n": print("DATASUBDIR = data") else: diff --git a/kiwixbuild/dependencies/libcurl.py b/kiwixbuild/dependencies/libcurl.py index f63ef7b..7f62557 100644 --- a/kiwixbuild/dependencies/libcurl.py +++ b/kiwixbuild/dependencies/libcurl.py @@ -1,13 +1,10 @@ -import os - from .base import ( Dependency, ReleaseDownload, MakeBuilder, ) -from kiwixbuild.utils import Remotefile, pj, Defaultdict, SkipCommand, run_command -from kiwixbuild._global import get_target_step +from kiwixbuild.utils import Remotefile class LibCurl(Dependency): diff --git a/kiwixbuild/dependencies/libkiwix.py b/kiwixbuild/dependencies/libkiwix.py index 66c7a59..3eac5c4 100644 --- a/kiwixbuild/dependencies/libkiwix.py +++ b/kiwixbuild/dependencies/libkiwix.py @@ -1,8 +1,5 @@ -import shutil, os - from .base import Dependency, GitClone, MesonBuilder -from kiwixbuild.utils import pj, copy_tree -from kiwixbuild._global import option, get_target_step, neutralEnv +from kiwixbuild._global import option class Libkiwix(Dependency): diff --git a/kiwixbuild/dependencies/libmagic.py b/kiwixbuild/dependencies/libmagic.py index 0e5c876..9f860b8 100644 --- a/kiwixbuild/dependencies/libmagic.py +++ b/kiwixbuild/dependencies/libmagic.py @@ -1,12 +1,10 @@ -import os - from .base import ( Dependency, ReleaseDownload, MakeBuilder, ) -from kiwixbuild.utils import Remotefile, pj, SkipCommand, run_command +from kiwixbuild.utils import Remotefile, pj, run_command from kiwixbuild._global import get_target_step diff --git a/kiwixbuild/dependencies/qt.py b/kiwixbuild/dependencies/qt.py index 1a55ae3..2f31a92 100644 --- a/kiwixbuild/dependencies/qt.py +++ b/kiwixbuild/dependencies/qt.py @@ -1,8 +1,6 @@ -import shutil - from .base import Dependency, ReleaseDownload, MakeBuilder, QMakeBuilder -from kiwixbuild.utils import Remotefile, pj, SkipCommand +from kiwixbuild.utils import Remotefile, pj class Qt(Dependency): diff --git a/kiwixbuild/dependencies/tc_android_ndk.py b/kiwixbuild/dependencies/tc_android_ndk.py index 3774976..c65768f 100644 --- a/kiwixbuild/dependencies/tc_android_ndk.py +++ b/kiwixbuild/dependencies/tc_android_ndk.py @@ -1,9 +1,7 @@ import os from .base import Dependency, ReleaseDownload, Builder -from kiwixbuild.utils import Remotefile, add_execution_right, run_command - -pj = os.path.join +from kiwixbuild.utils import Remotefile, add_execution_right, run_command, pj class android_ndk(Dependency): diff --git a/kiwixbuild/dependencies/tc_emsdk.py b/kiwixbuild/dependencies/tc_emsdk.py index 5b26c3b..f47f9f7 100644 --- a/kiwixbuild/dependencies/tc_emsdk.py +++ b/kiwixbuild/dependencies/tc_emsdk.py @@ -1,9 +1,5 @@ -import os - from .base import Dependency, ReleaseDownload, Builder -from kiwixbuild.utils import Remotefile, run_command, copy_tree - -pj = os.path.join +from kiwixbuild.utils import pj, Remotefile, run_command, copy_tree class emsdk(Dependency): diff --git a/kiwixbuild/dependencies/tc_flatpak.py b/kiwixbuild/dependencies/tc_flatpak.py index 21b0fd5..603c7a5 100644 --- a/kiwixbuild/dependencies/tc_flatpak.py +++ b/kiwixbuild/dependencies/tc_flatpak.py @@ -3,8 +3,6 @@ import os from .base import Dependency, NoopSource, Builder from kiwixbuild.utils import Remotefile, add_execution_right, run_command -pj = os.path.join - class org_kde(Dependency): neutral = False diff --git a/kiwixbuild/dependencies/zlib.py b/kiwixbuild/dependencies/zlib.py index 2ede4e2..7ee54d5 100644 --- a/kiwixbuild/dependencies/zlib.py +++ b/kiwixbuild/dependencies/zlib.py @@ -1,12 +1,6 @@ -import shutil +from .base import Dependency, ReleaseDownload, MesonBuilder -from .base import ( - Dependency, - ReleaseDownload, - MesonBuilder) - -from kiwixbuild.utils import Remotefile, pj, SkipCommand -from kiwixbuild._global import neutralEnv +from kiwixbuild.utils import Remotefile class zlib(Dependency): @@ -15,13 +9,14 @@ class zlib(Dependency): class Source(ReleaseDownload): src_archive = Remotefile( "zlib-1.2.12.tar.gz", - "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9" + "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9", ) meson_patch = Remotefile( "zlib_1.2.12-1_patch.zip", "8ec8344f3fe7b06ad4be768fd416694bc56cb4545ce78b0f1c18b3e72b3ec936", - "https://wrapdb.mesonbuild.com/v2/zlib_1.2.12-1/get_patch") + "https://wrapdb.mesonbuild.com/v2/zlib_1.2.12-1/get_patch", + ) archives = [src_archive, meson_patch] - #patches = ['zlib_std_libname.patch'] + # patches = ['zlib_std_libname.patch'] Builder = MesonBuilder