-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow XDG_CONFIG_HOME on macOS #4
Comments
I want (some version of) this change personally too, but I think we have to be quite careful -- the Apple guidelines are clear, so I'm:
(Not sure you were suggesting anything about default behavior, but yeah just mentioning my own opinion on all 3 decisions). |
For the record, I'm +1, +0, and +1 on those three points. |
Apple does not follow the XDG spec, so at best what I've seen is people roughly mapping it, see https://stackoverflow.com/questions/3373948/equivalents-of-xdg-config-home-and-xdg-data-home-on-mac-os-x If anyone has better links/documentation on what exactly would mean following the XDG spec when the XDG env-vars are set feel free to clarify. |
If XDG* is set (and is a CLI program), then the program should use XDG.
Other cases (GUI programs) are less clear, but if it has an application
bundle, then it's less likely that XDG is the answer.
|
How do you identify if the Python app is CLI or not? |
I think that the default should assume CLI. At the very least, this needs
to be specifiable downstream. Cross platform applications using Python most
likely see use in XDG compliant systems as well, and they often use configs
editable in Vim/etc. So having them in a well known location across
platforms is a compelling concern IMHO.
|
It gets tricky because platformdirs might be a dependency of one of your libraries, so the caller codebase might not have direct access to it, and could not necessarily tell in what env type is used. We could make it a global state I guess, something like
So then GUIS could call part of their setup that code, even if it's used by a transient dependency. |
I'm unsure if it makes sense for a dependent library to use platformdirs. I
guess it needs to be supported regardless, though.
Actually, what if this is done per key?
|
I'd personally rather have one global flag. Are we aware of other languages/libraries respecting XDG on macOS as precedence? |
If you are aware of ones that *don't* support XDG, please let me know so
that I can PR it in the future. With any luck, I can just PR platformdirs
instead of appdirs. :)
But in all seriousness, anything ported directly from Linux/Unix that
already uses XDG generally adheres to XDG on Mac. Anything that uses
~/.config follows the half of XDG that I care about (and a lot of stuff
uses ~/.config these days, including git).
And a concrete example: I did recently PR XDG into the Backblaze SDK, which
is used by their CLI and in other applications as a library.
|
Feel free to open a pull request 👍 |
How should backwards compatibility be handled? |
What do you suggest? |
Pushed my proposal for backwards compat to #35, which is mostly complete (just needs more tests, a bit of bikeshedding, and a rebase). |
This symlink is created by iTerm2, it's not a new addition to the OS. |
Would you accept a PR to extend the |
I personally would be alright with this, however, considering its wide-ranging implications I'd like to get input of some of the downstream users; e.g. pip cc @pradyunsg, pytest @asottile @nicoddemus. Plus the opinion of other maintainers: @RonnyPfannschmidt @ofek @Julian. |
I felt icky about it when seeing the email notification last night, but I can't place my finger on why yet :) |
I don't think pytest uses platformdirs/appdirs yet though many of its consumers do so my opinion is less rooted but I'll give it anyway:
that said, I think having some way to configure the directories via an environment variable is a desirably feature, and XDG is fairly well specced to enable such a feature. there's an additional question as to how you handle XDG considering a "default" -- and in that case you'd probably want to ignore XDG's recommended defaults and use the platform-specific defaults. the other edge case is when the xdg variable is present but empty -- which seems to imply a bit more "I want xdg" but typically empty should be treated the same as missing (though a popular "standard" (NO_COLOR) gets this wrong as well) anyway, I'm not a maintainer here -- nor am I currently a direct consumer -- nor am I a maintainer of a direct consumer -- so feel free to ignore my thoughts on this :) -- I'm going to unsubscribe from notifications and if you need me please @-mention directly |
I'm a soft -1 for doing any changes related to this on Windows, and -0 for adopting XDG-when-set on MacOS (as long as there's a way to opt out, or if it's made opt-in). I'd lean toward having There's absolutely no reason to follow XDG for Windows; and doing so will only complicate the story for files on Windows. For pip, this will mean additional caveats to the configuration file story on Windows. I'm not sure I'd want pip to support XDG configuration on MacOS either, since we're already technically out of sync with the Apple's specification for where configuration files should be; in more ways than one. Adding XDG as an additional layer of complexity on that would not be something I'd be enthusiastic about, to put it mildly. |
I would prefer this as well. Using XDG on windows feels wrong and that way we don't run into issues causing unintended behavior for other applications that are using those environment variables.
Does that also include adding |
Are there any well know / used standards for this on windows? IMHO the platform specific override mechanism should be used |
CC @zooba in case he cares to opine. |
I have to disagree with the logic. There is absolutely a reason to support XDG on both MacOS and Windows. It gives developers options. Regular "I don't know anything about computers" users won't care. But, I certainly do. I share my HOME directory tree across platforms. During development I hate to have to go digging around in AppData to find things. Being able to control that would be very helpful. You may think that Windows has standard directories for everything, but many application don't use them. For years Python only installed in C:\Python. And along came WSL. Now I can run Linux and Windows at the same time and share files. Being able to have a project directory seen by both platforms is great for development. With XDG dirs I can have python tools install into $HOME/.local/bin or $HOME/.local/bin_win. Please remember that adding support for XDG dirs doesn't affect anyone that doesn't use them (for MacOS and Windows). On Linux if not set they should default appropriately. |
We hear your points, but please respect the decision of the maintainer team on this topic 👍 Unless the current maintainers come back that they've changed their minds there's nothing else to do. |
I understand. |
Closing per above. |
@gaborbernat is the maintainer team also against implementing it on MacOS? If not - might be worth keeping this open? |
I think we were 🤔 |
Allow specifying the config/cache directories that Dangerzone will use, both for the CLI and the GUI, via CLI arguments. This way, the user has better control of where Dangerzone will save its state and, most importantly, we can use this feature to make each test run in a different directory. Moreover, we fix an issue where the temporary conversion artifacts were stored in the configuration directory, instead of the cache directory. Note that while most OSes (Windows and Linux) offer a way to specify these directories through environment variables, the same does not apply to MacOS [1], so having a CLI flag is required. [1]: tox-dev/platformdirs#4
What about a opt-in environment variable --- __init__.py.bak 2023-03-25 16:36:36.753498600 +0800
+++ __init__.py 2023-03-25 16:38:20.665189000 +0800
@@ -19,6 +19,9 @@
def _set_platform_dir_class() -> type[PlatformDirsABC]:
+ if os.getenv("PLATFORMDIRS_USE_XDG"):
+ from platformdirs.unix import Unix as Result
+
if sys.platform == "win32":
from platformdirs.windows import Windows as Result
elif sys.platform == "darwin": |
Got surprised I could not find a way to specify PDM config dir on macOS, in order to change it from ~/Library/Application Support/pdm to much more appropriate ~/.config/pdm which is effectively Digging into https://github.com/platformdirs/platformdirs/blob/b866d404c74d3467ab7a16e2be974612b14145b7/src/platformdirs/macos.py#L10-L11Having config stored at ~/Library/Application Support is anything but Unix thing. It's also not exactly macOS native thing, as all ~/Library/Preferences but I guess it's fine for some cross platform, especially, GUI apps, to use the former. Because macOS is certified Unix (inspired by BSD at POSIX level), it's not unnatural to expect basic Unix conformance, which is luckily the case (notwithstanding its infamously being known to deviate from all kinds of standards). The concern I can immediately come up with (there might be more) is related to Besides: there is unspoken contract for them to reside at $HOME/.config or
which rules out their placement to Application Support. For this to work,
|
I do not believe this to be the case to the extent you wish to be. |
[why] When a user sets the XDG_DATA_HOME environment variable the default of $HOME/.local/share should not be used. https://wiki.archlinux.org/title/XDG_Base_Directory [how] Enable XDG_DATA_HOME to override the default user data directory on Unix and MacOS platforms. There is some controversy if XDG_DATA_HOME should be honored on MacOS, see for example platformdirs (link below). But me also working on Linux and MacOS (and Windows) in parallel, I can not quite follow the downsides and believe we should allow XDG_DATA_HOME also for MacOS. Related: tox-dev/platformdirs#4 Fixes: #1324 Suggested-by: Anthony Foglia <@afoglia> Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
I suppose it was meant that macOS is POSIX certified? But at that level we are just splitting hairs and getting nowhere further to solving a major pain point that users are complaining about here. The commenters in this issue have given plenty of use cases for supporting XDG_CONFIG_HOME on macOS. Being technically correct about this or that is not the same as "doing the right thing". To me, open source is about respecting user freedom. |
Sometimes freedom from incorrect implementation is more important than freedom to do broken things out of preference |
[why] When a user sets the XDG_DATA_HOME environment variable the default of $HOME/.local/share should not be used. https://wiki.archlinux.org/title/XDG_Base_Directory [how] Enable XDG_DATA_HOME to override the default user data directory on Unix and MacOS platforms. There is some controversy if XDG_DATA_HOME should be honored on MacOS, see for example platformdirs (link below). But me also working on Linux and MacOS (and Windows) in parallel, I can not quite follow the downsides and believe we should allow XDG_DATA_HOME also for MacOS. Related: tox-dev/platformdirs#4 Fixes: #1324 Suggested-by: Anthony Foglia <@afoglia> Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] When a user sets the XDG_DATA_HOME environment variable the default of $HOME/.local/share should not be used. https://wiki.archlinux.org/title/XDG_Base_Directory [how] Enable XDG_DATA_HOME to override the default user data directory on Unix and MacOS platforms. There is some controversy if XDG_DATA_HOME should be honored on MacOS, see for example platformdirs (link below). But me also working on Linux and MacOS (and Windows) in parallel, I can not quite follow the downsides and believe we should allow XDG_DATA_HOME also for MacOS. Related: tox-dev/platformdirs#4 Fixes: ryanoasis#1324 Suggested-by: Anthony Foglia <@afoglia> Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] When a user sets the XDG_DATA_HOME environment variable the default of $HOME/.local/share should not be used. https://wiki.archlinux.org/title/XDG_Base_Directory [how] Enable XDG_DATA_HOME to override the default user data directory on Unix and MacOS platforms. There is some controversy if XDG_DATA_HOME should be honored on MacOS, see for example platformdirs (link below). But me also working on Linux and MacOS (and Windows) in parallel, I can not quite follow the downsides and believe we should allow XDG_DATA_HOME also for MacOS. Related: tox-dev/platformdirs#4 Fixes: ryanoasis#1324 Suggested-by: Anthony Foglia <@afoglia> Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
For many tools, especially those designed for use across Linux/Unix/Mac, it makes sense to use XDG as a common standard. This especially applies to command line tools, for which
~/Library/*
breaks inherited convention (and thus breaks interop).I have previously submitted PRs to resolve this in several applications on macOS, but it would be easier to establish good defaults here instead of sending PRs to patch around it downstream. (This also makes this a blocker for personal usage – at least without vendoring and modifying the module, which isn't ideal.)
Appdirs issue: ActiveState/appdirs#78
The text was updated successfully, but these errors were encountered: