beeware / beeware/toga

Audit for a possible convergence on using `platformdirs` for app paths

Open
#4,666 10 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
15h 39m
Merged PRs (30d)
40

Description

### What is the problem or limitation you are having?

#4645 introduced the use of `platformdirs` as the basis for accessing app and user paths on Linux-based apps (including Linux deployments of Textual-based apps). This allows us to lean on `platformdirs` as an implementation of XDG and other platform-specific mechanisms for finding app-related paths.

`platformdirs` also has support for macOS, Windows and Android. We should be making better use of the `platformdirs` implementation, rather than duplicating the implementation.

### Describe the solution you'd like

We should use `platformdirs` as the basis for macOS (Cocoa) and Windows (Winforms) implementation of app paths.

The complication is that these backends already have existing implementations for platform paths, and there are known discrepancies between the paths returned by `platformdirs`, and the paths returned by the existing backend implementations.

On each backend, and each of the paths supported by platformdirs, we need to know:

1. The path/path scheme that platformdirs returns
2. The path/path scheme currently returned by the Toga backend
3. Which is correct based on platform standards? If it's a matter of "taste" rather than a strict platform standard, that should be made clear in the analysis
4. Is there a plausible migration scheme from Toga's current path usage to a platformdirs-based implementation?

The ultimate "completion" of this task is not any code - it is purely a design decision on how to proceed further - this will be either:
1. Abandon the idea
2. Progress forward, with a clear plan for migration or backwards incompatibilities that will be accepted.

### Describe alternatives you've considered

Status quo - keep a duplication of platform dirs.

### Additional context

Platformdirs also contains support for Android, but using `pyjnius`, so it isn't compatible with Toga. It doesn't have support for iOS.

Ideally, we'd get Toga-compatible support upstream in platformdirs, and use that as the basis for migrating the iOS and Android backends to use platformdirs.

Contributor guide

Open the contributing guide

Research direction

Compare platformdirs' documented path schemes with the existing Cocoa and Winforms backend implementations, covering each path supported by platformdirs. Record the current and proposed paths, assess platform-standard correctness and migration risks, and finish with a decision to abandon the approach or a clear migration plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop, operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.