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 24bb62c commit 3cfe600
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
41 changes: 17 additions & 24 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ def build(setup_kwargs):
print(f"Contents of current directory: {os.listdir('.')}")
print(f"Contents of iscc_core directory: {os.listdir('iscc_core')}")

try:
from Cython.Build import cythonize

use_cython = True
print("Cython is available")
except ImportError:
use_cython = False
print("Cython is not available")
# Check if we're building with Cython
use_cython = "cython" in setup_kwargs.get("extras_require", {}).get("cython", [])

if use_cython:
try:
from Cython.Build import cythonize

print("Cython is available and will be used")
ext_modules = cythonize(
[
Extension("iscc_core.cdc", ["iscc_core/cdc.py"]),
Expand All @@ -37,22 +34,18 @@ def build(setup_kwargs):
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 or build Cython modules: {e}")
print("Falling back to pure Python")
# Add Cython to build requirements
setup_kwargs.setdefault("build_requires", []).extend(
["Cython>=3", "setuptools", "wheel"]
)
except ImportError:
print("Cython is not available, falling back to pure Python")
use_cython = False
else:
print("Cython not available, using pure Python")
print("Not building with Cython, using pure Python")

if not use_cython:
# Remove any Cython-related build options
setup_kwargs.pop("ext_modules", None)

print(f"Setup kwargs: {setup_kwargs}")
7 changes: 4 additions & 3 deletions iscc_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import os

__version__ = "1.1.0"
Expand All @@ -11,10 +10,12 @@ def _using_cython_modules(): # pragma: no cover
try:
module_obj = __import__(f"iscc_core.{module}", fromlist=[module])
module_path = getattr(module_obj, "__file__", "")
module_type = type(module_obj)
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)}")
print(f"Module {module}:")
print(f" Path: {module_path}")
print(f" Type: {module_type}")
except ImportError as e:
print(f"Error importing {module}: {e}")
print(f"Cython modules: {cython_modules}")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ generate-setup-file = true
script = "build.py"

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

0 comments on commit 3cfe600

Please sign in to comment.