ensure running in venv
This commit is contained in:
parent
be95c352d6
commit
a8a1f425cc
@ -82,6 +82,13 @@ PIP_HOOK = """# GENERATED BY MOMMY
|
||||
sys.exit(code)"""
|
||||
|
||||
|
||||
def assert_venv():
|
||||
if not IS_VENV:
|
||||
mommy_logger.error("mommy doesn't run in a virtual environment~")
|
||||
serious_logger.error("this has to run in a virtual environment")
|
||||
exit(1)
|
||||
|
||||
|
||||
def wrap_interpreter(path: Path):
|
||||
mommy_logger.info("mommy found a symlink to an interpreter~ %s", str(path))
|
||||
serious_logger.info("interpreter symlink found at %s", str(path))
|
||||
@ -130,6 +137,8 @@ def install_pip_hook(path: Path):
|
||||
|
||||
|
||||
def mommify_venv():
|
||||
assert_venv()
|
||||
|
||||
compile_local = False
|
||||
compiled_base_dir = VENV_DIRECTORY if compile_local else CONFIG_DIRECTORY
|
||||
compiled_config_file = compiled_base_dir / COMPILED_CONFIG_FILE_NAME
|
||||
|
@ -73,19 +73,27 @@ def _get_xdg_config_dir() -> Path:
|
||||
CONFIG_DIRECTORY = _get_xdg_config_dir() / "mommy"
|
||||
COMPILED_CONFIG_FILE_NAME = "compiled-mommy.json"
|
||||
|
||||
IS_VENV = sys.prefix != sys.base_prefix
|
||||
VENV_DIRECTORY = Path(sys.prefix)
|
||||
|
||||
def get_config_file() -> Optional[Path]:
|
||||
config_files = [
|
||||
config_files = []
|
||||
if IS_VENV:
|
||||
config_files.extend([
|
||||
VENV_DIRECTORY / "python-mommy.toml",
|
||||
VENV_DIRECTORY / "mommy.toml",
|
||||
])
|
||||
config_files.extend([
|
||||
CONFIG_DIRECTORY / "python-mommy.toml",
|
||||
CONFIG_DIRECTORY / "mommy.toml",
|
||||
]
|
||||
])
|
||||
|
||||
for f in config_files:
|
||||
if f.exists():
|
||||
return f
|
||||
|
||||
|
||||
IS_VENV = sys.prefix != sys.base_prefix
|
||||
VENV_DIRECTORY = Path(sys.prefix)
|
||||
|
||||
|
||||
def get_compiled_config_file() -> Path:
|
||||
compiled_config_files = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user