Skip to main content

dua-py

A minimal Python interface around the Rust traversal engine from dua-cli.

dua represents a traversal as an in-memory StableGraph<EntryData, (), Directed> with TreeIndex node IDs. This package uses PyO3 and maturin to run that traversal, integrate the emitted events into the graph, and return nested Python objects that keep the same tree shape.

Install

pip install dua-py

What gets bundled

dua-py uses the Rust library API from dua-cli; it does not shell out to the dua command-line executable.

When you install a PyPI wheel, the compiled Rust extension includes the dua-cli library code and its Rust dependencies. You do not need to install the standalone dua binary separately.

PyPI wheels are currently built for macOS and Linux. Windows wheels are not published because dua-cli currently requires an unstable Rust feature for its Windows library build.

When pip falls back to the source distribution, the dua-cli source is not vendored into this repository. The build uses Cargo.toml and Cargo.lock, so the machine installing from source needs Rust/Cargo and access to crates.io to fetch and compile the Rust dependencies.

Install for development

python -m venv .venv
source .venv/bin/activate
python -m pip install maturin pytest
maturin develop
pytest

Usage

from pathlib import Path

import dua_py

root = dua_py.walk(Path("."))
print(root.path, root.size, root.entry_count)

for child in root.children:
    print(child.name, child.size)

For multiple traversal roots, use scan():

roots = dua_py.scan(["src", "tests"], apparent_size=True)

API

dua_py.walk(path, **options) -> Entry

Scan a single filesystem path and return one Entry.

dua_py.scan(paths, **options) -> tuple[Entry, ...]

Scan one or more filesystem paths and return the top-level traversal entries.

Options:

  • threads: int | None = None - number of walker threads. None uses the available CPU parallelism.
  • apparent_size: bool = False - use metadata length instead of allocated disk usage.
  • count_hard_links: bool = False - count every hard-link occurrence independently.
  • cross_filesystems: bool = True - allow traversal to cross filesystem boundaries.
  • ignore_dirs: Iterable[path] | None = None - directories to skip.
  • sort: bool = True - sort entries alphabetically while walking and returning children.
  • use_root_path: bool = True - keep the root path as the root entry name.

Entry

Entry is an immutable dataclass:

@dataclass(frozen=True)
class Entry:
    name: str
    path: str
    size: int
    mtime: float
    entry_count: int | None
    metadata_io_error: bool
    is_dir: bool
    children: tuple[Entry, ...]

size is reported in bytes. mtime is seconds since the Unix epoch. For directories, size and entry_count are recursively aggregated by dua.

Release files for dua-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dua-py 0.1.0
File Size Uploaded
dua_py-0.1.0.tar.gz 23.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for dua-py 0.1.0
File Interpreter ABI Platform
dua_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
dua_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
dua_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64 Details

Total release size: 1.9 MB

Release files / dua_py-0.1.0.tar.gz

Download URL dua_py-0.1.0.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
953b2fbf3b57a149855eabb1431df8e7cb9972f5252d52e458ce56a189cf3a38
BLAKE2b-256 checksum
How to use checksums
bed3a094842ebaeaabba5cac81fa7122eb88bc43e0f071765126f55c64ea0bec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dua_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL dua_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 547.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5711435146121d7d8fcd2bb5de5d6976a568d7c51548fd5e291ed4e9cddc2912
BLAKE2b-256 checksum
How to use checksums
b76204d119e1a7e9e9aba5611bed3b4e0509cd14d32400f4fa3ce41dd58a0b4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dua_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL dua_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 500.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
66878800d63d869bfd8c218350391a546e8f5b655a61e1d746df7f646cd4a9e0
BLAKE2b-256 checksum
How to use checksums
f31f60d6e346dc888ed99961212ef60b6c407707558b2819ff8cb7ff7b2d4cd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / dua_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL dua_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 860.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fdc7ec70be91ed0817390bb2083129af3d4dac099054144a70aa2c8a2460f052
BLAKE2b-256 checksum
How to use checksums
bf05b3afc30927701a92f88ad747f365b71e464256b605d1b228cda75a5d90a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page