Skip to content

Feature Request: Respect standard XDG/cross-platform user data directories for .arc-data #224

Description

@krokosik

Description

Currently, the package hardcodes its data directory to the root of the user's home directory:

DPATH = os.path.join(os.path.expanduser("~"), ".arc-data")

While this works, it clutters the user's home directory and ignores operating system standards for storing application data (e.g., the XDG Base Directory Specification on Linux, AppData on Windows, and Library/Application Support on macOS).

Proposed Solution

It would be great if the package could adopt cross-platform directory standards. There are two common ways to handle this in Python:

1. Use the platformdirs library
platformdirs is a tiny, widely adopted standard for this (and is used by tools like pip, black, and pylint).

from platformdirs import user_data_dir
import os

# Resolves to ~/.local/share/arc on Linux, AppData\Local\arc on Windows, etc.
DPATH = user_data_dir("arc") 
os.makedirs(DPATH, exist_ok=True)

2. Add an environment variable override
If adding a dependency isn't an option, allowing users to override the path via an environment variable (while falling back to XDG_DATA_HOME on Linux) would be a great lightweight alternative:

import os

def get_data_dir():
    # 1. Allow explicit override
    if override := os.environ.get("ARC_DATA_DIR"):
        return override
        
    # 2. Respect XDG on Linux/macOS if set
    if xdg_data := os.environ.get("XDG_DATA_HOME"):
        return os.path.join(xdg_data, "arc")
        
    # 3. Fallback to current behavior
    return os.path.join(os.path.expanduser("~"), ".arc-data")

DPATH = get_data_dir()

Let me know if you would be open to one of these approaches and I'll make a PR

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions