platformdirs
A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.
This package has a good security score with no known vulnerabilities.
Community Reviews
Rock-solid utility for cross-platform directory management with zero overhead
From a production standpoint, this library is essentially invisible at runtime. It's pure path computation with no I/O operations, network calls, or resource allocation. Memory footprint is negligible, execution is instantaneous, and there's literally nothing that can fail beyond basic OS permission issues. The library doesn't create directories by default, giving you full control over filesystem operations and error handling.
I've used this across dozens of services for log rotation paths, application cache directories, and config file locations. It just works consistently. The API has remained stable across versions with no breaking changes that affected my deployments. For operational tooling, it's exactly what you want: predictable, minimal, and maintenance-free.
Best for: Any application needing cross-platform directory paths for configs, logs, or caches with predictable, zero-overhead behavior.
Avoid if: You need a full-featured configuration management system with file watching, validation, or complex directory structure management.
Reliable, zero-overhead directory resolution with excellent cross-platform support
The API is straightforward: instantiate PlatformDirs with your app name/author, call the appropriate property (user_data_dir, user_cache_dir, etc.), and you're done. No connection pooling needed, no retry logic required - it either returns a string path or raises an exception immediately if something is fundamentally wrong. Error handling is predictable: you get standard Python exceptions if environment variables are malformed, but in practice this rarely happens.
The main operational consideration is that it only returns paths - it doesn't create directories. You must handle os.makedirs yourself, which gives you control but requires boilerplate. Configuration is minimal (basically just app name/version), which is appropriate for its scope. No breaking changes in recent versions that affected production systems.
Best for: Applications needing cross-platform config, cache, or data directory paths with predictable, zero-overhead behavior.
Avoid if: You need automatic directory creation with permission handling or complex path validation logic.
Reliable path resolution with minimal security surface area
From a security perspective, this is a low-risk dependency. It doesn't handle file I/O itself, just returns path strings, so you still need to validate and sanitize these paths before use. The library won't create directories by default unless you use the path properties (not the dir methods), which is reasonably safe-by-default. One gotcha: it doesn't prevent path traversal if you concatenate user input to these base paths—that's on you to handle.
Error handling is minimal because there's little that can go wrong—it's mostly string manipulation and OS detection. The library has been stable for years with very few CVEs (none that I'm aware of). For what it does, it's a solid, boring utility that just works.
Best for: Applications needing cross-platform directory paths for config, cache, or data storage with minimal dependencies.
Avoid if: You need comprehensive file system abstractions with built-in permission handling or path validation.
Sign in to write a review
Sign In