Skip to content

Support for Windows and Mac OS. #177

Open

Description

@sethmlarson

Brought this up in Gitter and apparently this has had work done on it in a separate branch. (Link that here?). I've had multiple times where I wanted to have the amount of information about a Windows or Mac OS platform as the distro module gives but platform.mac_ver and platform.win32_ver are pretty deficient in. This thread is mostly for discussing how this would be done. cc: @nir0s

Activity

  1. nir0s commented on Apr 2, 2017

    @nir0s
    Collaborator

    So, My idea was that we implement a class per OS type. Distro will identify the OS it's running on (Darwin, nt, linux, etc..) and generate a distro object for that OS type when it is imported.

    When you run distro.id(), for example, it would map what would be the ID in Windows to the relevant information provided by the OS.

    This will aid users is making OS dependent decisions without having to know which OS they're running on.

  2. nir0s commented on Apr 4, 2017

    @nir0s
    Collaborator

    That being said, this means that to keep a consistent API as well have to come up with a good mapping from each OS type to the names of the functions already in distro.

  3. sethmlarson commented on Apr 4, 2017

    @sethmlarson
    ContributorAuthor

    I would suggest changing linux_distribution() to just distribution()? The rest map pretty well actually. All Windows and Mac distributions have a codename, id='windows', 'macos', version, name, pretty name.

  4. nir0s commented on Apr 5, 2017

    @nir0s
    Collaborator

    distro.linux_distribution is meant to replace platform.linux_distribution.. so I think it's kinda weird to remove it now, though there's no problem with deprecating it at some point.

    If we want distribution, I'd add it on top of linux_distribution while linux_distribution only returns for linux and distribution returns for any.

  5. sethmlarson commented on Apr 5, 2017

    @sethmlarson
    ContributorAuthor

    I'd say that something like that would work fine. Do we only define that method when on Linux (forcing distro users to check with hasattr) or have linux_distribution throw an error on non-Linux (forcing distro users to catch or check the system type first) or map linux_distribution to distribution just for backwards-compatibilities sake? Kind of awkward name-wise but at least our users don't have to check anything or receive any unexpected exceptions. Number 1 and 3 seem like the best options IMO.

  6. nir0s commented on Apr 8, 2017

    @nir0s
    Collaborator

    Um, it seems more natural to me to return empty for linux_distribution if you're not on linux and maybe throw a warning. Mapping might create some ambiguity since you're getting information on a non-linux system in what you'd expect to work only on linux. The reason because of which I like the return empty thing, is because distro tends to return (much like platform's implementation) empty results when it can't find something. This behavior would correspond with the natural flow distro's takes instead of unexpectedly erroring out only in this specific use case.

  7. sethmlarson commented on Apr 8, 2017

    @sethmlarson
    ContributorAuthor

    Oh sure! That can definitely be done. So just a Distribution object that has all empty values.

  8. FooBarQuaxx commented on Jan 2, 2019

    @FooBarQuaxx

    This feature is very useful but I don't see any progress? The referenced @sethmlarson closed PR looks a good place to start (resume) work. I don't see why it's taking this long to deliver support for Windows and MacOS systems.

  9. sethmlarson commented on Jan 2, 2019

    @sethmlarson
    ContributorAuthor

    @FooBarQuaxx Changes to open source projects require contributors willing to give to their free time. Perhaps you could provide a patch?

  10. Akm0d commented on Oct 10, 2019

    @Akm0d

    It might be helpful to use https://github.com/saltstack/salt/blob/master/salt/grains/core.py#L1624 as a reference when adding this feature

  11. s0undt3ch commented on May 17, 2020

    @s0undt3ch

    @Akm0d where you referring to this?
    Linked to a commit Sha so we would loose track of what implementation detail you were referring to.

  12. i2 commented on Jun 19, 2022

    @i2

    I was wondering if there is any update on this? Thank you!

  13. ssbarnea commented on Jan 10, 2023

    @ssbarnea

    @sethmlarson How open are you to welcome new cores to the project? I could give a hand with maintenance and also address long missing features like this one.

  14. 3 remaining items

  15. i2 commented on Sep 5, 2024

    @i2

    @kdeldycke Are you going to ask for a merge of these features into upstream?

  16. kdeldycke commented on Sep 5, 2024

    @kdeldycke

    @i2 I don't know. Maybe my new features are too ambitious for the stated scope of distro, which seems to be limited to filling the gap of the missing Python's original platform.linux_distribution.

  17. i2 commented on Sep 5, 2024

    @i2

    @kdeldycke IMHO, it's worth trying... nothing to lose! I'd contact them (if possible) first before PR. Sometimes that helps!

  18. added a commit that references this issue on Sep 11, 2024
  19. webknjaz commented on Mar 25, 2025

    @webknjaz

    FTR, implementing this would also help the bindep project: https://storyboard.openstack.org/#!/story/2011141.

  20. moved this to 🧐 @webknjaz's review queue 📋 in 📅 Procrastinating in public 😵‍💫on Mar 25, 2025
  21. moved this from 🧐 @webknjaz's review queue 📋 to ⏰ Review reminder needed 👀 in 📅 Procrastinating in public 😵‍💫on Nov 26, 2025
  22. webknjaz commented on Feb 26, 2026

    @webknjaz

    @kdeldycke wonder if your lib could monkey-patch this one maybe or be used in place of distro in bindep.. Have you looked into this? (I'm occasionally wanting to resurrect https://github.com/marketplace/actions/bindep)


    @nir0s have you considered moving this into @jazzband, perhaps? Jazzband is shutting down so it'd need to be a different shared org.

  23. kdeldycke commented on Feb 28, 2026

    @kdeldycke

    As of v10.0.0 (published today) my Extra Platforms project is no longer depending on distro. Now that I am free of distro legacy, we can go crazy and implement stuff there. Feel free to propose a feature request at https://github.com/kdeldycke/extra-platforms/issues !

    As for bindep, if I understand correctly, it is a tool to detect package managers right? If that's the case then look at my other Meta Package Manager project:

    $ uv run mpm managers                                  
    ╭────────────┬────────────────────────┬───────────┬────────────────────────────────────────────────────────────────────────┬────────────┬──────────────────────╮
    │ Manager ID │ Name                   │ Supported │ CLI                                                                    │ Executable │ Version              │
    ├────────────┼────────────────────────┼───────────┼────────────────────────────────────────────────────────────────────────┼────────────┼──────────────────────┤
    │ brew       │ Homebrew Formulae      │ ✓         │ ✓ /opt/homebrew/bin/brew                                               │ ✓          │ ✓ 5.0.15-65-g04ece73 │
    │ cargo      │ Rust's cargo           │ ✓         │ ✓ /opt/homebrew/bin/cargo                                              │ ✓          │ ✓ 1.93.1             │
    │ cask       │ Homebrew Cask          │ ✓         │ ✓ /opt/homebrew/bin/brew                                               │ ✓          │ ✓ 5.0.15-65-g04ece73 │
    │ composer   │ PHP's Composer         │ ✓         │ ✘ composer not found                                                   │            │                      │
    │ gem        │ Ruby Gems              │ ✓         │ ✓ /usr/bin/gem                                                         │ ✓          │ ✓ 3.4.5              │
    │ mas        │ Mac AppStore           │ ✓         │ ✓ /opt/homebrew/bin/mas                                                │ ✓          │ ✓ 5.2.0              │
    │ npm        │ Node's npm             │ ✓         │ ✘ npm not found                                                        │            │                      │
    │ pip        │ Pip                    │ ✓         │ ✓ /Users/kde/code/meta-package-manager/.venv/bin/python3               │ ✓          │ ✘                    │
    │ pipx       │ Pipx                   │ ✓         │ ✘ pipx not found                                                       │            │                      │
    │ pkg        │ FreeBSD System Manager │ ✓         │ ✘ pkg not found                                                        │            │                      │
    │ steamcmd   │ Valve Steam            │ ✓         │ ✘ steamcmd not found                                                   │            │                      │
    │ uv         │ UV                     │ ✓         │ ✓ /opt/homebrew/bin/uv                                                 │ ✓          │ ✓ 0.10.7             │
    │ uvx        │ UVX                    │ ✓         │ ✓ /opt/homebrew/bin/uv                                                 │ ✓          │ ✓ 0.10.7             │
    │ vscode     │ Visual Studio Code     │ ✓         │ ✓ /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code │ ✓          │ ✓ 1.109.5            │
    │ vscodium   │ VSCodium               │ ✓         │ ✘ codium not found                                                     │            │                      │
    │ yarn       │ Node's yarn            │ ✓         │ ✓ /opt/homebrew/bin/yarn                                               │ ✓          │ ✘                    │
    ╰────────────┴────────────────────────┴───────────┴────────────────────────────────────────────────────────────────────────┴────────────┴──────────────────────╯
    
    $ uv run mpm --output-format=json managers
    
    {
        "brew": {
            "available": true,
            "cli_path": "/opt/homebrew/bin/brew",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "brew",
            "name": "Homebrew Formulae",
            "supported": true,
            "version": "5.0.15-65-g04ece73"
        },
        "cargo": {
            "available": true,
            "cli_path": "/opt/homebrew/bin/cargo",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "cargo",
            "name": "Rust's cargo",
            "supported": true,
            "version": "1.93.1"
        },
        "cask": {
            "available": true,
            "cli_path": "/opt/homebrew/bin/brew",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "cask",
            "name": "Homebrew Cask",
            "supported": true,
            "version": "5.0.15-65-g04ece73"
        },
        "composer": {
            "available": false,
            "cli_path": null,
            "errors": [],
            "executable": false,
            "fresh": false,
            "id": "composer",
            "name": "PHP's Composer",
            "supported": true,
            "version": null
        },
        "gem": {
            "available": true,
            "cli_path": "/usr/bin/gem",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "gem",
            "name": "Ruby Gems",
            "supported": true,
            "version": "3.4.5"
        },
        "mas": {
            "available": true,
            "cli_path": "/opt/homebrew/bin/mas",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "mas",
            "name": "Mac AppStore",
            "supported": true,
            "version": "5.2.0"
        },
        "npm": {
            "available": false,
            "cli_path": null,
            "errors": [],
            "executable": false,
            "fresh": false,
            "id": "npm",
            "name": "Node's npm",
            "supported": true,
            "version": null
        },
        "pip": {
            "available": false,
            "cli_path": "/Users/kde/code/meta-package-manager/.venv/bin/python3",
            "errors": [
                "/Users/kde/code/meta-package-manager/.venv/bin/python3: No module named pip"
            ],
            "executable": true,
            "fresh": false,
            "id": "pip",
            "name": "Pip",
            "supported": true,
            "version": null
        },
        "pipx": {
            "available": false,
            "cli_path": null,
            "errors": [],
            "executable": false,
            "fresh": false,
            "id": "pipx",
            "name": "Pipx",
            "supported": true,
            "version": null
        },
        "pkg": {
            "available": false,
            "cli_path": null,
            "errors": [],
            "executable": false,
            "fresh": false,
            "id": "pkg",
            "name": "FreeBSD System Manager",
            "supported": true,
            "version": null
        },
        "steamcmd": {
            "available": false,
            "cli_path": null,
            "errors": [],
            "executable": false,
            "fresh": false,
            "id": "steamcmd",
            "name": "Valve Steam",
            "supported": true,
            "version": null
        },
        "uv": {
            "available": true,
            "cli_path": "/opt/homebrew/bin/uv",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "uv",
            "name": "UV",
            "supported": true,
            "version": "0.10.7"
        },
        "uvx": {
            "available": true,
            "cli_path": "/opt/homebrew/bin/uv",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "uvx",
            "name": "UVX",
            "supported": true,
            "version": "0.10.7"
        },
        "vscode": {
            "available": true,
            "cli_path": "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code",
            "errors": [],
            "executable": true,
            "fresh": true,
            "id": "vscode",
            "name": "Visual Studio Code",
            "supported": true,
            "version": "1.109.5"
        },
        "vscodium": {
            "available": false,
            "cli_path": null,
            "errors": [],
            "executable": false,
            "fresh": false,
            "id": "vscodium",
            "name": "VSCodium",
            "supported": true,
            "version": null
        },
        "yarn": {
            "available": false,
            "cli_path": "/opt/homebrew/bin/yarn",
            "errors": [
                "env: node: No such file or directory"
            ],
            "executable": true,
            "fresh": false,
            "id": "yarn",
            "name": "Node's yarn",
            "supported": true,
            "version": null
        }
    }
  24. johnthagen commented on Feb 28, 2026

    @johnthagen

    @kdeldycke FYI, to you and others on this thread, the fact you've chosen a GPL licence (https://github.com/kdeldycke/extra-platforms/blob/main/license) does mean that it will not a suitable for many projects that avoid all GPL dependencies.

    Thus having this support in a permissively licensed package like distro is still desirable.

  25. kdeldycke commented on Feb 28, 2026

    @kdeldycke

    @kdeldycke FYI, to you and others on this thread, the fact you've chosen a GPL licence (https://github.com/kdeldycke/extra-platforms/blob/main/license) does mean that it will not a suitable for many projects that avoid all GPL dependencies.

    Thus having this support in a permissively licensed package like distro is still desirable.

    Thanks for pointing that out. I choose that license by default a long time ago. Do you have examples of projects that can benefits from a change in licence? I am OK to change the licence if it increase adoption.

  26. kdeldycke commented on Feb 28, 2026

    @kdeldycke

    @johnthagen just created an issue at: kdeldycke/extra-platforms#488

  27. kdeldycke commented on Feb 28, 2026

    @kdeldycke

    extra-platforms 11.0.0 has just been released on PyPI under the Apache Software License 2.0: https://pypi.org/project/extra-platforms/

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions