From dd33f29988a1c901bb42f426a487eba7131638ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 10:14:50 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyrekordbox/__main__.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/pyrekordbox/__main__.py b/pyrekordbox/__main__.py index e984e74..c8c1186 100644 --- a/pyrekordbox/__main__.py +++ b/pyrekordbox/__main__.py @@ -8,7 +8,7 @@ import sys import urllib.request from pathlib import Path -from subprocess import run, CalledProcessError +from subprocess import CalledProcessError, run from pyrekordbox.config import _cache_file, write_db6_key_cache @@ -43,22 +43,27 @@ def __exit__(self, exc_type, exc_val, exc_tb): if self.path != self._prev: os.chdir(self._prev) + def set_sqlcipher_paths(): result = run(["brew", "--prefix", "sqlcipher"], capture_output=True, text=True) if result.returncode != 0: - raise CalledProcessError(result.returncode, result.args, output=result.stdout, stderr=result.stderr) + raise CalledProcessError( + result.returncode, result.args, output=result.stdout, stderr=result.stderr + ) sqlcipher_path = result.stdout.strip() - + # Ensure OpenSSL paths openssl_include_path = "/usr/local/opt/openssl/include" openssl_lib_path = "/usr/local/opt/openssl/lib" - + os.environ["C_INCLUDE_PATH"] = f"{sqlcipher_path}/include:{openssl_include_path}" os.environ["LIBRARY_PATH"] = f"{sqlcipher_path}/lib:{openssl_lib_path}" os.environ["PKG_CONFIG_PATH"] = f"{sqlcipher_path}/lib/pkgconfig" - os.environ["CFLAGS"] = f"-I{sqlcipher_path}/include -I{openssl_include_path} -Wno-deprecated-declarations -Wno-unused-variable -Wno-unreachable-code -Wno-sign-compare" + os.environ["CFLAGS"] = ( + f"-I{sqlcipher_path}/include -I{openssl_include_path} -Wno-deprecated-declarations -Wno-unused-variable -Wno-unreachable-code -Wno-sign-compare" + ) os.environ["LDFLAGS"] = f"-L{sqlcipher_path}/lib -L{openssl_lib_path}" - + print(f"SQLCipher path: {sqlcipher_path}") print(f"C_INCLUDE_PATH: {os.environ['C_INCLUDE_PATH']}") print(f"LIBRARY_PATH: {os.environ['LIBRARY_PATH']}") @@ -70,7 +75,9 @@ def set_sqlcipher_paths(): def create_symlinks(): result = run(["brew", "--prefix", "sqlcipher"], capture_output=True, text=True) if result.returncode != 0: - raise CalledProcessError(result.returncode, result.args, output=result.stdout, stderr=result.stderr) + raise CalledProcessError( + result.returncode, result.args, output=result.stdout, stderr=result.stderr + ) sqlcipher_path = result.stdout.strip() symlink_dir = Path("/usr/local") @@ -79,21 +86,27 @@ def create_symlinks(): symlink_dir.mkdir(parents=True, exist_ok=True) (symlink_dir / "lib").mkdir(parents=True, exist_ok=True) (symlink_dir / "include").mkdir(parents=True, exist_ok=True) - + lib_sqlcipher_a = symlink_dir / "lib/libsqlcipher.a" if not lib_sqlcipher_a.exists(): - lib_sqlcipher_a.symlink_to(f"{sqlcipher_path}/lib/libsqlcipher.a", target_is_directory=False) - + lib_sqlcipher_a.symlink_to( + f"{sqlcipher_path}/lib/libsqlcipher.a", target_is_directory=False + ) + include_sqlcipher = symlink_dir / "include/sqlcipher" if not include_sqlcipher.exists(): - include_sqlcipher.symlink_to(f"{sqlcipher_path}/include/sqlcipher", target_is_directory=True) + include_sqlcipher.symlink_to( + f"{sqlcipher_path}/include/sqlcipher", target_is_directory=True + ) if not (symlink_dir / "include/sqlcipher").exists(): print("Creating necessary symlinks for SQLCipher headers...") (symlink_dir / "include").mkdir(parents=True, exist_ok=True) include_sqlcipher = symlink_dir / "include/sqlcipher" if not include_sqlcipher.exists(): - include_sqlcipher.symlink_to(f"{sqlcipher_path}/include/sqlcipher", target_is_directory=True) + include_sqlcipher.symlink_to( + f"{sqlcipher_path}/include/sqlcipher", target_is_directory=True + ) def clone_repo(https_url: str) -> Path: @@ -136,6 +149,7 @@ def prepare_pysqlcipher(pysqlcipher_dir: Path, amalgamation_src: Path): shutil.copy2(amalgamation_src / "sqlite3.c", root / "sqlite3.c") shutil.copy2(amalgamation_src / "sqlite3.h", root / "sqlite3.h") + def install_pysqlcipher( tmpdir="pysqlcipher3", crypto_lib="libcrypto.lib", @@ -173,7 +187,6 @@ def install_pysqlcipher( # Install pysqlcipher package print() - # Remove temporary files if cleanup: try: