aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pw_doctor/docs.rst13
-rwxr-xr-xpw_doctor/py/pw_doctor/doctor.py28
-rwxr-xr-xpw_env_setup/py/pw_env_setup/cipd_setup/update.py15
3 files changed, 41 insertions, 15 deletions
diff --git a/pw_doctor/docs.rst b/pw_doctor/docs.rst
index 1bd65783c..6fb524e1c 100644
--- a/pw_doctor/docs.rst
+++ b/pw_doctor/docs.rst
@@ -7,10 +7,19 @@ pw_doctor
it checks that things exactly match what is expected and it checks that things
look compatible without.
-Currently pw_doctor expects the running python to be Python 3.8 or 3.9.
-
Projects that adjust the behavior of pw_env_setup may need to customize
these checks, but unfortunately this is not supported yet.
+Checks carried out by pw_doctor include:
+
+* The bootstrapped OS matches the current OS.
+* ``PW_ROOT`` is defined and points to the root of the Pigweed repo.
+* The presubmit git hook is installed.
+* The current Python version is 3.8 or 3.9.
+* The Pigweed virtual env is active.
+* CIPD is set up correctly and in use.
+* The CIPD packages required by Pigweed are up to date.
+* The platform support symlinks.
+
.. note::
The documentation for this module is currently incomplete.
diff --git a/pw_doctor/py/pw_doctor/doctor.py b/pw_doctor/py/pw_doctor/doctor.py
index f91800520..80cd93782 100755
--- a/pw_doctor/py/pw_doctor/doctor.py
+++ b/pw_doctor/py/pw_doctor/doctor.py
@@ -27,6 +27,7 @@ import tempfile
from typing import Callable, Iterable, List, Set
import pw_cli.pw_command_plugins
+import pw_env_setup.cipd_setup.update as cipd_update
def call_stdout(*args, **kwargs):
@@ -293,23 +294,26 @@ def cipd_versions(ctx: DoctorContext):
except KeyError:
return # This case is handled elsewhere.
- if 'PW_PIGWEED_CIPD_INSTALL_DIR' not in os.environ:
- ctx.error('PW_PIGWEED_CIPD_INSTALL_DIR not set')
- cipd_dir = pathlib.Path(os.environ['PW_PIGWEED_CIPD_INSTALL_DIR'])
+ if 'PW_CIPD_INSTALL_DIR' not in os.environ:
+ ctx.error('PW_CIPD_INSTALL_DIR not set')
+ cipd_dir = pathlib.Path(os.environ['PW_CIPD_INSTALL_DIR'])
- versions_path = cipd_dir / '.versions'
# Deliberately not checking luci.json--it's not required to be up-to-date.
- json_path = root.joinpath('pw_env_setup', 'py', 'pw_env_setup',
- 'cipd_setup', 'pigweed.json')
+ json_paths = (
+ root.joinpath('pw_env_setup', 'py', 'pw_env_setup', 'cipd_setup',
+ 'pigweed.json'),
+ root.joinpath('pw_env_setup', 'py', 'pw_env_setup', 'cipd_setup',
+ 'bazel.json'),
+ )
- def check_cipd(package):
+ def check_cipd(package, versions_path):
ctx.debug('checking version of %s', package['path'])
name = [
part for part in package['path'].split('/') if '{' not in part
][-1]
path = versions_path.joinpath(f'{name}.cipd_version')
if not path.is_file():
- ctx.debug('no version file')
+ ctx.debug(f'no version file for {name} at {path}')
return
with path.open() as ins:
@@ -333,8 +337,12 @@ def cipd_versions(ctx: DoctorContext):
'CIPD package %s is out of date, please rerun bootstrap',
installed['package_name'])
- for package in json.loads(json_path.read_text()).get('packages', ()):
- ctx.submit(check_cipd, package)
+ for json_path in json_paths:
+ versions_path = pathlib.Path(
+ cipd_update.package_installation_path(cipd_dir,
+ json_path)) / '.versions'
+ for package in json.loads(json_path.read_text()).get('packages', ()):
+ ctx.submit(check_cipd, package, versions_path)
@register_into(CHECKS)
diff --git a/pw_env_setup/py/pw_env_setup/cipd_setup/update.py b/pw_env_setup/py/pw_env_setup/cipd_setup/update.py
index 380ff5742..f5f544e11 100755
--- a/pw_env_setup/py/pw_env_setup/cipd_setup/update.py
+++ b/pw_env_setup/py/pw_env_setup/cipd_setup/update.py
@@ -221,6 +221,17 @@ def write_ensure_file(package_file, ensure_file):
outs.write('{} {}\n'.format(pkg['path'], ' '.join(pkg['tags'])))
+def package_installation_path(root_install_dir, package_file):
+ """Returns the package installation path.
+
+ Args:
+ root_install_dir: The CIPD installation directory.
+ package_file: The path to the .json package definition file.
+ """
+ return os.path.join(root_install_dir,
+ os.path.basename(os.path.splitext(package_file)[0]))
+
+
def update(
cipd,
package_files,
@@ -262,9 +273,7 @@ def update(
os.path.splitext(package_file)[0] + '.ensure'))
write_ensure_file(package_file, ensure_file)
- install_dir = os.path.join(
- root_install_dir,
- os.path.basename(os.path.splitext(package_file)[0]))
+ install_dir = package_installation_path(root_install_dir, package_file)
name = os.path.basename(install_dir)