# Path: src/setuptools_scm/utils.py
# def do(cmd, cwd="."):
#     out, err, ret = do_ex(cmd, cwd)
#     if ret:
#         print(err)
#     return out
# 
# Path: src/setuptools_scm/utils.py
# def do_ex(cmd, cwd="."):
#     trace("cmd", repr(cmd))
#     trace(" in", cwd)
#     if os.name == "posix" and not isinstance(cmd, (list, tuple)):
#         cmd = shlex.split(cmd)
# 
#     p = _popen_pipes(cmd, cwd)
#     out, err = p.communicate()
#     if out:
#         trace("out", repr(out))
#     if err:
#         trace("err", repr(err))
#     if p.returncode:
#         trace("ret", p.returncode)
#     return ensure_stripped_str(out), ensure_stripped_str(err), p.returncode
# 
# Path: src/setuptools_scm/utils.py
# def require_command(name):
#     if not has_command(name, warn=False):
#         raise OSError("%r was not found" % name)


from .utils import do
from .utils import do_ex
from .utils import require_command


class Workdir:
    def __init__(self, path):
        require_command(self.COMMAND)
        self.path = path

    def do_ex(self, cmd):
        return do_ex(cmd, cwd=self.path)

    def do(self, cmd):

# Path: src/setuptools_scm/utils.py
# def do(cmd, cwd="."):
#     out, err, ret = do_ex(cmd, cwd)
#     if ret:
#         print(err)
#     return out
# 
# Path: src/setuptools_scm/utils.py
# def do_ex(cmd, cwd="."):
#     trace("cmd", repr(cmd))
#     trace(" in", cwd)
#     if os.name == "posix" and not isinstance(cmd, (list, tuple)):
#         cmd = shlex.split(cmd)
# 
#     p = _popen_pipes(cmd, cwd)
#     out, err = p.communicate()
#     if out:
#         trace("out", repr(out))
#     if err:
#         trace("err", repr(err))
#     if p.returncode:
#         trace("ret", p.returncode)
#     return ensure_stripped_str(out), ensure_stripped_str(err), p.returncode
# 
# Path: src/setuptools_scm/utils.py
# def require_command(name):
#     if not has_command(name, warn=False):
#         raise OSError("%r was not found" % name)


# Path: src/setuptools_scm/scm_workdir.py
from .utils import do
from .utils import do_ex
from .utils import require_command



class Workdir:
    def __init__(self, path):
        require_command(self.COMMAND)
        self.path = path

    def do_ex(self, cmd):
        return do_ex(cmd, cwd=self.path)

    def do(self, cmd):

        return do(cmd, cwd=self.path)