# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)


from io import TextIOBase
from pathlib import Path
from typing import Union, Dict, Any
from ..tools import cd
import json
import logging
import os
import shlex
import shutil
import subprocess
import parmed
import pkg_resources
            import sys
    def _get_amber_env() -> Dict[str, str]:
        log.info("Using special environment variables for Amber executables")
        amber_env_stream = pkg_resources.resource_stream(
            __name__, "SimpleSim_data/amber_env.json"
        )  # type: TextIOBase
        amber_env = json.load(amber_env_stream)
        curr_env = dict(os.environ)
        curr_env.update(amber_env)
        try:
            conda_prefix = Path(curr_env["CONDA_PREFIX"])
            python_bin = conda_prefix / "bin"
        except KeyError:

            python_bin = Path(sys.executable).parent
        curr_env["PATH"] += os.pathsep + str(python_bin)
        return curr_env

    @property
    def topology(self) -> parmed.Structure:
        return self._ptop

    @property
    def directory(self) -> Path:
        return self._directory

    @property
    def name(self) -> str:
        return self._name

    def _run_in_dir(self, cl, **kwargs) -> subprocess.CompletedProcess:

# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)


# Path: paratemp/sim_setup/molecule.py
from io import TextIOBase
from pathlib import Path
from typing import Union, Dict, Any
from ..tools import cd
import json
import logging
import os
import shlex
import shutil
import subprocess
import parmed
import pkg_resources
            import sys

    def _get_amber_env() -> Dict[str, str]:
        log.info("Using special environment variables for Amber executables")
        amber_env_stream = pkg_resources.resource_stream(
            __name__, "SimpleSim_data/amber_env.json"
        )  # type: TextIOBase
        amber_env = json.load(amber_env_stream)
        curr_env = dict(os.environ)
        curr_env.update(amber_env)
        try:
            conda_prefix = Path(curr_env["CONDA_PREFIX"])
            python_bin = conda_prefix / "bin"
        except KeyError:

            python_bin = Path(sys.executable).parent
        curr_env["PATH"] += os.pathsep + str(python_bin)
        return curr_env

    @property
    def topology(self) -> parmed.Structure:
        return self._ptop

    @property
    def directory(self) -> Path:
        return self._directory

    @property
    def name(self) -> str:
        return self._name

    def _run_in_dir(self, cl, **kwargs) -> subprocess.CompletedProcess:

        with cd(self._directory):