mirror of
https://fuchsia.googlesource.com/third_party/pigweed.googlesource.com/pigweed/pigweed
synced 2024-09-21 06:12:09 +00:00
Add check for virtual env to doctor
Change-Id: If2aca9af65809828a8070603c618100856c6580f
This commit is contained in:
parent
7fe639d5cd
commit
3867c4f95f
|
@ -18,6 +18,7 @@ import argparse
|
|||
import logging
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -104,6 +105,27 @@ def python_version(ctx: DoctorContext):
|
|||
*actual[0:3])
|
||||
|
||||
|
||||
@register_into(CHECKS)
|
||||
def virtualenv(ctx: DoctorContext):
|
||||
"""Check that we're in the correct virtualenv."""
|
||||
try:
|
||||
venv_path = pathlib.Path(os.environ['VIRTUAL_ENV']).resolve()
|
||||
except KeyError:
|
||||
ctx.error('VIRTUAL_ENV not set')
|
||||
return
|
||||
|
||||
# When running in LUCI we might not have gone through the normal environment
|
||||
# setup process, so we need to skip the rest of this step.
|
||||
if 'LUCI_CONTEXT' in os.environ:
|
||||
return
|
||||
|
||||
root = pathlib.Path(os.environ['PW_ROOT']).resolve()
|
||||
|
||||
if root not in venv_path.parents:
|
||||
ctx.error('VIRTUAL_ENV (%s) not inside PW_ROOT (%s)', venv_path, root)
|
||||
ctx.error('\n'.join(os.environ.keys()))
|
||||
|
||||
|
||||
@register_into(CHECKS)
|
||||
def cipd(ctx: DoctorContext):
|
||||
"""Check cipd is set up correctly and in use."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user