Skip to content

Commit

Permalink
More debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
titusz committed Oct 19, 2024
1 parent 75c1877 commit 24bb62c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
19 changes: 15 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
from setuptools import Extension


from setuptools import Extension, setup
import os
import sys

Expand Down Expand Up @@ -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")
Expand Down
20 changes: 13 additions & 7 deletions iscc_core/__init__.py
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down
6 changes: 4 additions & 2 deletions iscc_core/cdc.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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`.
Expand All @@ -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""

Expand Down

0 comments on commit 24bb62c

Please sign in to comment.