maxminddb-rust 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. maxminddb_rust-0.1.0/.githooks/pre-commit +20 -0
  2. maxminddb_rust-0.1.0/.github/dependabot.yml +28 -0
  3. maxminddb_rust-0.1.0/.github/workflows/codeql.yml +55 -0
  4. maxminddb_rust-0.1.0/.github/workflows/lint.yml +80 -0
  5. maxminddb_rust-0.1.0/.github/workflows/release.yml +113 -0
  6. maxminddb_rust-0.1.0/.github/workflows/test.yml +51 -0
  7. maxminddb_rust-0.1.0/.github/workflows/zizmor.yml +25 -0
  8. maxminddb_rust-0.1.0/.gitignore +88 -0
  9. maxminddb_rust-0.1.0/.gitmodules +3 -0
  10. maxminddb_rust-0.1.0/CHANGELOG.md +81 -0
  11. maxminddb_rust-0.1.0/CONTRIBUTING.md +215 -0
  12. maxminddb_rust-0.1.0/Cargo.lock +298 -0
  13. maxminddb_rust-0.1.0/Cargo.toml +28 -0
  14. maxminddb_rust-0.1.0/LICENSE +15 -0
  15. maxminddb_rust-0.1.0/MIGRATION.md +261 -0
  16. maxminddb_rust-0.1.0/PKG-INFO +243 -0
  17. maxminddb_rust-0.1.0/README.md +210 -0
  18. maxminddb_rust-0.1.0/benchmark_comprehensive.py +80 -0
  19. maxminddb_rust-0.1.0/examples/basic_usage.py +90 -0
  20. maxminddb_rust-0.1.0/examples/batch_processing.py +245 -0
  21. maxminddb_rust-0.1.0/examples/benchmark.py +33 -0
  22. maxminddb_rust-0.1.0/examples/benchmark_batch.py +40 -0
  23. maxminddb_rust-0.1.0/examples/context_manager.py +137 -0
  24. maxminddb_rust-0.1.0/examples/iterator_demo.py +174 -0
  25. maxminddb_rust-0.1.0/maxminddb_rust.pyi +281 -0
  26. maxminddb_rust-0.1.0/precious.toml +60 -0
  27. maxminddb_rust-0.1.0/py.typed +0 -0
  28. maxminddb_rust-0.1.0/pyproject.toml +53 -0
  29. maxminddb_rust-0.1.0/src/lib.rs +1013 -0
  30. maxminddb_rust-0.1.0/tests/__init__.py +0 -0
  31. maxminddb_rust-0.1.0/tests/maxmind/README.md +157 -0
  32. maxminddb_rust-0.1.0/tests/maxmind/UPSTREAM_LICENSE +192 -0
  33. maxminddb_rust-0.1.0/tests/maxmind/__init__.py +0 -0
  34. maxminddb_rust-0.1.0/tests/maxmind/reader_test.py +749 -0
  35. maxminddb_rust-0.1.0/uv.lock +228 -0
