Skip to content

Commit

Permalink
Further --process-cleanup deprecation tweaks (pantsbuild#16524)
Browse files Browse the repository at this point in the history
Restores the plugin API deprecation from pantsbuild#16447, moves the deprecation start back to `2.15.0.dev1`, and bumps the deprecation end to `2.17.0.dev1`, since the flag is widely used.

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
stuhood authored and cczona committed Sep 1, 2022
1 parent b949ce5 commit 2f3a0fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/python/pants/engine/internals/options_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

from dataclasses import dataclass

from pants.base.deprecated import warn_or_error
from pants.build_graph.build_configuration import BuildConfiguration
from pants.engine.internals.session import SessionValues
from pants.engine.rules import collect_rules, rule
from pants.option.global_options import (
GlobalOptions,
KeepSandboxes,
NamedCachesDirOption,
ProcessCleanupOption,
UseDeprecatedPexBinaryRunSemanticsOption,
)
from pants.option.options import Options
Expand Down Expand Up @@ -58,6 +60,16 @@ def log_level(global_options: GlobalOptions) -> LogLevel:
return global_options.level


@rule
def extract_process_cleanup_option(keep_sandboxes: KeepSandboxes) -> ProcessCleanupOption:
warn_or_error(
removal_version="2.15.0.dev1",
entity="ProcessCleanupOption",
hint="Instead, use `KeepSandboxes`.",
)
return ProcessCleanupOption(keep_sandboxes == KeepSandboxes.never)


@rule
def extract_keep_sandboxes(global_options: GlobalOptions) -> KeepSandboxes:
return GlobalOptions.resolve_keep_sandboxes(global_options.options)
Expand Down
19 changes: 12 additions & 7 deletions src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
is_in_container,
pants_version,
)
from pants.base.deprecated import deprecated_conditional, resolve_conflicting_options, warn_or_error
from pants.base.deprecated import deprecated_conditional, resolve_conflicting_options
from pants.base.glob_match_error_behavior import GlobMatchErrorBehavior
from pants.engine.environment import CompleteEnvironment
from pants.engine.internals.native_engine import PyExecutor
Expand Down Expand Up @@ -1158,7 +1158,7 @@ class BootstrapOptions:
process_cleanup = BoolOption(
default=(DEFAULT_EXECUTION_OPTIONS.keep_sandboxes == KeepSandboxes.never),
deprecation_start_version="2.15.0.dev1",
removal_version="2.16.0.dev1",
removal_version="2.17.0.dev1",
removal_hint="Use the `keep_sandboxes` option instead.",
help=softwrap(
"""
Expand Down Expand Up @@ -1935,11 +1935,6 @@ def resolve_keep_sandboxes(

if isinstance(resolved_value, bool):
# Is `process_cleanup`.
warn_or_error(
removal_version="2.15.0.dev1",
entity="--process-cleanup",
hint="Instead, use `--keep-sandboxes`.",
)
return KeepSandboxes.never if resolved_value else KeepSandboxes.always
elif isinstance(resolved_value, KeepSandboxes):
return resolved_value
Expand Down Expand Up @@ -2038,6 +2033,16 @@ def create(cls, GlobalOptionsType: type[GlobalOptions]) -> GlobalOptionsFlags:
return cls(FrozenOrderedSet(flags), FrozenOrderedSet(short_flags))


@dataclass(frozen=True)
class ProcessCleanupOption:
"""A wrapper around the global option `process_cleanup`.
Prefer to use this rather than requesting `GlobalOptions` for more precise invalidation.
"""

val: bool


@dataclass(frozen=True)
class NamedCachesDirOption:
"""A wrapper around the global option `named_caches_dir`.
Expand Down

0 comments on commit 2f3a0fa

Please sign in to comment.