Skip to content

Commit

Permalink
Fix using relative paths with --local-cache-dir and `--named-caches…
Browse files Browse the repository at this point in the history
…-dir`

# Rust tests will be skipped. Delete if not intended.
[ci skip-rust-tests]
  • Loading branch information
Eric-Arellano committed Jul 17, 2020
1 parent f824da3 commit 53bd1f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/python/pants/init/engine_initializer.py
Expand Up @@ -3,6 +3,7 @@

import logging
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Iterable, List, Optional, Set, Tuple, Type, cast

from pants.base.build_environment import get_buildroot
Expand Down Expand Up @@ -308,14 +309,17 @@ def build_root_singleton() -> BuildRoot:

union_rules = build_configuration.union_rules()

def ensure_absolute_path(v: str) -> str:
return Path(v).resolve().as_posix()

scheduler = Scheduler(
native=native,
ignore_patterns=pants_ignore_patterns,
use_gitignore=use_gitignore,
build_root=build_root,
local_store_dir=local_store_dir,
local_execution_root_dir=local_execution_root_dir,
named_caches_dir=named_caches_dir,
local_store_dir=ensure_absolute_path(local_store_dir),
local_execution_root_dir=ensure_absolute_path(local_execution_root_dir),
named_caches_dir=ensure_absolute_path(named_caches_dir),
rules=rules,
union_rules=union_rules,
execution_options=execution_options,
Expand Down
20 changes: 16 additions & 4 deletions src/python/pants/option/global_options.py
Expand Up @@ -667,10 +667,17 @@ def register_bootstrap_options(cls, register):
"other, or override symbols from each other.",
)

cache_instructions = (
"The path may be absolute or relative. If the directory is within the build root, be "
"sure to include it in `--pants-ignore`."
)
register(
"--local-store-dir",
advanced=True,
help="Directory to use for engine's local file store.",
help=(
f"Directory to use for the local file store, which stores the results of "
f"subprocesses run by Pants. {cache_instructions}"
),
# This default is also hard-coded into the engine's rust code in
# fs::Store::default_path so that tools using a Store outside of pants
# are likely to be able to use the same storage location.
Expand All @@ -679,14 +686,19 @@ def register_bootstrap_options(cls, register):
register(
"--local-execution-root-dir",
advanced=True,
help="Directory to use for engine's local process execution sandboxing.",
help=(
"Directory to use for local process execution sandboxing. "
f"{cache_instructions}"
),
default=tempfile.gettempdir(),
)
register(
"--named-caches-dir",
advanced=True,
help="Directory to use as the base for named global caches for processes with "
"trusted, concurrency-safe caches.",
help=(
"Directory to use for named global caches for tools and processes with trusted, "
f"concurrency-safe caches. {cache_instructions}"
),
default=os.path.join(get_pants_cachedir(), "named_caches"),
)
register(
Expand Down

0 comments on commit 53bd1f6

Please sign in to comment.