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 1fcb39c
Show file tree
Hide file tree
Showing 2 changed files with 18 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
15 changes: 11 additions & 4 deletions src/python/pants/option/global_options.py
Expand Up @@ -670,7 +670,9 @@ def register_bootstrap_options(cls, register):
register(
"--local-store-dir",
advanced=True,
help="Directory to use for engine's local file store.",
help=(
"Directory to use for engine's local file store. This may be absolute or relative."
),
# 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 +681,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 engine's local process execution sandboxing. This may be "
"absolute or relative."
),
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 as the base for named global caches for processes with trusted, "
"concurrency-safe caches. This may be absolute or relative."
),
default=os.path.join(get_pants_cachedir(), "named_caches"),
)
register(
Expand Down

0 comments on commit 1fcb39c

Please sign in to comment.