@@ -0,0 +1,20 @@
1
+ #!/bin/bash
2
+ #
3
+ # Git pre-commit hook that runs precious lint on staged files
4
+ #
5
+
6
+ set -e
7
+
8
+ echo "Running precious lint on staged files..."
9
+
10
+ # Run precious lint on staged files
11
+ if ! precious lint --staged; then
12
+ echo ""
13
+ echo "❌ Linting failed. Please fix the issues above before committing."
14
+ echo ""
15
+ echo "To fix formatting issues automatically, run:"
16
+ echo " precious tidy --staged"
17
+ exit 1
18
+ fi
19
+
20
+ echo "✅ All linters passed!"
@@ -0,0 +1,28 @@
1
+ ---
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: cargo
5
+ directory: /
6
+ schedule:
7
+ interval: daily
8
+ time: "14:00"
9
+ open-pull-requests-limit: 10
10
+ cooldown:
11
+ default-days: 4
12
+
13
+ - package-ecosystem: pip
14
+ directory: /
15
+ schedule:
16
+ interval: daily
17
+ time: "14:00"
18
+ open-pull-requests-limit: 10
19
+ cooldown:
20
+ default-days: 4
21
+
22
+ - package-ecosystem: github-actions
23
+ directory: /
24
+ schedule:
25
+ interval: daily
26
+ time: "14:00"
27
+ cooldown:
28
+ default-days: 4
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: CodeQL
3
+
4
+ on:
5
+ push:
6
+ branches-ignore:
7
+ - "dependabot/**"
8
+ pull_request:
9
+ schedule:
10
+ - cron: "0 18 * * 0"
11
+
12
+ permissions: {}
13
+
14
+ jobs:
15
+ analyze:
16
+ name: Analyze
17
+ runs-on: ubuntu-latest
18
+
19
+ permissions:
20
+ security-events: write
21
+
22
+ steps:
23
+ - name: Checkout repository
24
+ uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
25
+ with:
26
+ fetch-depth: 2
27
+ persist-credentials: false
28
+
29
+ - name: Checkout pull request HEAD
30
+ if: github.event_name == 'pull_request'
31
+ run: git checkout HEAD^2
32
+
33
+ - name: Set up Python
34
+ uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
35
+ with:
36
+ python-version: "3.x"
37
+
38
+ - name: Install Rust
39
+ uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # master
40
+ with:
41
+ toolchain: stable
42
+
43
+ - name: Initialize CodeQL
44
+ uses: github/codeql-action/init@v3
45
+ with:
46
+ languages: python, rust
47
+
48
+ - name: Install maturin
49
+ run: pip install maturin
50
+
51
+ - name: Build extension
52
+ run: maturin build --release
53
+
54
+ - name: Perform CodeQL Analysis
55
+ uses: github/codeql-action/analyze@v3
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: Lint
3
+
4
+ on:
5
+ push:
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ clippy:
13
+ name: Clippy
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17
+ with:
18
+ persist-credentials: false
19
+
20
+ - name: Install Rust
21
+ uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # master
22
+ with:
23
+ toolchain: stable
24
+ components: clippy
25
+
26
+ - name: Run clippy
27
+ run: cargo clippy --all-targets --all-features -- -D warnings
28
+
29
+ rustfmt:
30
+ name: Rustfmt
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34
+ with:
35
+ persist-credentials: false
36
+
37
+ - name: Install Rust
38
+ uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # master
39
+ with:
40
+ toolchain: stable
41
+ components: rustfmt
42
+
43
+ - name: Run rustfmt
44
+ run: cargo fmt --all -- --check
45
+
46
+ ruff:
47
+ name: Ruff
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
51
+ with:
52
+ persist-credentials: false
53
+
54
+ - name: Install ruff
55
+ run: pip install ruff
56
+
57
+ - name: Run ruff check
58
+ run: ruff check .
59
+
60
+ - name: Run ruff format check
61
+ run: ruff format --check .
62
+
63
+ prettier:
64
+ name: Prettier
65
+ runs-on: ubuntu-latest
66
+ steps:
67
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
68
+ with:
69
+ persist-credentials: false
70
+
71
+ - name: Setup Node.js
72
+ uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
73
+ with:
74
+ node-version: "20"
75
+
76
+ - name: Install Prettier
77
+ run: npm install -g prettier
78
+
79
+ - name: Run Prettier
80
+ run: prettier --check "**/*.md" "**/*.yml"
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: Release
3
+
4
+ on:
5
+ workflow_dispatch:
6
+ pull_request:
7
+ push:
8
+ branches:
9
+ - main
10
+ release:
11
+ types:
12
+ - published
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ build_wheels:
19
+ name: Build wheels on ${{ matrix.os }}
20
+ runs-on: ${{ matrix.os }}
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ include:
25
+ - os: ubuntu-latest
26
+ target: x86_64
27
+ - os: ubuntu-latest
28
+ target: aarch64
29
+ - os: macos-latest
30
+ target: x86_64
31
+ - os: macos-latest
32
+ target: aarch64
33
+ - os: windows-latest
34
+ target: x86_64
35
+ - os: windows-latest
36
+ target: aarch64
37
+ python_versions: "3.11 3.12 3.13 3.14"
38
+
39
+ steps:
40
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41
+ with:
42
+ persist-credentials: false
43
+
44
+ - name: Set up Python
45
+ uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
46
+ with:
47
+ python-version: "3.x"
48
+
49
+ - name: Install maturin
50
+ run: pip install maturin
51
+
52
+ - name: Set up Zig
53
+ if: runner.os == 'Windows'
54
+ uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5
55
+
56
+ - name: Set up QEMU
57
+ if: runner.os == 'Linux' && matrix.target == 'aarch64'
58
+ uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
59
+ with:
60
+ platforms: arm64
61
+
62
+ - name: Build wheels
63
+ uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
64
+ with:
65
+ target: ${{ matrix.target }}
66
+ args: --release --out dist --interpreter ${{ matrix.python_versions || '3.9 3.10 3.11 3.12 3.13 3.14' }}
67
+ sccache: "true"
68
+ manylinux: auto
69
+
70
+ - name: Upload wheels
71
+ uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
72
+ with:
73
+ name: maxminddb-rust-whl-${{ matrix.os }}-${{ matrix.target }}
74
+ path: dist
75
+
76
+ build_sdist:
77
+ name: Build source distribution
78
+ runs-on: ubuntu-latest
79
+ steps:
80
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
81
+ with:
82
+ persist-credentials: false
83
+
84
+ - name: Build sdist
85
+ uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
86
+ with:
87
+ command: sdist
88
+ args: --out dist
89
+
90
+ - name: Upload sdist
91
+ uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
92
+ with:
93
+ name: maxminddb-rust-sdist
94
+ path: dist
95
+
96
+ upload_pypi:
97
+ name: Publish to PyPI
98
+ needs: [build_wheels, build_sdist]
99
+ runs-on: ubuntu-latest
100
+ if: github.event_name == 'release' && github.event.action == 'published'
101
+ environment: pypi
102
+ permissions:
103
+ id-token: write
104
+ steps:
105
+ - name: Download artifacts
106
+ uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
107
+ with:
108
+ pattern: maxminddb-rust-*
109
+ path: dist
110
+ merge-multiple: true
111
+
112
+ - name: Publish to PyPI
113
+ uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: Test
3
+
4
+ on:
5
+ push:
6
+ pull_request:
7
+ schedule:
8
+ - cron: "3 15 * * SUN"
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ test:
15
+ name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
21
+ os: [ubuntu-latest, macos-latest, windows-latest]
22
+
23
+ steps:
24
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
25
+ with:
26
+ persist-credentials: false
27
+ submodules: recursive
28
+
29
+ - name: Set up Python ${{ matrix.python-version }}
30
+ uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
31
+ with:
32
+ python-version: ${{ matrix.python-version }}
33
+
34
+ - name: Install Rust
35
+ uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # master
36
+ with:
37
+ toolchain: stable
38
+
39
+ - name: Install dependencies
40
+ run: |
41
+ python -m pip install --upgrade pip
42
+ pip install pytest
43
+
44
+ - name: Build and install extension
45
+ run: |
46
+ pip install maturin
47
+ maturin build --release
48
+ pip install --no-index --find-links target/wheels maxminddb-rust
49
+
50
+ - name: Run tests
51
+ run: pytest -v tests/
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: GitHub Actions Security Analysis with zizmor
3
+
4
+ on:
5
+ push:
6
+ branches: ["main"]
7
+ pull_request:
8
+ branches: ["**"]
9
+
10
+ permissions: {}
11
+
12
+ jobs:
13
+ zizmor:
14
+ name: zizmor
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ security-events: write
18
+ steps:
19
+ - name: Checkout repository
20
+ uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
21
+ with:
22
+ persist-credentials: false
23
+
24
+ - name: Run zizmor
25
+ uses: zizmorcore/zizmor-action@e673c3917a1aef3c65c972347ed84ccd013ecda4 # v0.2.0
@@ -0,0 +1,88 @@
1
+ # Rust
2
+ target/
3
+ Cargo.lock
4
+ **/*.rs.bk
5
+ *.pdb
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+ *.so
12
+ *.egg
13
+ *.egg-info/
14
+ dist/
15
+ build/
16
+ .eggs/
17
+ *.whl
18
+
19
+ # Virtual environments
20
+ .venv/
21
+ venv/
22
+ ENV/
23
+ env/
24
+
25
+ # UV cache
26
+ .uv-cache/
27
+
28
+ # Testing
29
+ .pytest_cache/
30
+ .coverage
31
+ htmlcov/
32
+ *.cover
33
+ .hypothesis/
34
+
35
+ # Profiling
36
+ *.pstats
37
+ perf.data
38
+ perf.data.old
39
+ *.svg
40
+ profile_*.json
41
+ profile_*.txt
42
+
43
+ # IDEs
44
+ .vscode/
45
+ .idea/
46
+ *.swp
47
+ *.swo
48
+ *~
49
+ .DS_Store
50
+
51
+ # PyCharm
52
+ .idea/
53
+
54
+ # VS Code
55
+ .vscode/
56
+
57
+ # Emacs
58
+ *~
59
+ \#*\#
60
+ .\#*
61
+
62
+ # Vim
63
+ *.swp
64
+ *.swo
65
+
66
+ # OS
67
+ .DS_Store
68
+ Thumbs.db
69
+
70
+ # Personal notes
71
+ todo.md
72
+ TODO.md
73
+ notes.md
74
+ NOTES.md
75
+
76
+ # Claude Code
77
+ .claude/
78
+
79
+ # Maturin
80
+ .cargo/
81
+
82
+ # PyO3
83
+ *.so
84
+
85
+ # Benchmarking outputs
86
+ *.json
87
+ *.svg
88
+ perf.data*
@@ -0,0 +1,3 @@
1
+ [submodule "tests/data"]
2
+ path = tests/data
3
+ url = https://github.com/maxmind/MaxMind-DB
@@ -0,0 +1,81 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.1] - 2025-11-08
9
+
10
+ - Attempt at republishing with tweaked workflow.
11
+ - Minor doc updates.
12
+
13
+ ## [0.1.0] - 2025-11-08
14
+
15
+ ### Added
16
+
17
+ - High-performance Rust-based Python module for MaxMind DB files
18
+ - 100% API compatibility with the official `maxminddb` Python package
19
+ - `Reader` class with `get()`, `get_with_prefix_len()`, `metadata()`, and `close()` methods
20
+ - `open_database()` function
21
+ - Context manager support (`with` statement)
22
+ - MODE\_\* constants (MODE_AUTO, MODE_MMAP, MODE_MMAP_EXT, MODE_MEMORY)
23
+ - `InvalidDatabaseError` exception
24
+ - `Metadata` class with all attributes and computed properties
25
+ - Support for string IP addresses and `ipaddress.IPv4Address`/`IPv6Address` objects
26
+ - `closed` attribute
27
+ - Iterator support for iterating over all database records
28
+ - Extension method `get_many()` for efficient batch IP lookups (not in official package)
29
+ - Comprehensive Python API docstrings for all public methods and classes
30
+ - Type stub file (`maxminddb_rust.pyi`) for IDE autocomplete and type checking support
31
+ - `py.typed` marker file for PEP 561 compliance
32
+ - Example scripts demonstrating common usage patterns:
33
+ - basic_usage.py: Simple lookups and database lifecycle
34
+ - context_manager.py: Using 'with' statement patterns
35
+ - iterator_demo.py: Iterating over all database networks
36
+ - batch_processing.py: High-performance batch lookups with get_many()
37
+ - Migration guide (MIGRATION.md) for users switching from the official maxminddb package
38
+ - Comprehensive test suite with upstream compatibility tests from MaxMind
39
+ - This CHANGELOG file
40
+
41
+ ### Performance
42
+
43
+ - 45% faster average performance: 373K lookups/second vs official package
44
+ - GeoLite2-Country: 493K lookups/sec
45
+ - GeoLite2-City: 319K lookups/sec
46
+ - GeoIP2-City: 308K lookups/sec
47
+ - Memory-mapped file I/O for optimal performance
48
+ - GIL release during lookups for better concurrency
49
+ - Thin LTO and aggressive compiler optimizations
50
+ - Zero-copy operations where possible
51
+ - Optimized Python object deserialization with reduced allocations
52
+ - Reduced reader lock contention with RwLock
53
+ - Batch processing support with `get_many()`
54
+
55
+ ### Supported Modes
56
+
57
+ - MODE_AUTO: Automatically choose the best mode (uses MODE_MMAP)
58
+ - MODE_MMAP: Memory-mapped file I/O (default, best performance)
59
+ - MODE_MMAP_EXT: Same as MODE_MMAP
60
+ - MODE_MEMORY: Load entire database into memory
61
+
62
+ ### Not Yet Implemented
63
+
64
+ - MODE_FILE: Read database as standard file
65
+ - MODE_FD: Load from file descriptor
66
+
67
+ ### Dependencies
68
+
69
+ - PyO3 0.27.1: Python bindings for Rust
70
+ - maxminddb 0.26.0: MaxMind DB file format reader
71
+ - memmap2 0.9: Memory mapping
72
+ - ipnetwork 0.21: IP network types
73
+ - serde 1.0: Serialization framework
74
+
75
+ ### Python Support
76
+
77
+ - Python 3.8+
78
+ - CPython implementation
79
+
80
+ [Unreleased]: https://github.com/oschwald/maxminddb-rust-python/compare/v0.1.0...HEAD
81
+ [0.1.0]: https://github.com/oschwald/maxminddb-rust-python/releases/tag/v0.1.0