rgapi 0.1.30__tar.gz → 0.2.1__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.
- {rgapi-0.1.30 → rgapi-0.2.1}/.github/workflows/ci.yml +3 -2
- {rgapi-0.1.30 → rgapi-0.2.1}/Cargo.lock +26 -38
- {rgapi-0.1.30 → rgapi-0.2.1}/Cargo.toml +24 -11
- {rgapi-0.1.30 → rgapi-0.2.1}/DEV.md +10 -10
- {rgapi-0.1.30 → rgapi-0.2.1}/PKG-INFO +8 -4
- {rgapi-0.1.30 → rgapi-0.2.1}/README.md +6 -2
- rgapi-0.2.1/py/Cargo.toml +18 -0
- rgapi-0.2.1/py/build.rs +1 -0
- rgapi-0.1.30/src/python.rs → rgapi-0.2.1/py/src/lib.rs +67 -735
- {rgapi-0.1.30 → rgapi-0.2.1}/pyproject.toml +3 -3
- {rgapi-0.1.30 → rgapi-0.2.1}/python/rgapi/__init__.py +66 -53
- {rgapi-0.1.30 → rgapi-0.2.1}/python/rgapi/_cli.py +3 -3
- {rgapi-0.1.30 → rgapi-0.2.1}/python/rgapi/block.py +6 -1
- {rgapi-0.1.30 → rgapi-0.2.1}/python/rgapi/nb.py +26 -20
- rgapi-0.2.1/python/rgapi/skill.py +19 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/src/block.rs +10 -28
- {rgapi-0.1.30 → rgapi-0.2.1}/src/lib.rs +2 -5
- {rgapi-0.1.30 → rgapi-0.2.1}/src/nb.rs +20 -53
- {rgapi-0.1.30 → rgapi-0.2.1}/src/search.rs +26 -90
- {rgapi-0.1.30 → rgapi-0.2.1}/src/walk.rs +147 -144
- {rgapi-0.1.30 → rgapi-0.2.1}/tests/test_rgapi.py +25 -0
- rgapi-0.1.30/python/rgapi/skill.py +0 -37
- {rgapi-0.1.30 → rgapi-0.2.1}/.gitignore +0 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/LICENSE +0 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/_config.yml +0 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/_layouts/default.html +0 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/rustfmt.toml +0 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/tests/test_async.py +0 -0
- {rgapi-0.1.30 → rgapi-0.2.1}/tools/bench.py +0 -0
|
@@ -12,11 +12,12 @@ jobs:
|
|
|
12
12
|
steps:
|
|
13
13
|
- uses: actions/checkout@v7
|
|
14
14
|
- uses: dtolnay/rust-toolchain@stable
|
|
15
|
-
- run: cargo test
|
|
16
15
|
- uses: actions/setup-python@v7
|
|
17
16
|
with:
|
|
18
17
|
python-version: '3.12'
|
|
18
|
+
- run: cargo test
|
|
19
19
|
- run: pip install -e '.[dev]'
|
|
20
|
+
- run: cargo develop
|
|
20
21
|
- run: pytest -q
|
|
21
22
|
|
|
22
23
|
build:
|
|
@@ -61,7 +62,7 @@ jobs:
|
|
|
61
62
|
- uses: dtolnay/rust-toolchain@stable
|
|
62
63
|
- id: crates-auth
|
|
63
64
|
uses: rust-lang/crates-io-auth-action@v1
|
|
64
|
-
- run: cargo publish
|
|
65
|
+
- run: cargo publish -p rgapi
|
|
65
66
|
env:
|
|
66
67
|
CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }}
|
|
67
68
|
- uses: actions/download-artifact@v8
|
|
@@ -70,13 +70,12 @@ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
|
70
70
|
|
|
71
71
|
[[package]]
|
|
72
72
|
name = "encoding_rs"
|
|
73
|
-
version = "0.8.
|
|
73
|
+
version = "0.8.42"
|
|
74
74
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
75
|
-
checksum = "
|
|
75
|
+
checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"
|
|
76
76
|
dependencies = [
|
|
77
77
|
"cfg-if",
|
|
78
78
|
"core_detect",
|
|
79
|
-
"multiversion",
|
|
80
79
|
"multiversion_no_op",
|
|
81
80
|
"rustversion",
|
|
82
81
|
"scopeguard",
|
|
@@ -172,9 +171,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
|
172
171
|
|
|
173
172
|
[[package]]
|
|
174
173
|
name = "libc"
|
|
175
|
-
version = "0.2.
|
|
174
|
+
version = "0.2.190"
|
|
176
175
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
177
|
-
checksum = "
|
|
176
|
+
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
|
178
177
|
|
|
179
178
|
[[package]]
|
|
180
179
|
name = "log"
|
|
@@ -197,27 +196,6 @@ dependencies = [
|
|
|
197
196
|
"libc",
|
|
198
197
|
]
|
|
199
198
|
|
|
200
|
-
[[package]]
|
|
201
|
-
name = "multiversion"
|
|
202
|
-
version = "0.9.0"
|
|
203
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
-
checksum = "b4ca4bea16ffc3f443cf7d866912118196bfef4c6a1556ca00f9f9b00bb43f7c"
|
|
205
|
-
dependencies = [
|
|
206
|
-
"multiversion-macros",
|
|
207
|
-
]
|
|
208
|
-
|
|
209
|
-
[[package]]
|
|
210
|
-
name = "multiversion-macros"
|
|
211
|
-
version = "0.9.0"
|
|
212
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
213
|
-
checksum = "0d416831a7317ef4b08bee00b69cbbb9c8763da7959a7026244d6266869f9c83"
|
|
214
|
-
dependencies = [
|
|
215
|
-
"proc-macro2",
|
|
216
|
-
"quote",
|
|
217
|
-
"rustversion",
|
|
218
|
-
"syn 3.0.6",
|
|
219
|
-
]
|
|
220
|
-
|
|
221
199
|
[[package]]
|
|
222
200
|
name = "multiversion_no_op"
|
|
223
201
|
version = "1.0.0"
|
|
@@ -247,9 +225,9 @@ dependencies = [
|
|
|
247
225
|
|
|
248
226
|
[[package]]
|
|
249
227
|
name = "pyo3"
|
|
250
|
-
version = "0.29.
|
|
228
|
+
version = "0.29.3"
|
|
251
229
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
252
|
-
checksum = "
|
|
230
|
+
checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
|
|
253
231
|
dependencies = [
|
|
254
232
|
"libc",
|
|
255
233
|
"once_cell",
|
|
@@ -261,18 +239,18 @@ dependencies = [
|
|
|
261
239
|
|
|
262
240
|
[[package]]
|
|
263
241
|
name = "pyo3-build-config"
|
|
264
|
-
version = "0.29.
|
|
242
|
+
version = "0.29.3"
|
|
265
243
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
266
|
-
checksum = "
|
|
244
|
+
checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
|
|
267
245
|
dependencies = [
|
|
268
246
|
"target-lexicon",
|
|
269
247
|
]
|
|
270
248
|
|
|
271
249
|
[[package]]
|
|
272
250
|
name = "pyo3-ffi"
|
|
273
|
-
version = "0.29.
|
|
251
|
+
version = "0.29.3"
|
|
274
252
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
275
|
-
checksum = "
|
|
253
|
+
checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
|
|
276
254
|
dependencies = [
|
|
277
255
|
"libc",
|
|
278
256
|
"pyo3-build-config",
|
|
@@ -280,9 +258,9 @@ dependencies = [
|
|
|
280
258
|
|
|
281
259
|
[[package]]
|
|
282
260
|
name = "pyo3-macros"
|
|
283
|
-
version = "0.29.
|
|
261
|
+
version = "0.29.3"
|
|
284
262
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
285
|
-
checksum = "
|
|
263
|
+
checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
|
|
286
264
|
dependencies = [
|
|
287
265
|
"proc-macro2",
|
|
288
266
|
"pyo3-macros-backend",
|
|
@@ -292,9 +270,9 @@ dependencies = [
|
|
|
292
270
|
|
|
293
271
|
[[package]]
|
|
294
272
|
name = "pyo3-macros-backend"
|
|
295
|
-
version = "0.29.
|
|
273
|
+
version = "0.29.3"
|
|
296
274
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
297
|
-
checksum = "
|
|
275
|
+
checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
|
|
298
276
|
dependencies = [
|
|
299
277
|
"heck",
|
|
300
278
|
"proc-macro2",
|
|
@@ -330,7 +308,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
|
330
308
|
|
|
331
309
|
[[package]]
|
|
332
310
|
name = "rgapi"
|
|
333
|
-
version = "0.1
|
|
311
|
+
version = "0.2.1"
|
|
334
312
|
dependencies = [
|
|
335
313
|
"crc32fast",
|
|
336
314
|
"globset",
|
|
@@ -338,11 +316,21 @@ dependencies = [
|
|
|
338
316
|
"grep-regex",
|
|
339
317
|
"grep-searcher",
|
|
340
318
|
"ignore",
|
|
341
|
-
"pyo3",
|
|
342
319
|
"serde",
|
|
343
320
|
"serde_json",
|
|
344
321
|
]
|
|
345
322
|
|
|
323
|
+
[[package]]
|
|
324
|
+
name = "rgapi-py"
|
|
325
|
+
version = "0.2.1"
|
|
326
|
+
dependencies = [
|
|
327
|
+
"grep-matcher",
|
|
328
|
+
"grep-regex",
|
|
329
|
+
"pyo3",
|
|
330
|
+
"pyo3-build-config",
|
|
331
|
+
"rgapi",
|
|
332
|
+
]
|
|
333
|
+
|
|
346
334
|
[[package]]
|
|
347
335
|
name = "rustversion"
|
|
348
336
|
version = "1.0.23"
|
|
@@ -1,37 +1,44 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
members = ["py"]
|
|
3
|
+
|
|
4
|
+
[workspace.package]
|
|
5
|
+
version = "0.2.1"
|
|
6
|
+
edition = "2024"
|
|
7
|
+
|
|
8
|
+
[workspace.dependencies]
|
|
9
|
+
grep-matcher = ">=0.1.8"
|
|
10
|
+
grep-regex = ">=0.1.14"
|
|
11
|
+
|
|
1
12
|
[package]
|
|
2
13
|
name = "rgapi"
|
|
3
|
-
version =
|
|
4
|
-
edition =
|
|
14
|
+
version.workspace = true
|
|
15
|
+
edition.workspace = true
|
|
5
16
|
rust-version = "1.91"
|
|
6
17
|
license = "Apache-2.0"
|
|
7
18
|
description = "Python API for ripgrep-style file walking and searching"
|
|
8
19
|
repository = "https://github.com/AnswerDotAI/rgapi"
|
|
9
20
|
homepage = "https://github.com/AnswerDotAI/rgapi"
|
|
10
21
|
documentation = "https://github.com/AnswerDotAI/rgapi"
|
|
11
|
-
readme = "README.md"
|
|
12
22
|
|
|
13
23
|
[lib]
|
|
14
24
|
name = "rgapi"
|
|
15
|
-
crate-type = ["cdylib", "rlib"]
|
|
16
25
|
|
|
17
26
|
[dependencies]
|
|
18
27
|
crc32fast = "1"
|
|
19
28
|
globset = ">=0.4.18"
|
|
20
|
-
grep-matcher =
|
|
21
|
-
grep-regex =
|
|
29
|
+
grep-matcher.workspace = true
|
|
30
|
+
grep-regex.workspace = true
|
|
22
31
|
grep-searcher = ">=0.1.16"
|
|
23
32
|
ignore = ">=0.4.26"
|
|
24
|
-
pyo3 = { version = ">=0.28", optional = true }
|
|
25
33
|
serde = { version = "=1", features = ["derive"] }
|
|
26
34
|
serde_json = "=1"
|
|
27
35
|
|
|
28
|
-
[features]
|
|
29
|
-
python = ["dep:pyo3"]
|
|
30
|
-
extension-module = ["python", "pyo3/extension-module"]
|
|
31
|
-
|
|
32
36
|
[lints.clippy]
|
|
33
37
|
too_many_arguments = "allow"
|
|
34
38
|
|
|
39
|
+
[profile.test]
|
|
40
|
+
inherits = "release"
|
|
41
|
+
|
|
35
42
|
[profile.release]
|
|
36
43
|
lto = false
|
|
37
44
|
codegen-units = 16
|
|
@@ -39,6 +46,9 @@ codegen-units = 16
|
|
|
39
46
|
[profile.release.package.rgapi]
|
|
40
47
|
incremental = true
|
|
41
48
|
|
|
49
|
+
[profile.release.package.rgapi-py]
|
|
50
|
+
incremental = true
|
|
51
|
+
|
|
42
52
|
[profile.dist]
|
|
43
53
|
inherits = "release"
|
|
44
54
|
lto = true
|
|
@@ -48,3 +58,6 @@ strip = true
|
|
|
48
58
|
|
|
49
59
|
[profile.dist.package.rgapi]
|
|
50
60
|
incremental = false
|
|
61
|
+
|
|
62
|
+
[profile.dist.package.rgapi-py]
|
|
63
|
+
incremental = false
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
src/walk.rs ignore/globset/grep-regex-backed path walking and filtering
|
|
9
9
|
src/search.rs grep-regex/grep-searcher-backed searching
|
|
10
10
|
src/block.rs blank-line-delimited block grouping, matching, and block context
|
|
11
|
-
src/
|
|
11
|
+
py/src/lib.rs PyO3 classes and private core functions
|
|
12
12
|
python/rgapi/ public Python wrappers over `rgapi._core`, plus the `rgapi-nbrg` CLI
|
|
13
13
|
tests/ pytest coverage for the Python API
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
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
|
+
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. Every walking `_core` function takes the walk options as one dict, which PyO3 reads into `WalkOptions`. `_walk(root, **kwargs)` builds that dict. A new walk parameter adds a field to `WalkOptions` and a parameter to `_walk_args`. No `_core` signature changes.
|
|
17
17
|
|
|
18
18
|
## Commands
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
21
|
+
cargo develop
|
|
22
22
|
pytest -q
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
`cargo develop` and bare `cargo test` use the same Cargo profile and share the core and binding libraries. Unit tests also build a separate `cfg(test)` executable. The published `rgapi` crate has no Python dependency; the unpublished `rgapi-py` crate in `py/` builds the extension. Run `cargo fmt` after Rust edits and `chkstyle` before committing Python edits.
|
|
26
26
|
|
|
27
27
|
## Release
|
|
28
28
|
|
|
@@ -30,28 +30,28 @@ The canonical version lives in `Cargo.toml`. `pyproject.toml` gets the Python pa
|
|
|
30
30
|
|
|
31
31
|
Release flow is: release first, then bump - `ship-release` does both.
|
|
32
32
|
|
|
33
|
-
1. Run `
|
|
34
|
-
2. Confirm the release version in `Cargo.toml` (`[package].version`).
|
|
33
|
+
1. Run `cargo develop && pytest -q`.
|
|
34
|
+
2. Confirm the release version in `Cargo.toml` (`[workspace.package].version`).
|
|
35
35
|
3. Run `ship-release`. It tags `v<version>`, pushes branch and tag (CI builds and publishes), then bumps `Cargo.toml`, refreshes the editable install, and pushes the bump without a tag.
|
|
36
36
|
|
|
37
37
|
The GitHub workflow builds wheels for Python 3.10-3.13 on Linux and macOS and publishes the Rust crate, GitHub release artifacts, and PyPI package when a `v*` tag is pushed.
|
|
38
38
|
|
|
39
39
|
## Design notes
|
|
40
40
|
|
|
41
|
-
Python discovery and `paths=True` results contain absolute `pathlib.Path` objects. Structured search rows
|
|
41
|
+
Python discovery and `paths=True` results contain absolute `pathlib.Path` objects. Structured search rows hold base-relative string labels with `/` 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. `SearchLine.lnhash` is computed with the same CRC-32-based line-content hash format as exhash (`lineno|hash|`, low 12 bits of CRC-32 over the line's UTF-8 bytes, encoded as two Base64url characters); `lnhashs=True` only changes row display, not `line_number` or matching behavior. Path regexes filter returned/searched paths; `skip_dir` and `skip_dir_re` prune traversal through `ignore::WalkBuilder::filter_entry`. Depth, size, filesystem, hidden, and ignore options use `ignore::WalkBuilder` settings. The `ignore` walker follows every root it is given. Discovery checks each root with `symlink_metadata`. The worker sends each unfollowed link root as a result before walking the other roots. This also supports dangling roots, which the underlying walker would reject. `ls` sets `walk_root_links`, which gives a root link to a directory to the walker. The walker then reports paths under the link. Other discovery roots use absolute paths without canonicalizing. Content searches retain canonical root resolution. `rg_iter` exposes the same parallel search stream that `rg` collects by default; `paths=True` and `count=True` consume that stream with different reducers. Text search skips binary files and invalid UTF-8 content.
|
|
42
42
|
|
|
43
43
|
Streaming engine: `walk.rs` owns the generic machinery. `StreamIter<T>` is the worker-thread-plus-bounded-channel iterator (`sync_channel(8192)`, so producers block rather than buffer without limit when a consumer lags), and `spawn_walk` owns the shared scaffold: walker config, panic catching, cancel flag, and worker thread. `rg_iter` (`T = SearchLine`), `block_iter` (`T = SearchBlock`), `nb_iter` (`T = NbCell`), and `find_iter` (`T = PathBuf`, the path walk) plug entry closures into that engine. Block search reads each file once, searches it once, groups nonblank lines into blocks, maps matching lines to their blocks, and expands context by block index. Each `SearchBlock` carries numeric boundaries plus hashes for its first and last source lines. Python keeps both and chooses the displayed address without another file read.
|
|
44
44
|
|
|
45
|
+
`resolve_roots` makes the roots absolute, or canonical for content searches, and drops repeats. It also computes the base that result paths and filters are relative to. A directory root is its own base. A file root, or a link root that is not followed, has its parent as its base. Several roots use the common ancestor of their bases. `spawn_walk` walks the roots one after another on its worker thread, with one `ignore` walker per root. Each walker applies the file-root rules to its own root. Entry closures receive the base, not the root. When one root is inside another, a shared set of visited paths lets each path reach the entry closure once. Python gets the same base from `_core.walk_base`.
|
|
46
|
+
|
|
45
47
|
Async API: `fda`, `fda_iter`, `rga`, `rga_iter`, `nbrga`, and `nbrga_iter` wrap the corresponding private core operations. `rga(summary=True)` uses `_core.block_search_async`; ordinary `rga` uses `_core.rg_async`. Each collected core function takes a Python callback, runs on Rust threads through the generic `stream_async` helper, and delivers with one GIL attach at the end. Iterator forms use `stream_iter_async` and attach once per batch. The Python side settles an `asyncio.Future` or feeds an `asyncio.Queue` via `loop.call_soon_threadsafe`; no Python thread blocks and `asyncio.to_thread` is not involved. `AsyncHandle.cancel()` sets the same atomic flag used by the Rust iterators.
|
|
46
48
|
|
|
47
49
|
Truncation is recorded on collected results: `max_results` sets `stop_reason="max_results"`, and `timeout_ms` on `rg`/`rga`/`nbrg`/`nbrga`/`fd`/`fda`/`walk`/`ls` sets `stop_reason="timeout"`. `SearchResults`, `BlockResults`, `PathResults`, and `NbResults` share this through `_Results`; `complete` means `stop_reason is None`. In block summary mode, `max_results` counts matching blocks and keeps their block context. `count=True` returns a plain int, so it rejects timeouts and block summary mode.
|
|
48
50
|
|
|
49
|
-
Rust discovery returns
|
|
51
|
+
Rust discovery returns base-relative `PathBuf` values. Glob filters operate on native paths; only regex matching uses string labels. PyO3 converts discovery roots and results with its filesystem-path support. Python joins each result to the base from `_core.walk_base` without resolving links. `PathResults` stores that display base and completion status, including across slices. Its `__repr__` uses `Path.lstat()` for an `ls -l`-style listing capped at `MAX_REPR` rows. `str()` returns one base-relative name per line. `ls` is `fd` with shell-style defaults (one level, dirs, ignore rules off) and `walk_root_links`, sorted in place.
|
|
50
52
|
|
|
51
53
|
Rust callers can consume a `StreamIter` with `cancel_and_join()` to cancel, drain queued results, and wait for the walk's workers to finish. `Drop` remains nonblocking. Since filesystem calls already in progress must return before joining completes, keep `cancel_and_join()` off async executors.
|
|
52
54
|
|
|
53
55
|
Notebook hierarchy uses `heading_level(source)`, `section_range(levels, idx)` and `ancestor_indices(levels, idx)`. Callers supply zero for non-heading cells. Heading detection skips blank lines and lines starting with `#|`, then checks the first remaining line against `^#{1,6} \w`. It does not search past ordinary text. Section ranges include the addressed cell and end before the next equal-or-higher heading; non-headings select themselves. Ancestors exclude the addressed cell and are returned outermost first. These are calculations over the supplied levels, without retained outline state. Rustygate uses them for its cell selectors.
|
|
54
56
|
|
|
55
57
|
`cell_refs(cell)` takes an nbformat cell as a `serde_json::Value` and returns its sigil references as `CellRefs { vars, cmds, tools }`, in order of appearance, with duplicates. A prompt cell has `solveit_ai: true` in its metadata. `vars` holds each `expr` written as `` $`expr` `` in a prompt cell's source. `cmds` holds each `cmd` written as `` !`cmd` `` in a prompt cell's source. `tools` holds each name written as `` &`name` `` or `` &`[a, b]` ``. A name holds word characters and dots. `cell_refs` reads `tools` from the source of a prompt or Markdown cell. For every other cell it reads the `text/markdown` data of `display_data` and `execute_result` outputs. It never reads a prompt cell's outputs. This function is Rust-only. Rustygate uses it for the cells API's `refs=true`.
|
|
56
|
-
|
|
57
|
-
This package intentionally has no CLI. Python is the interface.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rgapi
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Requires-Dist: fastcore>=2.2.29
|
|
7
|
+
Requires-Dist: fastws-cli>=0.0.20 ; extra == 'dev'
|
|
7
8
|
Requires-Dist: fastship>=0.0.12 ; extra == 'dev'
|
|
8
9
|
Requires-Dist: maturin>=1.0,<2.0 ; extra == 'dev'
|
|
9
10
|
Requires-Dist: pytest ; extra == 'dev'
|
|
10
11
|
Provides-Extra: dev
|
|
11
12
|
License-File: LICENSE
|
|
12
13
|
Summary: Python API for ripgrep-style file walking and searching
|
|
13
|
-
Home-Page: https://github.com/AnswerDotAI/rgapi
|
|
14
14
|
Author-email: Jeremy Howard <j@fast.ai>
|
|
15
15
|
License-Expression: Apache-2.0
|
|
16
16
|
Requires-Python: >=3.10
|
|
@@ -36,6 +36,7 @@ fd(".", ext="py", exclude="test_*.py")
|
|
|
36
36
|
ls("src")
|
|
37
37
|
for row in rg_iter("TODO", ".", include="*.py", context=2): print(row.asdict())
|
|
38
38
|
rg("TODO", ".", ext="py", skip_dir=".venv", paths=True)
|
|
39
|
+
rg("TODO", ["src", "tests"], ext="py")
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
For cell-aware search of Jupyter notebooks (see [Notebooks](#notebooks)):
|
|
@@ -77,7 +78,9 @@ pip install rgapi
|
|
|
77
78
|
|
|
78
79
|
## File discovery
|
|
79
80
|
|
|
80
|
-
`fd` and `walk` return absolute `pathlib.Path` objects. Use them directly with `.read_text()`, `.open()`, `.stat()`, or other filesystem operations. Their collected results display names relative to `root`. Pass `root` as a `str` or `Path
|
|
81
|
+
`fd` and `walk` return absolute `pathlib.Path` objects. Use them directly with `.read_text()`, `.open()`, `.stat()`, or other filesystem operations. Their collected results display names relative to `root`. Pass `root` as a `str` or `Path`, or as a list of them. The sync and async APIs expand `~` and accept `.`, `./`, and paths containing `..`.
|
|
82
|
+
|
|
83
|
+
A list of roots, such as `rg("TODO", ["src", "tests"])`, works with every walk and search function. The roots are searched as one walk that returns one result list. `timeout_ms` and `max_results` apply to the whole walk. Result paths are relative to the common ancestor of the roots. For example, rows read `src/app.py` and `tests/test_app.py`. `PathResults` displays use the same relative paths. Filters such as `include`, `path_re` and `skip_dir` match these relative paths. A file under more than one root, such as `src/app.py` with roots `[".", "src"]`, appears once.
|
|
81
84
|
|
|
82
85
|
Discovery uses the `ignore` crate with ripgrep's default filters. It reads `.gitignore`, `.ignore`, and `.rgignore` files. `.rgignore` takes precedence over `.gitignore`. Pass `ignore=False` to disable all ignore-file filtering, including `.rgignore`.
|
|
83
86
|
|
|
@@ -142,7 +145,7 @@ Use `.name`, `.suffix`, and `.relative_to(root)` for path components. `.stat()`
|
|
|
142
145
|
|
|
143
146
|
Structured text and notebook search rows retain root-relative string labels in their `path` fields. Content searches still follow explicitly named root links. This differs from discovery's default of returning the link itself.
|
|
144
147
|
|
|
145
|
-
The Rust `find` and `find_iter` APIs return native `PathBuf` values relative to the root
|
|
148
|
+
The Rust `find` and `find_iter` APIs return native `PathBuf` values relative to the root, or to the common ancestor of several roots in `WalkOptions::roots`. For an explicitly named file or unfollowed root link, the result is its basename.
|
|
146
149
|
|
|
147
150
|
Rust callers can set `FindOptions::special_files` to also discover FIFOs, sockets, and device nodes, for example to reject unsupported entries during archiving. This defaults to false; normal discovery returns regular files, directories when requested, and symlinks.
|
|
148
151
|
|
|
@@ -224,6 +227,7 @@ The parser reads only each cell's `id`, `cell_type`, and `source`. It skips outp
|
|
|
224
227
|
```bash
|
|
225
228
|
rgapi-nbrg 'read_csv' .
|
|
226
229
|
rgapi-nbrg 'read_csv' . --cell-context 1
|
|
230
|
+
rgapi-nbrg 'read_csv' nbs tests
|
|
227
231
|
rgapi-nbrg 'read_csv' nbs --glob '*.ipynb' --max-results 20
|
|
228
232
|
```
|
|
229
233
|
|
|
@@ -15,6 +15,7 @@ fd(".", ext="py", exclude="test_*.py")
|
|
|
15
15
|
ls("src")
|
|
16
16
|
for row in rg_iter("TODO", ".", include="*.py", context=2): print(row.asdict())
|
|
17
17
|
rg("TODO", ".", ext="py", skip_dir=".venv", paths=True)
|
|
18
|
+
rg("TODO", ["src", "tests"], ext="py")
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
For cell-aware search of Jupyter notebooks (see [Notebooks](#notebooks)):
|
|
@@ -56,7 +57,9 @@ pip install rgapi
|
|
|
56
57
|
|
|
57
58
|
## File discovery
|
|
58
59
|
|
|
59
|
-
`fd` and `walk` return absolute `pathlib.Path` objects. Use them directly with `.read_text()`, `.open()`, `.stat()`, or other filesystem operations. Their collected results display names relative to `root`. Pass `root` as a `str` or `Path
|
|
60
|
+
`fd` and `walk` return absolute `pathlib.Path` objects. Use them directly with `.read_text()`, `.open()`, `.stat()`, or other filesystem operations. Their collected results display names relative to `root`. Pass `root` as a `str` or `Path`, or as a list of them. The sync and async APIs expand `~` and accept `.`, `./`, and paths containing `..`.
|
|
61
|
+
|
|
62
|
+
A list of roots, such as `rg("TODO", ["src", "tests"])`, works with every walk and search function. The roots are searched as one walk that returns one result list. `timeout_ms` and `max_results` apply to the whole walk. Result paths are relative to the common ancestor of the roots. For example, rows read `src/app.py` and `tests/test_app.py`. `PathResults` displays use the same relative paths. Filters such as `include`, `path_re` and `skip_dir` match these relative paths. A file under more than one root, such as `src/app.py` with roots `[".", "src"]`, appears once.
|
|
60
63
|
|
|
61
64
|
Discovery uses the `ignore` crate with ripgrep's default filters. It reads `.gitignore`, `.ignore`, and `.rgignore` files. `.rgignore` takes precedence over `.gitignore`. Pass `ignore=False` to disable all ignore-file filtering, including `.rgignore`.
|
|
62
65
|
|
|
@@ -121,7 +124,7 @@ Use `.name`, `.suffix`, and `.relative_to(root)` for path components. `.stat()`
|
|
|
121
124
|
|
|
122
125
|
Structured text and notebook search rows retain root-relative string labels in their `path` fields. Content searches still follow explicitly named root links. This differs from discovery's default of returning the link itself.
|
|
123
126
|
|
|
124
|
-
The Rust `find` and `find_iter` APIs return native `PathBuf` values relative to the root
|
|
127
|
+
The Rust `find` and `find_iter` APIs return native `PathBuf` values relative to the root, or to the common ancestor of several roots in `WalkOptions::roots`. For an explicitly named file or unfollowed root link, the result is its basename.
|
|
125
128
|
|
|
126
129
|
Rust callers can set `FindOptions::special_files` to also discover FIFOs, sockets, and device nodes, for example to reject unsupported entries during archiving. This defaults to false; normal discovery returns regular files, directories when requested, and symlinks.
|
|
127
130
|
|
|
@@ -203,6 +206,7 @@ The parser reads only each cell's `id`, `cell_type`, and `source`. It skips outp
|
|
|
203
206
|
```bash
|
|
204
207
|
rgapi-nbrg 'read_csv' .
|
|
205
208
|
rgapi-nbrg 'read_csv' . --cell-context 1
|
|
209
|
+
rgapi-nbrg 'read_csv' nbs tests
|
|
206
210
|
rgapi-nbrg 'read_csv' nbs --glob '*.ipynb' --max-results 20
|
|
207
211
|
```
|
|
208
212
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "rgapi-py"
|
|
3
|
+
version.workspace = true
|
|
4
|
+
edition.workspace = true
|
|
5
|
+
publish = false
|
|
6
|
+
|
|
7
|
+
[lib]
|
|
8
|
+
crate-type = ["cdylib", "rlib"]
|
|
9
|
+
test = false
|
|
10
|
+
|
|
11
|
+
[dependencies]
|
|
12
|
+
rgapi = { path = ".." }
|
|
13
|
+
grep-matcher.workspace = true
|
|
14
|
+
grep-regex.workspace = true
|
|
15
|
+
pyo3 = { version = ">=0.29", features = ["extension-module"] }
|
|
16
|
+
|
|
17
|
+
[build-dependencies]
|
|
18
|
+
pyo3-build-config = "0.29"
|
rgapi-0.2.1/py/build.rs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fn main() { pyo3_build_config::add_extension_module_link_args(); }
|