diff --git a/sh.py b/sh.py index 4a83a3ac..d52d8b60 100644 --- a/sh.py +++ b/sh.py @@ -27,6 +27,19 @@ from collections import deque from collections.abc import Mapping +import platform +from importlib import metadata + +try: + __version__ = metadata.version("sh") +except metadata.PackageNotFoundError: # pragma: no cover + __version__ = "unknown" + +if "windows" in platform.system().lower(): # pragma: no cover + raise ImportError( + f"sh {__version__} is currently only supported on Linux and macOS." + ) + import errno import fcntl import gc @@ -35,7 +48,6 @@ import inspect import logging import os -import platform import pty import pwd import re @@ -55,7 +67,6 @@ from asyncio import Queue as AQueue from contextlib import contextmanager from functools import partial -from importlib import metadata from io import BytesIO, StringIO, UnsupportedOperation from io import open as fdopen from locale import getpreferredencoding @@ -64,17 +75,8 @@ from types import GeneratorType, ModuleType from typing import Any, Dict, Type, Union -try: - __version__ = metadata.version("sh") -except metadata.PackageNotFoundError: # pragma: no cover - __version__ = "unknown" __project_url__ = "https://github.com/amoffat/sh" -if "windows" in platform.system().lower(): # pragma: no cover - raise ImportError( - f"sh {__version__} is currently only supported on Linux and macOS." - ) - TEE_STDOUT = {True, "out", 1} TEE_STDERR = {"err", 2}