A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.
Project description
platformdirs
A Python package for determining platform-specific directories (e.g. user data, config, cache, logs). Handles the differences between macOS, Windows, Linux/Unix, and Android so you don't have to.
Quick start
from platformdirs import PlatformDirs
dirs = PlatformDirs("MyApp", "MyCompany")
dirs.user_data_dir # ~/.local/share/MyApp (Linux)
dirs.user_config_dir # ~/.config/MyApp (Linux)
dirs.user_cache_dir # ~/.cache/MyApp (Linux)
dirs.user_state_dir # ~/.local/state/MyApp (Linux)
dirs.user_log_dir # ~/.local/state/MyApp/log (Linux)
dirs.user_documents_dir # ~/Documents
dirs.user_downloads_dir # ~/Downloads
dirs.user_runtime_dir # /run/user/<uid>/MyApp (Linux)
For Path objects instead of strings:
from platformdirs import PlatformDirs
dirs = PlatformDirs("MyApp", "MyCompany")
dirs.user_data_path # pathlib.Path('~/.local/share/MyApp')
dirs.user_config_path # pathlib.Path('~/.config/MyApp')
Convenience functions for quick access:
from platformdirs import user_data_dir, user_config_path
user_data_dir("MyApp", "MyCompany") # returns str
user_config_path("MyApp", "MyCompany") # returns pathlib.Path
Directory types
- Data: Persistent application data (
user_data_dir,site_data_dir) - Config: Configuration files and settings (
user_config_dir,site_config_dir) - Cache: Cached data that can be regenerated (
user_cache_dir,site_cache_dir) - State: Non-essential runtime state like window positions (
user_state_dir,site_state_dir) - Logs: Log files (
user_log_dir,site_log_dir) - Runtime: Runtime files like sockets and PIDs (
user_runtime_dir,site_runtime_dir)
Each type has both user_* (per-user, writable) and site_* (system-wide, read-only for users) variants.
Documentation
Full documentation is available at platformdirs.readthedocs.io:
- Getting started tutorial -- learn core concepts through real-world examples
- How-to guides -- recipes for common tasks and platform-specific tips
- API reference -- complete list of functions and classes
- Platform details -- default paths for each operating system
Contributions are welcome! See CONTRIBUTING.md for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file platformdirs-4.9.1.tar.gz.
File metadata
- Download URL: platformdirs-4.9.1.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f310f16e89c4e29117805d8328f7c10876eeff36c94eac879532812110f7d39f
|
|
| MD5 |
d8bda2dcbd55be50a43f492244b5e1d4
|
|
| BLAKE2b-256 |
6cd5763666321efaded11112de8b7a7f2273dd8d1e205168e73c334e54b0ab9a
|
Provenance
The following attestation bundles were made for platformdirs-4.9.1.tar.gz:
Publisher:
release.yaml on tox-dev/platformdirs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
platformdirs-4.9.1.tar.gz -
Subject digest:
f310f16e89c4e29117805d8328f7c10876eeff36c94eac879532812110f7d39f - Sigstore transparency entry: 953253567
- Sigstore integration time:
-
Permalink:
tox-dev/platformdirs@d983fb18dcc3f688894f84783ae9b305b0c50e37 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tox-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@d983fb18dcc3f688894f84783ae9b305b0c50e37 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file platformdirs-4.9.1-py3-none-any.whl.
File metadata
- Download URL: platformdirs-4.9.1-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d8b967d34791c162d30d60737369cbbd77debad5b981c4bfda1842e71e0d66
|
|
| MD5 |
070d794362640442867d8e07ec736d01
|
|
| BLAKE2b-256 |
7077e8c95e95f1d4cdd88c90a96e31980df7e709e51059fac150046ad67fac63
|
Provenance
The following attestation bundles were made for platformdirs-4.9.1-py3-none-any.whl:
Publisher:
release.yaml on tox-dev/platformdirs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
platformdirs-4.9.1-py3-none-any.whl -
Subject digest:
61d8b967d34791c162d30d60737369cbbd77debad5b981c4bfda1842e71e0d66 - Sigstore transparency entry: 953253568
- Sigstore integration time:
-
Permalink:
tox-dev/platformdirs@d983fb18dcc3f688894f84783ae9b305b0c50e37 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tox-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@d983fb18dcc3f688894f84783ae9b305b0c50e37 -
Trigger Event:
workflow_dispatch
-
Statement type: