File size: 1,366 Bytes
85e93a2
6d70778
85e93a2
 
6d70778
73d3d37
6d70778
 
 
85e93a2
 
6d70778
85e93a2
 
6d70778
 
 
 
 
 
 
 
 
 
 
85e93a2
 
 
 
 
89a139c
85e93a2
 
 
89a139c
85e93a2
89a139c
85e93a2
89a139c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Pytest conftest for Necthrall test configuration.

This file sets up the test environment with proper threading settings
and handles Windows-specific configurations.
"""

import os
import sys

# Set environment variables BEFORE any imports that might use parallel processing
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")

# WINDOWS DLL FIX: Add torch/lib to DLL search path if torch is installed
# This MUST happen before importing torch or any library that uses torch
if os.name == "nt":
    try:
        torch_lib = os.path.join(sys.prefix, "Lib", "site-packages", "torch", "lib")
        if os.path.isdir(torch_lib):
            try:
                os.add_dll_directory(torch_lib)
            except Exception:
                os.environ["PATH"] = torch_lib + os.pathsep + os.environ.get("PATH", "")
    except Exception:
        pass

# CRITICAL: Import torch FIRST before any other library that might load conflicting DLLs
# This prevents DLL conflicts with onnxruntime, sentence-transformers, etc.
# Wrapped in try/except to continue if this fails - tests may still work with mocking
try:
    import torch  # noqa: F401

    _torch_loaded = True
except (ImportError, OSError):
    _torch_loaded = False

# Import fitz (PyMuPDF) early if available - it has its own DLL requirements
try:
    import fitz  # noqa: F401
except ImportError:
    pass