Skip to content

Commit aa04600

Browse files
committed
DO NOT MERGE
1 parent 9f82e0b commit aa04600

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ jobs:
3232
- name: Setup test suite
3333
run: tox run -vv --notest --skip-missing-interpreters false
3434
env:
35+
MAXMINDDB_REQUIRE_EXTENSION: 1
3536
TOX_GH_MAJOR_MINOR: ${{ matrix.env }}
37+
- name: Debug extension import
38+
run: tox exec -e ${{ matrix.env }} -- python ../debug_import.py
39+
continue-on-error: true
3640
- name: Run test suite
3741
run: tox run --skip-pkg-install
3842
env:

debug_import.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""Debug script to test extension import."""
2+
import os
3+
import sys
4+
import traceback
5+
6+
print(f"Python version: {sys.version}")
7+
print(f"Python executable: {sys.executable}")
8+
print(f"Current working directory: {os.getcwd()}")
9+
print(f"sys.path:")
10+
for p in sys.path:
11+
print(f" {p}")
12+
print()
13+
14+
# First, check if maxminddb can be imported at all
15+
try:
16+
import maxminddb
17+
print(f"maxminddb package location: {maxminddb.__file__}")
18+
maxminddb_dir = os.path.dirname(maxminddb.__file__)
19+
print(f"maxminddb directory: {maxminddb_dir}")
20+
print()
21+
22+
# List files in maxminddb directory
23+
print("Files in maxminddb directory:")
24+
for filename in sorted(os.listdir(maxminddb_dir)):
25+
filepath = os.path.join(maxminddb_dir, filename)
26+
size = os.path.getsize(filepath) if os.path.isfile(filepath) else "DIR"
27+
print(f" {filename:50s} {str(size):>10s}")
28+
print()
29+
30+
# Check if there's a site-packages version
31+
site_packages_path = None
32+
for path in sys.path:
33+
if 'site-packages' in path:
34+
potential = os.path.join(path, 'maxminddb')
35+
if os.path.exists(potential):
36+
site_packages_path = potential
37+
break
38+
39+
if site_packages_path and site_packages_path != maxminddb_dir:
40+
print(f"ALSO found maxminddb in site-packages: {site_packages_path}")
41+
print("Files in site-packages maxminddb:")
42+
for filename in sorted(os.listdir(site_packages_path)):
43+
filepath = os.path.join(site_packages_path, filename)
44+
size = os.path.getsize(filepath) if os.path.isfile(filepath) else "DIR"
45+
print(f" {filename:50s} {str(size):>10s}")
46+
print()
47+
except Exception as e:
48+
print(f"FAILED to import maxminddb: {e}")
49+
traceback.print_exc()
50+
sys.exit(1)
51+
52+
# Now try to import the extension
53+
try:
54+
import maxminddb.extension as ext
55+
print(f"SUCCESS: Extension imported: {ext}")
56+
print(f"Extension file: {ext.__file__}")
57+
print(f"Has Reader: {hasattr(ext, 'Reader')}")
58+
except ImportError as e:
59+
print(f"FAILED: ImportError: {e}")
60+
print("\nFull traceback:")
61+
traceback.print_exc()
62+
except Exception as e:
63+
print(f"FAILED: Unexpected error: {e}")
64+
print("\nFull traceback:")
65+
traceback.print_exc()

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ pass_env = [
112112
"MAXMINDDB_USE_SYSTEM_LIBMAXMINDDB",
113113
"MM_FORCE_EXT_TESTS",
114114
]
115+
change_dir = "{tox_root}/tests"
115116
commands = [
116-
["pytest", "tests"],
117+
["pytest", "{tox_root}/tests"],
117118
]
118119

119120
[tool.tox.env.lint]

0 commit comments

Comments
 (0)