From 24bb62c9282ece656d1a3c33d71198b3ec2272ce Mon Sep 17 00:00:00 2001 From: Titusz Pan Date: Sat, 19 Oct 2024 21:10:06 +0200 Subject: [PATCH] More debug output --- build.py | 19 +++++++++++++++---- iscc_core/__init__.py | 20 +++++++++++++------- iscc_core/cdc.py | 6 ++++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/build.py b/build.py index a2fcec5..772e0cb 100644 --- a/build.py +++ b/build.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from setuptools import Extension - - +from setuptools import Extension, setup import os import sys @@ -38,8 +36,21 @@ def build(setup_kwargs): print(f"Number of extensions: {len(ext_modules)}") for ext in ext_modules: print(f"Extension: {ext.name}") + + # Force the build process + setup(**setup_kwargs) + print("Build process completed") + + # Check if the compiled modules exist + for ext in ext_modules: + module_name = ext.name.split(".")[-1] + compiled_file = f"{module_name}.cp{sys.version_info.major}{sys.version_info.minor}-win_amd64.pyd" + if os.path.exists(os.path.join("iscc_core", compiled_file)): + print(f"Compiled module found: {compiled_file}") + else: + print(f"Compiled module not found: {compiled_file}") except Exception as e: - print(f"Failed to prepare Cython modules: {e}") + print(f"Failed to prepare or build Cython modules: {e}") print("Falling back to pure Python") else: print("Cython not available, using pure Python") diff --git a/iscc_core/__init__.py b/iscc_core/__init__.py index 5063b3b..06fe58b 100644 --- a/iscc_core/__init__.py +++ b/iscc_core/__init__.py @@ -1,34 +1,40 @@ import sys +import os + +__version__ = "1.1.0" def _using_cython_modules(): # pragma: no cover modules = ["cdc", "minhash", "simhash", "dct", "wtahash"] cython_modules = [] for module in modules: - module_path = getattr(sys.modules.get(f"iscc_core.{module}"), "__file__", "") - if module_path.endswith((".so", ".pyd")): - cython_modules.append(module) - print(f"Module {module} path: {module_path}") + try: + module_obj = __import__(f"iscc_core.{module}", fromlist=[module]) + module_path = getattr(module_obj, "__file__", "") + if module_path.endswith((".so", ".pyd")): + cython_modules.append(module) + print(f"Module {module} path: {module_path}") + print(f"Module {module} type: {type(module_obj)}") + except ImportError as e: + print(f"Error importing {module}: {e}") print(f"Cython modules: {cython_modules}") + print(f"iscc_core directory contents: {os.listdir(os.path.dirname(__file__))}") return bool(cython_modules) USING_CYTHON = _using_cython_modules() print(f"USING_CYTHON: {USING_CYTHON}") -__version__ = "1.1.0" from iscc_core.options import core_opts, conformant_options # Import full api to toplevel from iscc_core.conformance import * from iscc_core.constants import * - from iscc_core.simhash import * from iscc_core.minhash import * from iscc_core.wtahash import * from iscc_core.dct import * from iscc_core.cdc import * - from iscc_core.iscc_code import * from iscc_core.iscc_id import * from iscc_core.code_meta import * diff --git a/iscc_core/cdc.py b/iscc_core/cdc.py index 54919f5..d89132d 100644 --- a/iscc_core/cdc.py +++ b/iscc_core/cdc.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- """Compatible with [fastcdc](https://pypi.org/project/fastcdc/)""" + import io from math import log2 from typing import Generator +from iscc_core.options import core_opts import iscc_core as ic @@ -11,7 +13,7 @@ ] -def alg_cdc_chunks(data, utf32, avg_chunk_size=ic.core_opts.data_avg_chunk_size): +def alg_cdc_chunks(data, utf32, avg_chunk_size=core_opts.data_avg_chunk_size): # type: (ic.Data, bool, int) -> Generator[bytes, None, None] """ A generator that yields data-dependent chunks for `data`. @@ -31,7 +33,7 @@ def alg_cdc_chunks(data, utf32, avg_chunk_size=ic.core_opts.data_avg_chunk_size) """ stream = io.BytesIO(data) - buffer = stream.read(ic.core_opts.io_read_size) + buffer = stream.read(core_opts.io_read_size) if not buffer: yield b""