Skip to content

extra-platforms for environment detection #1612

@Fizzadar

Description

@Fizzadar

Discussed in #1563

Originally posted by kdeldycke February 26, 2026
I discovered PyInfra thanks to @wowi42's talk at FOSDEM 2026.

I maintain the extra-platforms Python package, which helps me detect architectures, platforms, shells, terminals and CI systems, and group them by family. Something I need for my various multi-platform CLIs.

extra-platforms was born out of limitations of the distro package, that PyInfra also relies on. So there is a natural filiation.

Quickly looking at PyInfra code, there is no concept of family. So you have to do write things like:

if host.get_fact(LinuxName) == "Fedora" and host.get_fact(LinuxName) == "Ubuntu" and host.get_fact(LinuxName) == "RedHat":
    hostname_file = "/etc/hostname"
elif "BSD" in host.get_fact(Os):
    hostname_file = "/etc/bsd_convention"

With extra-platforms, you can rely on family matching:

from extra_platforms import is_linux, is_bsd

if is_linux():
    hostname_file = "/etc/hostname"
elif is_bsd():
    hostname_file = "/etc/bsd_convention"

So I think extra-platforms could be a good fit for PyInfra.

And you can go deep because extra-platforms covers:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions