rgapi 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.
@@ -0,0 +1,62 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ['v*']
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - run: cargo test
15
+
16
+ build:
17
+ needs: test
18
+ strategy:
19
+ matrix:
20
+ os: [ubuntu-latest, macos-latest]
21
+ python: ['3.10', '3.11', '3.12', '3.13']
22
+ runs-on: ${{ matrix.os }}
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: dtolnay/rust-toolchain@stable
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: ${{ matrix.python }}
29
+ - run: tools/build.sh release
30
+ - uses: PyO3/maturin-action@v1
31
+ with:
32
+ command: build
33
+ args: --release -o dist
34
+ - uses: actions/upload-artifact@v4
35
+ with:
36
+ name: wheel-${{ matrix.os }}-py${{ matrix.python }}
37
+ path: dist/*.whl
38
+
39
+ publish:
40
+ if: startsWith(github.ref, 'refs/tags/v')
41
+ needs: build
42
+ runs-on: ubuntu-latest
43
+ permissions:
44
+ id-token: write
45
+ contents: write
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: PyO3/maturin-action@v1
49
+ with:
50
+ command: sdist
51
+ args: -o dist
52
+ - uses: actions/download-artifact@v4
53
+ with:
54
+ path: dist
55
+ merge-multiple: true
56
+ - uses: softprops/action-gh-release@v2
57
+ with:
58
+ files: dist/*
59
+ generate_release_notes: true
60
+ - uses: pypa/gh-action-pypi-publish@release/v1
61
+ with:
62
+ packages-dir: dist/
rgapi-0.1.0/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ Cargo.lock
2
+ tags
3
+ /target/
4
+ /.pytest_cache/
5
+ /.mypy_cache/
6
+ /.ruff_cache/
7
+ __pycache__/
8
+ *.egg-info/
9
+ *.so
10
+ /meta/
11
+ .DS_Store
rgapi-0.1.0/Cargo.lock ADDED
@@ -0,0 +1,424 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "1.1.4"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "autocfg"
16
+ version = "1.5.1"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
19
+
20
+ [[package]]
21
+ name = "bstr"
22
+ version = "1.12.1"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab"
25
+ dependencies = [
26
+ "memchr",
27
+ "regex-automata",
28
+ "serde",
29
+ ]
30
+
31
+ [[package]]
32
+ name = "cfg-if"
33
+ version = "1.0.4"
34
+ source = "registry+https://github.com/rust-lang/crates.io-index"
35
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
36
+
37
+ [[package]]
38
+ name = "crossbeam-deque"
39
+ version = "0.8.6"
40
+ source = "registry+https://github.com/rust-lang/crates.io-index"
41
+ checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
42
+ dependencies = [
43
+ "crossbeam-epoch",
44
+ "crossbeam-utils",
45
+ ]
46
+
47
+ [[package]]
48
+ name = "crossbeam-epoch"
49
+ version = "0.9.18"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
52
+ dependencies = [
53
+ "crossbeam-utils",
54
+ ]
55
+
56
+ [[package]]
57
+ name = "crossbeam-utils"
58
+ version = "0.8.21"
59
+ source = "registry+https://github.com/rust-lang/crates.io-index"
60
+ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
61
+
62
+ [[package]]
63
+ name = "encoding_rs"
64
+ version = "0.8.35"
65
+ source = "registry+https://github.com/rust-lang/crates.io-index"
66
+ checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
67
+ dependencies = [
68
+ "cfg-if",
69
+ ]
70
+
71
+ [[package]]
72
+ name = "encoding_rs_io"
73
+ version = "0.1.7"
74
+ source = "registry+https://github.com/rust-lang/crates.io-index"
75
+ checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83"
76
+ dependencies = [
77
+ "encoding_rs",
78
+ ]
79
+
80
+ [[package]]
81
+ name = "globset"
82
+ version = "0.4.18"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3"
85
+ dependencies = [
86
+ "aho-corasick",
87
+ "bstr",
88
+ "log",
89
+ "regex-automata",
90
+ "regex-syntax",
91
+ ]
92
+
93
+ [[package]]
94
+ name = "grep-matcher"
95
+ version = "0.1.8"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "36d7b71093325ab22d780b40d7df3066ae4aebb518ba719d38c697a8228a8023"
98
+ dependencies = [
99
+ "memchr",
100
+ ]
101
+
102
+ [[package]]
103
+ name = "grep-regex"
104
+ version = "0.1.14"
105
+ source = "registry+https://github.com/rust-lang/crates.io-index"
106
+ checksum = "0ce0c256c3ad82bcc07b812c15a45ec1d398122e8e15124f96695234db7112ef"
107
+ dependencies = [
108
+ "bstr",
109
+ "grep-matcher",
110
+ "log",
111
+ "regex-automata",
112
+ "regex-syntax",
113
+ ]
114
+
115
+ [[package]]
116
+ name = "grep-searcher"
117
+ version = "0.1.16"
118
+ source = "registry+https://github.com/rust-lang/crates.io-index"
119
+ checksum = "ac63295322dc48ebb20a25348147905d816318888e64f531bfc2a2bc0577dc34"
120
+ dependencies = [
121
+ "bstr",
122
+ "encoding_rs",
123
+ "encoding_rs_io",
124
+ "grep-matcher",
125
+ "log",
126
+ "memchr",
127
+ "memmap2",
128
+ ]
129
+
130
+ [[package]]
131
+ name = "heck"
132
+ version = "0.5.0"
133
+ source = "registry+https://github.com/rust-lang/crates.io-index"
134
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
135
+
136
+ [[package]]
137
+ name = "ignore"
138
+ version = "0.4.26"
139
+ source = "registry+https://github.com/rust-lang/crates.io-index"
140
+ checksum = "b915661dd01db3f05050265b2477bcc6527b3792388e2749b41623cc592be67d"
141
+ dependencies = [
142
+ "crossbeam-deque",
143
+ "globset",
144
+ "log",
145
+ "memchr",
146
+ "regex-automata",
147
+ "same-file",
148
+ "walkdir",
149
+ "winapi-util",
150
+ ]
151
+
152
+ [[package]]
153
+ name = "indoc"
154
+ version = "2.0.7"
155
+ source = "registry+https://github.com/rust-lang/crates.io-index"
156
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
157
+ dependencies = [
158
+ "rustversion",
159
+ ]
160
+
161
+ [[package]]
162
+ name = "libc"
163
+ version = "0.2.186"
164
+ source = "registry+https://github.com/rust-lang/crates.io-index"
165
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
166
+
167
+ [[package]]
168
+ name = "log"
169
+ version = "0.4.32"
170
+ source = "registry+https://github.com/rust-lang/crates.io-index"
171
+ checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"
172
+
173
+ [[package]]
174
+ name = "memchr"
175
+ version = "2.8.2"
176
+ source = "registry+https://github.com/rust-lang/crates.io-index"
177
+ checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4"
178
+
179
+ [[package]]
180
+ name = "memmap2"
181
+ version = "0.9.10"
182
+ source = "registry+https://github.com/rust-lang/crates.io-index"
183
+ checksum = "714098028fe011992e1c3962653c96b2d578c4b4bce9036e15ff220319b1e0e3"
184
+ dependencies = [
185
+ "libc",
186
+ ]
187
+
188
+ [[package]]
189
+ name = "memoffset"
190
+ version = "0.9.1"
191
+ source = "registry+https://github.com/rust-lang/crates.io-index"
192
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
193
+ dependencies = [
194
+ "autocfg",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "once_cell"
199
+ version = "1.21.4"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
202
+
203
+ [[package]]
204
+ name = "portable-atomic"
205
+ version = "1.13.1"
206
+ source = "registry+https://github.com/rust-lang/crates.io-index"
207
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
208
+
209
+ [[package]]
210
+ name = "proc-macro2"
211
+ version = "1.0.106"
212
+ source = "registry+https://github.com/rust-lang/crates.io-index"
213
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
214
+ dependencies = [
215
+ "unicode-ident",
216
+ ]
217
+
218
+ [[package]]
219
+ name = "pyo3"
220
+ version = "0.23.5"
221
+ source = "registry+https://github.com/rust-lang/crates.io-index"
222
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
223
+ dependencies = [
224
+ "cfg-if",
225
+ "indoc",
226
+ "libc",
227
+ "memoffset",
228
+ "once_cell",
229
+ "portable-atomic",
230
+ "pyo3-build-config",
231
+ "pyo3-ffi",
232
+ "pyo3-macros",
233
+ "unindent",
234
+ ]
235
+
236
+ [[package]]
237
+ name = "pyo3-build-config"
238
+ version = "0.23.5"
239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
240
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
241
+ dependencies = [
242
+ "once_cell",
243
+ "target-lexicon",
244
+ ]
245
+
246
+ [[package]]
247
+ name = "pyo3-ffi"
248
+ version = "0.23.5"
249
+ source = "registry+https://github.com/rust-lang/crates.io-index"
250
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
251
+ dependencies = [
252
+ "libc",
253
+ "pyo3-build-config",
254
+ ]
255
+
256
+ [[package]]
257
+ name = "pyo3-macros"
258
+ version = "0.23.5"
259
+ source = "registry+https://github.com/rust-lang/crates.io-index"
260
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
261
+ dependencies = [
262
+ "proc-macro2",
263
+ "pyo3-macros-backend",
264
+ "quote",
265
+ "syn",
266
+ ]
267
+
268
+ [[package]]
269
+ name = "pyo3-macros-backend"
270
+ version = "0.23.5"
271
+ source = "registry+https://github.com/rust-lang/crates.io-index"
272
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
273
+ dependencies = [
274
+ "heck",
275
+ "proc-macro2",
276
+ "pyo3-build-config",
277
+ "quote",
278
+ "syn",
279
+ ]
280
+
281
+ [[package]]
282
+ name = "quote"
283
+ version = "1.0.45"
284
+ source = "registry+https://github.com/rust-lang/crates.io-index"
285
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
286
+ dependencies = [
287
+ "proc-macro2",
288
+ ]
289
+
290
+ [[package]]
291
+ name = "regex-automata"
292
+ version = "0.4.14"
293
+ source = "registry+https://github.com/rust-lang/crates.io-index"
294
+ checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
295
+ dependencies = [
296
+ "aho-corasick",
297
+ "memchr",
298
+ "regex-syntax",
299
+ ]
300
+
301
+ [[package]]
302
+ name = "regex-syntax"
303
+ version = "0.8.11"
304
+ source = "registry+https://github.com/rust-lang/crates.io-index"
305
+ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
306
+
307
+ [[package]]
308
+ name = "rgapi"
309
+ version = "0.1.0"
310
+ dependencies = [
311
+ "globset",
312
+ "grep-matcher",
313
+ "grep-regex",
314
+ "grep-searcher",
315
+ "ignore",
316
+ "pyo3",
317
+ ]
318
+
319
+ [[package]]
320
+ name = "rustversion"
321
+ version = "1.0.22"
322
+ source = "registry+https://github.com/rust-lang/crates.io-index"
323
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
324
+
325
+ [[package]]
326
+ name = "same-file"
327
+ version = "1.0.6"
328
+ source = "registry+https://github.com/rust-lang/crates.io-index"
329
+ checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
330
+ dependencies = [
331
+ "winapi-util",
332
+ ]
333
+
334
+ [[package]]
335
+ name = "serde"
336
+ version = "1.0.228"
337
+ source = "registry+https://github.com/rust-lang/crates.io-index"
338
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
339
+ dependencies = [
340
+ "serde_core",
341
+ ]
342
+
343
+ [[package]]
344
+ name = "serde_core"
345
+ version = "1.0.228"
346
+ source = "registry+https://github.com/rust-lang/crates.io-index"
347
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
348
+ dependencies = [
349
+ "serde_derive",
350
+ ]
351
+
352
+ [[package]]
353
+ name = "serde_derive"
354
+ version = "1.0.228"
355
+ source = "registry+https://github.com/rust-lang/crates.io-index"
356
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
357
+ dependencies = [
358
+ "proc-macro2",
359
+ "quote",
360
+ "syn",
361
+ ]
362
+
363
+ [[package]]
364
+ name = "syn"
365
+ version = "2.0.118"
366
+ source = "registry+https://github.com/rust-lang/crates.io-index"
367
+ checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
368
+ dependencies = [
369
+ "proc-macro2",
370
+ "quote",
371
+ "unicode-ident",
372
+ ]
373
+
374
+ [[package]]
375
+ name = "target-lexicon"
376
+ version = "0.12.16"
377
+ source = "registry+https://github.com/rust-lang/crates.io-index"
378
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
379
+
380
+ [[package]]
381
+ name = "unicode-ident"
382
+ version = "1.0.24"
383
+ source = "registry+https://github.com/rust-lang/crates.io-index"
384
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
385
+
386
+ [[package]]
387
+ name = "unindent"
388
+ version = "0.2.4"
389
+ source = "registry+https://github.com/rust-lang/crates.io-index"
390
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
391
+
392
+ [[package]]
393
+ name = "walkdir"
394
+ version = "2.5.0"
395
+ source = "registry+https://github.com/rust-lang/crates.io-index"
396
+ checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
397
+ dependencies = [
398
+ "same-file",
399
+ "winapi-util",
400
+ ]
401
+
402
+ [[package]]
403
+ name = "winapi-util"
404
+ version = "0.1.11"
405
+ source = "registry+https://github.com/rust-lang/crates.io-index"
406
+ checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
407
+ dependencies = [
408
+ "windows-sys",
409
+ ]
410
+
411
+ [[package]]
412
+ name = "windows-link"
413
+ version = "0.2.1"
414
+ source = "registry+https://github.com/rust-lang/crates.io-index"
415
+ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
416
+
417
+ [[package]]
418
+ name = "windows-sys"
419
+ version = "0.61.2"
420
+ source = "registry+https://github.com/rust-lang/crates.io-index"
421
+ checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
422
+ dependencies = [
423
+ "windows-link",
424
+ ]
rgapi-0.1.0/Cargo.toml ADDED
@@ -0,0 +1,26 @@
1
+ [package]
2
+ name = "rgapi"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ license = "MIT OR Apache-2.0"
6
+ description = "Python API for ripgrep-style file walking and searching"
7
+ repository = "https://github.com/AnswerDotAI/rgapi"
8
+ homepage = "https://github.com/AnswerDotAI/rgapi"
9
+ documentation = "https://github.com/AnswerDotAI/rgapi"
10
+ readme = "README.md"
11
+
12
+ [lib]
13
+ name = "rgapi"
14
+ crate-type = ["cdylib", "rlib"]
15
+
16
+ [dependencies]
17
+ globset = "0.4.18"
18
+ grep-matcher = "0.1.8"
19
+ grep-regex = "0.1.14"
20
+ grep-searcher = "0.1.16"
21
+ ignore = "0.4.26"
22
+ pyo3 = { version = "0.23", optional = true }
23
+
24
+ [features]
25
+ extension-module = ["pyo3", "pyo3/extension-module"]
26
+ pyo3 = ["dep:pyo3"]
rgapi-0.1.0/DEV.md ADDED
@@ -0,0 +1,36 @@
1
+ # Development
2
+
3
+ `rgapi` is a PyO3/maturin package. The Rust crate contains the core implementation; `python/rgapi/__init__.py` is the public Python API over the private `rgapi._core` extension module.
4
+
5
+ ## Layout
6
+
7
+ ```text
8
+ src/walk.rs ignore/globset/grep-regex-backed path walking and filtering
9
+ src/search.rs grep-regex/grep-searcher-backed searching
10
+ src/python.rs PyO3 classes and private core functions
11
+ python/rgapi/ public Python wrappers over `rgapi._core`
12
+ tests/ pytest coverage for the Python API
13
+ ```
14
+
15
+ The public Python API lives in `python/rgapi/__init__.py`. The extension module is private as `rgapi._core`; keep crate-like functions there and put Python-facing argument policy in the wrapper when that stays concise. For example, `glob=` and `ext=` are Python wrapper conveniences over the core include glob list.
16
+
17
+ ## Commands
18
+
19
+ ```bash
20
+ cargo fmt --check
21
+ cargo check
22
+ maturin develop
23
+ pytest -q
24
+ ```
25
+
26
+ Run `cargo test` for Rust unit tests. Run `chkstyle` after Python edits once tests pass.
27
+
28
+ ## Release
29
+
30
+ Release plumbing mirrors exhash. `tools/bump.sh` bumps the patch version in `pyproject.toml` and `Cargo.toml`; `tools/bump2.sh` bumps the minor version; `tools/release.sh` tags the current version and pushes `main` plus tags. The GitHub workflow builds wheels for Python 3.10-3.13 on Linux and macOS and publishes artifacts to GitHub Releases and PyPI when a `v*` tag is pushed.
31
+
32
+ ## Design notes
33
+
34
+ Paths in `fd`, `walk`, `rg`, and `rg_iter` results are relative to the requested root and use `/` separators. Traversal uses `ignore::WalkParallel`, so result order is not part of the API contract. Search results are structured rows; collected result lists use rg-style `str()` and notebook display. Path regexes filter returned/searched paths; `skip_dir` and `skip_dir_re` prune traversal through `ignore::WalkBuilder::filter_entry`. Depth, size, symlink, filesystem, hidden, and ignore options are direct `ignore::WalkBuilder` settings. `rg_iter` exposes the same parallel search stream that `rg` collects by default; `paths=True` and `count=True` consume that stream with different reducers. Binary files and invalid UTF-8 are skipped for now.
35
+
36
+ This package intentionally has no CLI. Python is the interface.
rgapi-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: rgapi
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Summary: Python API for ripgrep-style file walking and searching
7
+ Home-Page: https://github.com/AnswerDotAI/rgapi
8
+ Author-email: Jeremy Howard <j@fast.ai>
9
+ License: MIT OR Apache-2.0
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
+ Project-URL: Homepage, https://github.com/AnswerDotAI/rgapi
13
+ Project-URL: Issues, https://github.com/AnswerDotAI/rgapi/issues
14
+ Project-URL: Repository, https://github.com/AnswerDotAI/rgapi
15
+
16
+ # rgapi
17
+
18
+ `rgapi` is a Python API for ripgrep-style walking and search. It is meant for Python code that wants `fd`-style file discovery or `rg`-style searching without shelling out.
19
+
20
+ It uses the same `ignore`, `grep-regex`, and `grep-searcher` crates that ripgrep uses for walking, regex matching, and file scanning. Walking and searching run in parallel by default. Most expensive work stays in Rust.
21
+
22
+ ## Overview
23
+
24
+ For common file discovery and search:
25
+
26
+ ```python
27
+ from rgapi import fd, rg, rg_iter
28
+
29
+ fd(".", ext="py", exclude="test_*.py")
30
+ for row in rg_iter("TODO", ".", include="*.py", context=2): print(row.asdict())
31
+ rg("TODO", ".", ext="py", skip_dir=".venv", paths=True)
32
+ ```
33
+
34
+ For direct access to the regex, search, and walk pieces:
35
+
36
+ ```python
37
+ from rgapi import compile, search_path, search_text, walk
38
+
39
+ matcher = compile("TODO")
40
+ matcher.is_match("TODO")
41
+ matcher.finditer("TODO TODO")
42
+
43
+ walk(".")
44
+ search_text(matcher, "alpha\nTODO\nomega\n", path="memory.txt", context=1)
45
+ search_path(matcher, "src/lib.rs", display_path="src/lib.rs")
46
+ ```
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install rgapi
52
+ ```
53
+
54
+ ## Semantics
55
+
56
+ `fd` and `walk` return slash-separated paths relative to `root`. They use the `ignore` crate, so `.gitignore` and the usual ripgrep filters apply by default. Hidden files are skipped unless `hidden=True`. Pass `ignore=False` to disable ignore filtering. Symlinks are not followed unless `follow_links=True`; `same_file_system=True` avoids crossing filesystem boundaries. Traversal is parallel, and result order is not guaranteed; use `sorted(...)` if order matters.
57
+
58
+ `fd` adds fd-like filtering on top of `walk`: `pattern` is a substring match on the relative path, and `include`/`exclude` use glob syntax. `glob=` is accepted as an alias for `include=`. A basename glob such as `*.py` also matches recursively, so it finds `src/app.py`. Use `ext="py"` or `ext=["py", "rs"]` for extension filters, `min_depth=`/`max_depth=` to bound recursion, and `max_filesize=` to skip files above a byte limit.
59
+
60
+ `path_re` and `skip_path_re` are regex filters on slash-separated relative paths. They filter returned paths or searched files, but do not control traversal. `skip_dir` uses glob syntax to prune matching directory subtrees, and `skip_dir_re` does the same with regex.
61
+
62
+ `rg` and `rg_iter` return structured rows rather than raw CLI text. They accept the same `include`, `exclude`, `glob`, `ext`, `path_re`, `skip_path_re`, `skip_dir`, `skip_dir_re`, `min_depth`, `max_depth`, `max_filesize`, `follow_links`, and `same_file_system` filters as `fd`. Each row is a `SearchLine` with:
63
+
64
+ ```text
65
+ kind 'match', 'before', 'after', or 'context'
66
+ path path relative to root
67
+ line_number 1-based line number
68
+ line line text without the trailing newline
69
+ matches list of (start, end) byte offsets for match rows
70
+ ```
71
+
72
+ `rg`, `search_text`, and `search_path` return `SearchResults` by default, a list subclass whose `str()` and notebook pretty display are rg-style multiline text. `rg_iter` yields rows lazily.
73
+
74
+ `SearchLine` has a structured `repr`, an rg-style `str`, and `SearchLine.asdict()` returns row fields as a plain Python dict. `rg(..., paths=True)` returns unique matched paths, and `rg(..., count=True)` returns the total number of match spans. `paths` and `count` cannot both be set.
75
+
76
+ `before_context`, `after_context`, and `context` match the shape of `rg -B`, `rg -A`, and `rg -C`. Files containing NUL bytes or invalid UTF-8 are skipped.
77
+
78
+ Search is case-sensitive by default, matching `rg`. Use `smart_case=True` for `rg --smart-case` behavior, or `case_sensitive=False` to force case-insensitive matching.
79
+
80
+ ## Benchmarks
81
+
82
+ `tools/bench.py` compares the `rg` CLI with in-process `rgapi`. Run it against a release build. One run on this machine, using best time from seven repeats:
83
+
84
+ | fixture | rg | rgapi |
85
+ | --- | ---: | ---: |
86
+ | 6 x 2 MB files, 2 matches | 6.54 ms | 1.44 ms |
87
+ | 800 x 1.5 KB files, 2 matches | 13.90 ms | 10.94 ms |
88
+ | tiny dir, repeated 30x | 5.92 ms | 2.14 ms |
89
+
90
+