Update __init__.py

Signed-off-by: ed <s@ocv.me>
This commit is contained in:
ed 2026-01-30 17:47:53 +00:00 committed by GitHub
parent 8418abc4ff
commit 591e959283
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,20 +17,28 @@ def nope(include_unconfigured=False):
return [] return []
try: host_os = platform.system()
S390X = os.uname().machine == "s390x" machine = platform.machine()
except: py_impl = platform.python_implementation()
S390X = False
if os.environ.get("PRTY_NO_IFADDR") or S390X or platform.python_implementation() == "GraalVM": if os.environ.get("PRTY_NO_IFADDR"):
get_adapters = nope
elif machine in ("s390x",) or host_os in ("IRIX32",):
# s390x deadlocks at libc.getifaddrs # s390x deadlocks at libc.getifaddrs
# irix libc does not have getifaddrs at all
print("ifaddr unavailable; can't determine LAN IP: unsupported OS")
get_adapters = nope
elif py_impl in ("GraalVM",):
print("ifaddr unavailable; can't determine LAN IP: unsupported interpreter")
get_adapters = nope get_adapters = nope
elif os.name == "nt": elif os.name == "nt":
from ._win32 import get_adapters from ._win32 import get_adapters
elif os.name == "posix": elif os.name == "posix":
from ._posix import get_adapters from ._posix import get_adapters
else: else:
raise RuntimeError("Unsupported Operating System: %s" % os.name) print("ifaddr unavailable; can't determine LAN IP: unsupported OS")
get_adapters = nope
__all__ = ["Adapter", "IP", "get_adapters"] __all__ = ["Adapter", "IP", "get_adapters"]