Skip to main content

A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.

Project description

platformdirs

PyPI version Python versions CI Downloads

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:

Contributions are welcome! See CONTRIBUTING.md for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

platformdirs-4.9.6.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

platformdirs-4.9.6-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file platformdirs-4.9.6.tar.gz.

File metadata

  • Download URL: platformdirs-4.9.6.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for platformdirs-4.9.6.tar.gz
Algorithm Hash digest
SHA256 3bfa75b0ad0db84096ae777218481852c0ebc6c727b3168c1b9e0118e458cf0a
MD5 6b9f7a12243ab0609a433bcf2f641c6b
BLAKE2b-256 9f4a0883b8e3802965322523f0b200ecf33d31f10991d0401162f4b23c698b42

See more details on using hashes here.

Provenance

The following attestation bundles were made for platformdirs-4.9.6.tar.gz:

Publisher: release.yaml on tox-dev/platformdirs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file platformdirs-4.9.6-py3-none-any.whl.

File metadata

  • Download URL: platformdirs-4.9.6-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.12

File hashes

Hashes for platformdirs-4.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e61adb1d5e5cb3441b4b7710bea7e4c12250ca49439228cc1021c00dcfac0917
MD5 3ce5ef9b95238835cb65b97caa06c832
BLAKE2b-256 75a6a0a304dc33b49145b21f4808d763822111e67d1c3a32b524a1baf947b6e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for platformdirs-4.9.6-py3-none-any.whl:

Publisher: release.yaml on tox-dev/platformdirs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page