Giter Club home page Giter Club logo

Comments (8)

DanCardin avatar DanCardin commented on July 30, 2024 7

I honestly, it seems like it would be ideal if appdirs listened to XDG_*_HOME for all operating systems.

Even if XDG isn't specified for macos, for almost all tools I can set (expecting it to work) XDG_CONFIG_HOME, and therefore I can commit that dir to my dotfiles. Now, any library which uses appdirs forces me to go back to using symlinks and yields a worse experience.

In my mind, even if it doesn't make the most sense for someone to set it on windows, it at least gives everyone an opportunity to customize the config location, as opposed to unconditionally having it set to a specific location (but only on certain operating systems). And ultimately in the default case where it's not being set, you get the same existing behavior.

from appdirs.

xmo-odoo avatar xmo-odoo commented on July 30, 2024 3

@arusahni I expect @rendaw means doing so when it's configured as darwin if you want/need to e.g.

import appdirs
if appdirs.system == 'darwin':
    appdirs.system = 'linux2'

if you want your application to follow XDG rules even on OSX.

from appdirs.

DanCardin avatar DanCardin commented on July 30, 2024 3

#137 seems like it'd be a jarring breaking change, on new installations it'd always prefer ~/.config, hardcoded.

I'm imagining

def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
    path = os.getenv('XDG_CONFIG_HOME')
    if not path:
        if system == "win32":
            path = user_data_dir(appname, appauthor, None, roaming)
        elif system == 'darwin':
            path = os.path.expanduser('~/Library/Preferences/')
        else:
            path = os.path.expanduser("~/.config")

    # win32's user_data_dir already appends appname
    if appname and system != "win32":
        path = os.path.join(path, appname)

    if appname and version:
        path = os.path.join(path, version)
    return path

Given my understanding of the reasoning for the way it is right now (XDG is only a thing for linux), then this seems ideal to me:

  • for people for whom that assumption is correct, they wont have XDG_CONFIG_HOME set and they'll see no change in behavior
    ** "Free" extra functionality for windows, where it's even less likely someone opts into thus, but hey i see no reason to artificially cripple windows.
  • for people like me, I'll see the behavior i want

Probably ideally this pattern is applied to all the xdg variables, but truly config is the only one that I'd actually like to commit to a repo, and therefore the only one there's a significant incentive to fix.

Happy to submit an actual PR if there's an indication it'd get merged.

from appdirs.

arusahni avatar arusahni commented on July 30, 2024 1

That looks like it'd apply that rule even when on Windows.

from appdirs.

arusahni avatar arusahni commented on July 30, 2024

Click does something similar for POSIX systems, although it doesn't try to infer the XDG_CONFIG_HOME directory. Instead it just returns a top-level ~/.appname dir for all platforms.

from appdirs.

rendaw avatar rendaw commented on July 30, 2024

Could you set appdirs.system to linux2 maybe? https://github.com/ActiveState/appdirs/blob/master/appdirs.py#L39

from appdirs.

0az avatar 0az commented on July 30, 2024

I guess I can take a stab at a PR re-enabling XDG_CONFIG_HOME on Darwin next week.

E: #137 exists.

from appdirs.

0az avatar 0az commented on July 30, 2024

Happy to submit an actual PR if there's an indication it'd get merged.
Unfortunately, we might have to wait for maintenance status to get sorted out in #79.

from appdirs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.