Skip to content

Commit 3cfe600

Browse files
committed
More debug output
1 parent 24bb62c commit 3cfe600

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

build.py

+17-24
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ def build(setup_kwargs):
1010
print(f"Contents of current directory: {os.listdir('.')}")
1111
print(f"Contents of iscc_core directory: {os.listdir('iscc_core')}")
1212

13-
try:
14-
from Cython.Build import cythonize
15-
16-
use_cython = True
17-
print("Cython is available")
18-
except ImportError:
19-
use_cython = False
20-
print("Cython is not available")
13+
# Check if we're building with Cython
14+
use_cython = "cython" in setup_kwargs.get("extras_require", {}).get("cython", [])
2115

2216
if use_cython:
2317
try:
18+
from Cython.Build import cythonize
19+
20+
print("Cython is available and will be used")
2421
ext_modules = cythonize(
2522
[
2623
Extension("iscc_core.cdc", ["iscc_core/cdc.py"]),
@@ -37,22 +34,18 @@ def build(setup_kwargs):
3734
for ext in ext_modules:
3835
print(f"Extension: {ext.name}")
3936

40-
# Force the build process
41-
setup(**setup_kwargs)
42-
print("Build process completed")
43-
44-
# Check if the compiled modules exist
45-
for ext in ext_modules:
46-
module_name = ext.name.split(".")[-1]
47-
compiled_file = f"{module_name}.cp{sys.version_info.major}{sys.version_info.minor}-win_amd64.pyd"
48-
if os.path.exists(os.path.join("iscc_core", compiled_file)):
49-
print(f"Compiled module found: {compiled_file}")
50-
else:
51-
print(f"Compiled module not found: {compiled_file}")
52-
except Exception as e:
53-
print(f"Failed to prepare or build Cython modules: {e}")
54-
print("Falling back to pure Python")
37+
# Add Cython to build requirements
38+
setup_kwargs.setdefault("build_requires", []).extend(
39+
["Cython>=3", "setuptools", "wheel"]
40+
)
41+
except ImportError:
42+
print("Cython is not available, falling back to pure Python")
43+
use_cython = False
5544
else:
56-
print("Cython not available, using pure Python")
45+
print("Not building with Cython, using pure Python")
46+
47+
if not use_cython:
48+
# Remove any Cython-related build options
49+
setup_kwargs.pop("ext_modules", None)
5750

5851
print(f"Setup kwargs: {setup_kwargs}")

iscc_core/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import os
32

43
__version__ = "1.1.0"
@@ -11,10 +10,12 @@ def _using_cython_modules(): # pragma: no cover
1110
try:
1211
module_obj = __import__(f"iscc_core.{module}", fromlist=[module])
1312
module_path = getattr(module_obj, "__file__", "")
13+
module_type = type(module_obj)
1414
if module_path.endswith((".so", ".pyd")):
1515
cython_modules.append(module)
16-
print(f"Module {module} path: {module_path}")
17-
print(f"Module {module} type: {type(module_obj)}")
16+
print(f"Module {module}:")
17+
print(f" Path: {module_path}")
18+
print(f" Type: {module_type}")
1819
except ImportError as e:
1920
print(f"Error importing {module}: {e}")
2021
print(f"Cython modules: {cython_modules}")

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ generate-setup-file = true
9999
script = "build.py"
100100

101101
[build-system]
102-
requires = ["poetry-core>=1.0.0", "Cython>=3", "setuptools", "wheel"]
102+
requires = ["poetry-core>=1.0.0"]
103103
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)