From 5078e0ff3ece544b357462e59726723509db3adc Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Mon, 20 Jul 2020 09:20:06 -0700 Subject: [PATCH] Delete unused v1 sources. Also, removes superfluous fingerprint=True option kwargs. [ci skip-rust-tests] --- src/python/pants/auth/cookies.py | 1 - .../backend/native/subsystems/libc_dev.py | 3 - .../native/subsystems/xcode_cli_tools.py | 1 - src/python/pants/backend/project_info/cloc.py | 5 +- .../pants/backend/python/python_artifact.py | 8 +- .../pants/backend/python/subsystems/pytest.py | 7 +- .../python/subsystems/python_native_code.py | 2 - .../python/subsystems/python_tool_base.py | 4 - .../subsystems/subprocess_environment.py | 2 - .../pants/backend/python/target_types.py | 1 - src/python/pants/base/fingerprint_strategy.py | 66 ------ src/python/pants/base/payload.py | 154 -------------- src/python/pants/base/payload_field.py | 200 ------------------ src/python/pants/core/goals/repl.py | 1 - src/python/pants/core/goals/run.py | 1 - .../pants/core/util_rules/external_tool.py | 1 - .../option/compiler_option_sets_mixin.py | 3 - src/python/pants/python/pex_build_util.py | 2 - src/python/pants/python/python_repos.py | 2 - src/python/pants/python/python_setup.py | 6 - src/python/pants/python/setup_py_runner.py | 2 - src/python/pants/source/source_root.py | 3 - .../base/test_fingerprint_strategy.py | 22 -- tests/python/pants_test/base/test_payload.py | 74 ------- .../pants_test/base/test_payload_field.py | 101 --------- 25 files changed, 3 insertions(+), 669 deletions(-) delete mode 100644 src/python/pants/base/fingerprint_strategy.py delete mode 100644 src/python/pants/base/payload.py delete mode 100644 src/python/pants/base/payload_field.py delete mode 100644 tests/python/pants_test/base/test_fingerprint_strategy.py delete mode 100644 tests/python/pants_test/base/test_payload.py delete mode 100644 tests/python/pants_test/base/test_payload_field.py diff --git a/src/python/pants/auth/cookies.py b/src/python/pants/auth/cookies.py index 50c864e87ea..9ca43957290 100644 --- a/src/python/pants/auth/cookies.py +++ b/src/python/pants/auth/cookies.py @@ -21,7 +21,6 @@ def register_options(cls, register): register( "--path", advanced=True, - fingerprint=True, default=os.path.join(register.bootstrap.pants_bootstrapdir, "auth", "cookies"), help="Path to file that stores persistent cookies. " "Defaults to /auth/cookies.", diff --git a/src/python/pants/backend/native/subsystems/libc_dev.py b/src/python/pants/backend/native/subsystems/libc_dev.py index 2550f0211d5..f6ea0dc395c 100644 --- a/src/python/pants/backend/native/subsystems/libc_dev.py +++ b/src/python/pants/backend/native/subsystems/libc_dev.py @@ -46,7 +46,6 @@ def register_options(cls, register): "--enable-libc-search", type=bool, default=False, - fingerprint=True, advanced=True, help="Whether to search for the host's libc installation. Set to False if the host " "does not have a libc install with crti.o -- this file is necessary to create " @@ -56,7 +55,6 @@ def register_options(cls, register): "--libc-dir", type=dir_option, default=None, - fingerprint=True, advanced=True, help="A directory containing a host-specific crti.o from libc.", ) @@ -64,7 +62,6 @@ def register_options(cls, register): "--host-compiler", type=str, default="gcc", - fingerprint=True, advanced=True, help="The host compiler to invoke with -print-search-dirs to find the host libc.", ) diff --git a/src/python/pants/backend/native/subsystems/xcode_cli_tools.py b/src/python/pants/backend/native/subsystems/xcode_cli_tools.py index 686b3dc186c..5ffb8c26171 100644 --- a/src/python/pants/backend/native/subsystems/xcode_cli_tools.py +++ b/src/python/pants/backend/native/subsystems/xcode_cli_tools.py @@ -60,7 +60,6 @@ def register_options(cls, register): "--install-prefixes", type=list, default=cls.INSTALL_PREFIXES_DEFAULT, - fingerprint=True, advanced=True, help="Locations to search for resources from the XCode CLI tools, including a " "compiler, linker, header files, and some libraries. " diff --git a/src/python/pants/backend/project_info/cloc.py b/src/python/pants/backend/project_info/cloc.py index 490ca0f58b7..54205a53eb1 100644 --- a/src/python/pants/backend/project_info/cloc.py +++ b/src/python/pants/backend/project_info/cloc.py @@ -66,10 +66,7 @@ class CountLinesOfCodeOptions(GoalSubsystem): def register_options(cls, register) -> None: super().register_options(register) register( - "--ignored", - type=bool, - fingerprint=True, - help="Show information about files ignored by cloc.", + "--ignored", type=bool, help="Show information about files ignored by cloc.", ) diff --git a/src/python/pants/backend/python/python_artifact.py b/src/python/pants/backend/python/python_artifact.py index 5776e916069..307c7f5c7d6 100644 --- a/src/python/pants/backend/python/python_artifact.py +++ b/src/python/pants/backend/python/python_artifact.py @@ -1,11 +1,8 @@ # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). -from pants.base.hash_utils import stable_json_sha1 -from pants.base.payload_field import PayloadField - -class PythonArtifact(PayloadField): +class PythonArtifact: """Represents a Python setup.py-based project.""" class MissingArgument(Exception): @@ -66,9 +63,6 @@ def binaries(self): def __str__(self): return self.name - def _compute_fingerprint(self): - return stable_json_sha1((self._kw, self._binaries)) - def with_binaries(self, *args, **kw): """Add binaries tagged to this artifact. diff --git a/src/python/pants/backend/python/subsystems/pytest.py b/src/python/pants/backend/python/subsystems/pytest.py index 968eb00ed73..6d0619db7d5 100644 --- a/src/python/pants/backend/python/subsystems/pytest.py +++ b/src/python/pants/backend/python/subsystems/pytest.py @@ -19,20 +19,15 @@ def register_options(cls, register): "--args", type=list, member_type=shell_str, - fingerprint=True, passthrough=True, help='Arguments to pass directly to Pytest, e.g. `--pytest-args="-k test_foo --quiet"`', ) register( - "--version", - default="pytest>=5.3.5,<5.4", - fingerprint=True, - help="Requirement string for Pytest.", + "--version", default="pytest>=5.3.5,<5.4", help="Requirement string for Pytest.", ) register( "--pytest-plugins", type=list, - fingerprint=True, default=[ "pytest-timeout>=1.3.4,<1.4", "pytest-cov>=2.8.1,<2.9", diff --git a/src/python/pants/backend/python/subsystems/python_native_code.py b/src/python/pants/backend/python/subsystems/python_native_code.py index 55601f64803..339569bdad5 100644 --- a/src/python/pants/backend/python/subsystems/python_native_code.py +++ b/src/python/pants/backend/python/subsystems/python_native_code.py @@ -23,7 +23,6 @@ def register_options(cls, register): "--cpp-flags", type=list, default=safe_shlex_split(os.environ.get("CPPFLAGS", "")), - fingerprint=True, advanced=True, help="Override the `CPPFLAGS` environment variable for any forked subprocesses.", ) @@ -31,7 +30,6 @@ def register_options(cls, register): "--ld-flags", type=list, default=safe_shlex_split(os.environ.get("LDFLAGS", "")), - fingerprint=True, advanced=True, help="Override the `LDFLAGS` environment variable for any forked subprocesses.", ) diff --git a/src/python/pants/backend/python/subsystems/python_tool_base.py b/src/python/pants/backend/python/subsystems/python_tool_base.py index 761564a21e7..da81c47e3cb 100644 --- a/src/python/pants/backend/python/subsystems/python_tool_base.py +++ b/src/python/pants/backend/python/subsystems/python_tool_base.py @@ -23,7 +23,6 @@ def register_options(cls, register): "--version", type=str, advanced=True, - fingerprint=True, default=cls.default_version, help="Requirement string for the tool.", ) @@ -32,7 +31,6 @@ def register_options(cls, register): type=list, member_type=str, advanced=True, - fingerprint=True, default=cls.default_extra_requirements, help="Any additional requirement strings to use with the tool. This is useful if the " "tool allows you to install plugins or if you need to constrain a dependency to " @@ -42,7 +40,6 @@ def register_options(cls, register): "--interpreter-constraints", type=list, advanced=True, - fingerprint=True, default=cls.default_interpreter_constraints, help="Python interpreter constraints for this tool. An empty list uses the default " "interpreter constraints for the repo.", @@ -51,7 +48,6 @@ def register_options(cls, register): "--entry-point", type=str, advanced=True, - fingerprint=True, default=cls.default_entry_point, help="The main module for the tool. If unspecified, the code using this tool " "must provide it explicitly on invocation, or it can use the tool as a " diff --git a/src/python/pants/backend/python/subsystems/subprocess_environment.py b/src/python/pants/backend/python/subsystems/subprocess_environment.py index 23732b95bd6..7cc13a1bcb6 100644 --- a/src/python/pants/backend/python/subsystems/subprocess_environment.py +++ b/src/python/pants/backend/python/subsystems/subprocess_environment.py @@ -22,14 +22,12 @@ def register_options(cls, register): register( "--lang", default=os.environ.get("LANG"), - fingerprint=True, advanced=True, help="Override the `LANG` environment variable for any forked subprocesses.", ) register( "--lc-all", default=os.environ.get("LC_ALL"), - fingerprint=True, advanced=True, help="Override the `LC_ALL` environment variable for any forked subprocesses.", ) diff --git a/src/python/pants/backend/python/target_types.py b/src/python/pants/backend/python/target_types.py index 56f33710ddb..47890c5428c 100644 --- a/src/python/pants/backend/python/target_types.py +++ b/src/python/pants/backend/python/target_types.py @@ -101,7 +101,6 @@ def register_options(cls, register): advanced=True, type=bool, default=True, - fingerprint=True, help=( "Whether built PEX binaries should emit pex warnings at runtime by default. " "Can be over-ridden by specifying the `emit_warnings` parameter of individual " diff --git a/src/python/pants/base/fingerprint_strategy.py b/src/python/pants/base/fingerprint_strategy.py deleted file mode 100644 index a92a2680065..00000000000 --- a/src/python/pants/base/fingerprint_strategy.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -import logging -from abc import ABC, abstractmethod - -logger = logging.getLogger(__name__) - - -class DefaultFingerprintHashingMixin: - """Default definitions for __hash__ and __eq__. - - Warning: Don't use this when the mixed in class has instance attributes mixed into its - fingerprints. This will cause subtle bugs because fingerprints are cached on the Target - base class, and the cache key is the instance of the FingerprintStrategy. - """ - - def __hash__(self): - return hash(type(self)) - - def __eq__(self, other): - return type(self) == type(other) - - -class FingerprintStrategy(ABC): - """A helper object for doing per-task, finer grained invalidation of Targets.""" - - @abstractmethod - def compute_fingerprint(self, target): - """Subclasses override this method to actually compute the Task specific fingerprint.""" - - def fingerprint_target(self, target): - """Consumers of subclass instances call this to get a fingerprint labeled with the name.""" - fingerprint = self.compute_fingerprint(target) - if fingerprint: - return "{fingerprint}-{name}".format(fingerprint=fingerprint, name=type(self).__name__) - else: - return None - - def direct(self, target): - return False - - def dependencies(self, target): - return target.dependencies - - @abstractmethod - def __hash__(self): - """Subclasses must implement a hash so computed fingerprints can be safely memoized.""" - - @abstractmethod - def __eq__(self, other): - """Subclasses must implement an equality check so computed fingerprints can be safely - memoized.""" - - -class DefaultFingerprintStrategy(DefaultFingerprintHashingMixin, FingerprintStrategy): - """The default FingerprintStrategy, which delegates to target.payload.fingerprint(). - - :API: public - """ - - def compute_fingerprint(self, target): - """ - :API: public - """ - return target.payload.fingerprint() diff --git a/src/python/pants/base/payload.py b/src/python/pants/base/payload.py deleted file mode 100644 index c26cc268192..00000000000 --- a/src/python/pants/base/payload.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from hashlib import sha1 - -from pants.util.strutil import ensure_binary - - -class PayloadFieldAlreadyDefinedError(Exception): - pass - - -class PayloadFrozenError(Exception): - pass - - -class Payload: - """A mapping from field names to PayloadField instances. - - A Target will add PayloadFields to its Payload until instantiation is finished, at which point - freeze() will be called and make the Payload immutable. - - :API: public - """ - - def __init__(self): - self._fields = {} - self._frozen = False - self._fingerprint_memo_map = {} - - @property - def fields(self): - return list(self._fields.items()) - - def as_dict(self): - """Return the Payload object as a dict.""" - return {k: self.get_field_value(k) for k in self._fields} - - def freeze(self): - """Permanently make this Payload instance immutable. - - No more fields can be added after calling freeze(). - - :API: public - """ - self._frozen = True - - def get_field(self, key, default=None): - """An alternative to attribute access for duck typing Payload instances. - - Has the same semantics as dict.get, and in fact just delegates to the underlying field mapping. - - :API: public - """ - return self._fields.get(key, default) - - def get_field_value(self, key, default=None): - """Retrieves the value in the payload field if the field exists, otherwise returns the - default. - - :API: public - """ - if key in self._fields: - payload_field = self._fields[key] - if payload_field: - return payload_field.value - return default - - def add_fields(self, field_dict): - """Add a mapping of field names to PayloadField instances. - - :API: public - """ - for key, field in field_dict.items(): - self.add_field(key, field) - - def add_field(self, key, field): - """Add a field to the Payload. - - :API: public - - :param string key: The key for the field. Fields can be accessed using attribute access as - well as `get_field` using `key`. - :param PayloadField field: A PayloadField instance. None is an allowable value for `field`, - in which case it will be skipped during hashing. - """ - if key in self._fields: - raise PayloadFieldAlreadyDefinedError( - "Key {key} is already set on this payload. The existing field was {existing_field}." - " Tried to set new field {field}.".format( - key=key, existing_field=self._fields[key], field=field - ) - ) - elif self._frozen: - raise PayloadFrozenError( - "Payload is frozen, field with key {key} cannot be added to it.".format(key=key) - ) - else: - self._fields[key] = field - self._fingerprint_memo = None - - def fingerprint(self, field_keys=None): - """A memoizing fingerprint that rolls together the fingerprints of underlying PayloadFields. - - If no fields were hashed (or all fields opted out of being hashed by returning `None`), then - `fingerprint()` also returns `None`. - - :param iterable field_keys: A subset of fields to use for the fingerprint. Defaults - to all fields. - """ - field_keys = frozenset(field_keys or self._fields.keys()) - if field_keys not in self._fingerprint_memo_map: - self._fingerprint_memo_map[field_keys] = self._compute_fingerprint(field_keys) - return self._fingerprint_memo_map[field_keys] - - def _compute_fingerprint(self, field_keys): - hasher = sha1() - empty_hash = True - for key in sorted(field_keys): - field = self._fields[key] - if field is not None: - fp = field.fingerprint() - if fp is not None: - empty_hash = False - fp = ensure_binary(fp) - key = ensure_binary(key) - key_sha1 = sha1(key).hexdigest().encode() - hasher.update(key_sha1) - hasher.update(fp) - if empty_hash: - return None - else: - return hasher.hexdigest() - - def mark_dirty(self): - """Invalidates memoized fingerprints for this payload. - - Exposed for testing. - - :API: public - """ - self._fingerprint_memo_map = {} - for field in self._fields.values(): - field.mark_dirty() - - def __getattr__(self, attr): - try: - field = self._fields[attr] - except KeyError: - raise AttributeError(attr) - if field is not None: - return field.value - else: - return None diff --git a/src/python/pants/base/payload_field.py b/src/python/pants/base/payload_field.py deleted file mode 100644 index e8a2189d9cb..00000000000 --- a/src/python/pants/base/payload_field.py +++ /dev/null @@ -1,200 +0,0 @@ -# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from abc import ABC, abstractmethod -from collections.abc import Sequence -from hashlib import sha1 -from typing import ClassVar, Optional - -from pants.base.hash_utils import stable_json_sha1 -from pants.util.ordered_set import OrderedSet -from pants.util.strutil import ensure_binary - - -def combine_hashes(hashes): - """A simple helper function to combine other hashes. - - Sorts the hashes before rolling them in. - """ - hasher = sha1() - for h in sorted(hashes): - h = ensure_binary(h) - hasher.update(h) - return hasher.hexdigest() - - -class PayloadField(ABC): - """An immutable, hashable structure to be mixed into Payload instances. - - :API: public - """ - - _fingerprint_memo: ClassVar[Optional[str]] = None - - def fingerprint(self): - """A memoized sha1 hexdigest hashing the contents of this PayloadField. - - The fingerprint returns either a string or None. If the return is None, consumers of the - fingerprint may choose to elide this PayloadField from their combined hash computation. - - :API: public - """ - if self._fingerprint_memo is None: - self._fingerprint_memo = self._compute_fingerprint() - return self._fingerprint_memo - - def mark_dirty(self): - """Invalidates the memoized fingerprint for this field. - - Exposed for testing. - - :API: public - """ - self._fingerprint_memo = None - - @abstractmethod - def _compute_fingerprint(self): - """This method will be called and the result memoized for ``PayloadField.fingerprint``.""" - pass - - @property - def value(self): - """ - :API: public - """ - return self - - -class FingerprintedMixin: - """Mixin this class to make your class suitable for passing to FingerprintedField. - - :API: public - """ - - def fingerprint(self): - """Override this method to implement a fingerprint for your class. - - :API: public - - :returns: a sha1 hexdigest hashing the contents of this structure. - """ - raise NotImplementedError() - - -class FingerprintedField(PayloadField): - """Use this field to fingerprint any class that mixes in FingerprintedMixin. - - The caller must ensure that the class properly implements fingerprint() - to hash the contents of the object. - - :API: public - """ - - def __init__(self, value): - self._value = value - - def _compute_fingerprint(self): - return self._value.fingerprint() - - @property - def value(self): - return self._value - - -class PythonRequirementsField(frozenset, PayloadField): - """A frozenset subclass that mixes in PayloadField. - - Must be initialized with an iterable of PythonRequirement instances. - - :API: public - """ - - def _compute_fingerprint(self): - def fingerprint_iter(): - for req in self: - hash_items = ( - repr(req._requirement), - req._repository, - req._name, - req._use_2to3, - req.compatibility, - ) - yield stable_json_sha1(hash_items) - - return combine_hashes(fingerprint_iter()) - - -class ExcludesField(OrderedSet, PayloadField): - """An OrderedSet subclass that mixes in PayloadField. - - Must be initialized with an iterable of Excludes instances. - - :API: public - """ - - def __eq__(self, other): - # NB: Our `pants.util.ordered_set` has strict `__eq__` semantics for the sake of sanity - # with the engine. This is different than the original Twitter Common's implementation at - # https://github.com/twitter-archive/commons/blob/master/src/python/twitter/common/collections/orderedset.py. - # Here, we override `__eq__` to use a tweak on the original Twitter Common's implementation - # as this is V1 code so we are okay with the looser equality. - if other is None: - return False - if isinstance(other, Sequence): - return len(self) == len(other) and list(self) == list(other) - return set(self) == set(other) - - def _compute_fingerprint(self): - return stable_json_sha1(tuple(repr(exclude) for exclude in self)) - - -class JarsField(tuple, PayloadField): - """A tuple subclass that mixes in PayloadField. - - Must be initialized with an iterable of JarDependency instances. - - :API: public - """ - - def _compute_fingerprint(self): - return stable_json_sha1(tuple(jar.cache_key() for jar in self)) - - -class PrimitiveField(PayloadField): - """A general field for primitive types. - - As long as the contents are JSON representable, their hash can be stably inferred. - - :API: public - """ - - def __init__(self, underlying=None): - self._underlying = underlying - - @property - def value(self): - return self._underlying - - def _compute_fingerprint(self): - return stable_json_sha1(self._underlying) - - -class PrimitivesSetField(PayloadField): - """A general field for order-insensitive sets of primitive, ordered types. - - As long as the underlying elements are JSON representable and have a consistent sort order, - their hash can be stably inferred. An underlying value of `None` is preserved to allow for - "unset" fields: to default to an empty list/set instead, pass one to the constructor. - - :API: public - """ - - def __init__(self, underlying=None): - self._underlying = tuple(sorted(set(underlying))) if underlying is not None else None - - @property - def value(self): - return self._underlying - - def _compute_fingerprint(self): - return stable_json_sha1(self._underlying) diff --git a/src/python/pants/core/goals/repl.py b/src/python/pants/core/goals/repl.py index 14be802804a..e0810990dad 100644 --- a/src/python/pants/core/goals/repl.py +++ b/src/python/pants/core/goals/repl.py @@ -48,7 +48,6 @@ def register_options(cls, register) -> None: "--shell", type=str, default=None, - fingerprint=True, help="Override the automatically-detected REPL program for the target(s) specified. ", ) diff --git a/src/python/pants/core/goals/run.py b/src/python/pants/core/goals/run.py index 76cd4f76ff8..2bb0470a235 100644 --- a/src/python/pants/core/goals/run.py +++ b/src/python/pants/core/goals/run.py @@ -36,7 +36,6 @@ def register_options(cls, register) -> None: "--args", type=list, member_type=shell_str, - fingerprint=True, passthrough=True, help="Arguments to pass directly to the executed target, e.g. " '`--run-args="val1 val2 --debug"`', diff --git a/src/python/pants/core/util_rules/external_tool.py b/src/python/pants/core/util_rules/external_tool.py index 0f91d352957..c59ff3b6ad5 100644 --- a/src/python/pants/core/util_rules/external_tool.py +++ b/src/python/pants/core/util_rules/external_tool.py @@ -95,7 +95,6 @@ def register_options(cls, register): type=str, default=cls.default_version, advanced=True, - fingerprint=True, help=f"Use this version of {cls.name}.", ) diff --git a/src/python/pants/option/compiler_option_sets_mixin.py b/src/python/pants/option/compiler_option_sets_mixin.py index 76b5c4b0ccb..71e9a939545 100644 --- a/src/python/pants/option/compiler_option_sets_mixin.py +++ b/src/python/pants/option/compiler_option_sets_mixin.py @@ -18,7 +18,6 @@ def register_options(cls, register): "--compiler-option-sets-enabled-args", advanced=True, type=dict, - fingerprint=True, default=cls.get_compiler_option_sets_enabled_default_value, help="Extra compiler args to use for each enabled option set.", ) @@ -26,7 +25,6 @@ def register_options(cls, register): "--compiler-option-sets-disabled-args", advanced=True, type=dict, - fingerprint=True, default=cls.get_compiler_option_sets_disabled_default_value, help="Extra compiler args to use for each disabled option set.", ) @@ -34,7 +32,6 @@ def register_options(cls, register): "--default-compiler-option-sets", advanced=True, type=list, - fingerprint=True, default=cls.get_default_compiler_option_sets, help="The compiler_option_sets to use for targets which don't declare any.", ) diff --git a/src/python/pants/python/pex_build_util.py b/src/python/pants/python/pex_build_util.py index b97a1d89a17..6214514a74f 100644 --- a/src/python/pants/python/pex_build_util.py +++ b/src/python/pants/python/pex_build_util.py @@ -64,7 +64,6 @@ def register_options(cls, register): "--setuptools-version", advanced=True, default="40.6.3", - fingerprint=True, help="The setuptools version to include in the pex if namespace packages need " "to be injected.", ) @@ -72,7 +71,6 @@ def register_options(cls, register): "--pex-version", advanced=True, default=pex_version, - fingerprint=True, help="The pex version to include in any generated ipex files. " "NOTE: This should ideally be the same as the pex version which pants " f"itself depends on, which right now is {pex_version}.", diff --git a/src/python/pants/python/python_repos.py b/src/python/pants/python/python_repos.py index d9c2d281036..6f6d8c22493 100644 --- a/src/python/pants/python/python_repos.py +++ b/src/python/pants/python/python_repos.py @@ -22,7 +22,6 @@ def register_options(cls, register): advanced=True, type=list, default=[], - fingerprint=True, help=( "URLs of code repositories to look for requirements. In Pip and Pex, this option " "corresponds to the `--find-links` option." @@ -32,7 +31,6 @@ def register_options(cls, register): "--indexes", advanced=True, type=list, - fingerprint=True, default=["https://pypi.org/simple/"], help=( "URLs of code repository indexes to look for requirements. If set to an empty " diff --git a/src/python/pants/python/python_setup.py b/src/python/pants/python/python_setup.py index ecad2f8afe9..d4454435364 100644 --- a/src/python/pants/python/python_setup.py +++ b/src/python/pants/python/python_setup.py @@ -28,7 +28,6 @@ def register_options(cls, register): register( "--interpreter-constraints", advanced=True, - fingerprint=True, type=list, default=["CPython>=3.6"], metavar="", @@ -41,7 +40,6 @@ def register_options(cls, register): register( "--requirement-constraints", advanced=True, - fingerprint=True, type=file_option, help=( "When resolving third-party requirements, use this " @@ -56,7 +54,6 @@ def register_options(cls, register): type=list, metavar="", default=["current"], - fingerprint=True, help="A list of platforms to be supported by this Python environment. Each platform" "is a string, as returned by pkg_resources.get_supported_platform().", ) @@ -89,7 +86,6 @@ def register_options(cls, register): advanced=True, type=bool, default=UnsetBool, - fingerprint=True, help="Whether to include pre-releases when resolving requirements.", ) register( @@ -110,7 +106,6 @@ def register_options(cls, register): advanced=True, type=str, default="manylinux2014", - fingerprint=True, help="Whether to allow resolution of manylinux wheels when resolving requirements for " "foreign linux platforms. The value should be a manylinux platform upper bound, " "e.g.: manylinux2010, or else [Ff]alse, [Nn]o or [Nn]one to disallow.", @@ -120,7 +115,6 @@ def register_options(cls, register): type=int, default=None, advanced=True, - fingerprint=True, help="The maximum number of concurrent jobs to resolve wheels with.", ) diff --git a/src/python/pants/python/setup_py_runner.py b/src/python/pants/python/setup_py_runner.py index 28c45d9973c..bd4b1bb1839 100644 --- a/src/python/pants/python/setup_py_runner.py +++ b/src/python/pants/python/setup_py_runner.py @@ -33,14 +33,12 @@ def register_options(cls, register: Callable[..., None]) -> None: register( "--setuptools-version", advanced=True, - fingerprint=True, default="44.0.0", help="The setuptools version to use when executing `setup.py` scripts.", ) register( "--wheel-version", advanced=True, - fingerprint=True, default="0.34.2", help="The wheel version to use when executing `setup.py` scripts.", ) diff --git a/src/python/pants/source/source_root.py b/src/python/pants/source/source_root.py index 0f4bdaf9cde..09a088e163c 100644 --- a/src/python/pants/source/source_root.py +++ b/src/python/pants/source/source_root.py @@ -152,7 +152,6 @@ def register_options(cls, register): choices=["create", "fail"], default="create", advanced=True, - fingerprint=True, help="Configures the behavior when sources are defined outside of any configured " "source root. `create` will cause a source root to be implicitly created at " "the definition location of the sources; `fail` will trigger an error.", @@ -162,7 +161,6 @@ def register_options(cls, register): "--root-patterns", metavar='["pattern1", "pattern2", ...]', type=list, - fingerprint=True, default=cls.DEFAULT_ROOT_PATTERNS, advanced=True, help="A list of source root suffixes. A directory with this suffix will be considered " @@ -180,7 +178,6 @@ def register_options(cls, register): metavar="filename", type=list, member_type=str, - fingerprint=True, default=None, advanced=True, help="The presence of a file of this name in a directory indicates that the directory " diff --git a/tests/python/pants_test/base/test_fingerprint_strategy.py b/tests/python/pants_test/base/test_fingerprint_strategy.py deleted file mode 100644 index 717bc9b12cf..00000000000 --- a/tests/python/pants_test/base/test_fingerprint_strategy.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.base.fingerprint_strategy import DefaultFingerprintStrategy -from pants.testutil.test_base import TestBase - - -class FingerprintStrategyTest(TestBase): - def test_subclass_equality(self): - class FPStrategyA(DefaultFingerprintStrategy): - pass - - class FPStrategyB(DefaultFingerprintStrategy): - pass - - self.assertNotEqual(FPStrategyA(), DefaultFingerprintStrategy()) - self.assertNotEqual(FPStrategyA(), FPStrategyB()) - self.assertEqual(FPStrategyA(), FPStrategyA()) - - self.assertNotEqual(hash(FPStrategyA()), hash(DefaultFingerprintStrategy())) - self.assertNotEqual(hash(FPStrategyA()), hash(FPStrategyB())) - self.assertEqual(hash(FPStrategyA()), hash(FPStrategyA())) diff --git a/tests/python/pants_test/base/test_payload.py b/tests/python/pants_test/base/test_payload.py deleted file mode 100644 index a3085fb62a5..00000000000 --- a/tests/python/pants_test/base/test_payload.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from pants.base.payload import Payload, PayloadFieldAlreadyDefinedError, PayloadFrozenError -from pants.base.payload_field import PrimitiveField -from pants.testutil.test_base import TestBase - - -class PayloadTest(TestBase): - def test_freeze(self): - payload = Payload() - payload.add_field("foo", PrimitiveField()) - payload.freeze() - with self.assertRaises(PayloadFrozenError): - payload.add_field("bar", PrimitiveField()) - - def test_field_duplication(self): - payload = Payload() - payload.add_field("foo", PrimitiveField()) - payload.freeze() - with self.assertRaises(PayloadFieldAlreadyDefinedError): - payload.add_field("foo", PrimitiveField()) - - def test_fingerprint(self): - payload = Payload() - payload.add_field("foo", PrimitiveField()) - fingerprint1 = payload.fingerprint() - self.assertEqual(fingerprint1, payload.fingerprint()) - payload.add_field("bar", PrimitiveField()) - fingerprint2 = payload.fingerprint() - self.assertNotEqual(fingerprint1, fingerprint2) - self.assertEqual(fingerprint2, payload.fingerprint()) - payload.freeze() - self.assertEqual(fingerprint2, payload.fingerprint()) - - def test_partial_fingerprint(self): - payload = Payload() - payload.add_field("foo", PrimitiveField()) - fingerprint1 = payload.fingerprint() - self.assertEqual(fingerprint1, payload.fingerprint(field_keys=("foo",))) - payload.add_field("bar", PrimitiveField()) - fingerprint2 = payload.fingerprint() - self.assertEqual(fingerprint1, payload.fingerprint(field_keys=("foo",))) - self.assertNotEqual(fingerprint2, payload.fingerprint(field_keys=("foo",))) - self.assertNotEqual(fingerprint2, payload.fingerprint(field_keys=("bar",))) - self.assertEqual(fingerprint2, payload.fingerprint(field_keys=("bar", "foo"))) - - def test_none(self): - payload = Payload() - payload.add_field("foo", None) - payload2 = Payload() - payload2.add_field("foo", PrimitiveField(None)) - self.assertNotEqual(payload.fingerprint(), payload2.fingerprint()) - - def test_missing_payload_field(self): - payload = Payload() - payload.add_field("foo", PrimitiveField("test-value")) - payload.add_field("bar", PrimitiveField(None)) - self.assertEqual("test-value", payload.foo) - self.assertEqual("test-value", payload.get_field("foo").value) - self.assertEqual("test-value", payload.get_field_value("foo")) - self.assertEqual(None, payload.bar) - self.assertEqual(None, payload.get_field("bar").value) - self.assertEqual(None, payload.get_field_value("bar")) - self.assertEqual(None, payload.get_field("bar", default="nothing").value) - self.assertEqual(None, payload.get_field_value("bar", default="nothing")) - with self.assertRaises(AttributeError): - self.assertEqual(None, payload.field_doesnt_exist) - self.assertEqual(None, payload.get_field("field_doesnt_exist")) - self.assertEqual(None, payload.get_field_value("field_doesnt_exist")) - self.assertEqual("nothing", payload.get_field("field_doesnt_exist", default="nothing")) - self.assertEqual( - "nothing", payload.get_field_value("field_doesnt_exist", default="nothing") - ) diff --git a/tests/python/pants_test/base/test_payload_field.py b/tests/python/pants_test/base/test_payload_field.py deleted file mode 100644 index 214f85f2d7e..00000000000 --- a/tests/python/pants_test/base/test_payload_field.py +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from hashlib import sha1 - -from pants.base.payload_field import ( - FingerprintedField, - FingerprintedMixin, - PrimitiveField, - PrimitivesSetField, - PythonRequirementsField, -) -from pants.python.python_requirement import PythonRequirement -from pants.testutil.test_base import TestBase -from pants.util.strutil import ensure_binary - - -class PayloadTest(TestBase): - def test_python_requirements_field(self): - req1 = PythonRequirement("foo==1.0") - req2 = PythonRequirement("bar==1.0") - - self.assertNotEqual( - PythonRequirementsField([req1]).fingerprint(), - PythonRequirementsField([req2]).fingerprint(), - ) - - def test_primitive_field(self): - self.assertEqual( - PrimitiveField({"foo": "bar"}).fingerprint(), - PrimitiveField({"foo": "bar"}).fingerprint(), - ) - self.assertEqual( - PrimitiveField(["foo", "bar"]).fingerprint(), - PrimitiveField(("foo", "bar")).fingerprint(), - ) - self.assertEqual( - PrimitiveField(["foo", "bar"]).fingerprint(), - PrimitiveField(("foo", "bar")).fingerprint(), - ) - self.assertEqual( - PrimitiveField("foo").fingerprint(), PrimitiveField("foo").fingerprint(), - ) - self.assertNotEqual( - PrimitiveField("foo").fingerprint(), PrimitiveField("bar").fingerprint(), - ) - - def test_fingerprinted_field(self): - class TestValue(FingerprintedMixin): - def __init__(self, test_value): - self.test_value = test_value - - def fingerprint(self): - hasher = sha1() - self.test_value = ensure_binary(self.test_value) - hasher.update(self.test_value) - return hasher.hexdigest() - - field1 = TestValue("field1") - field1_same = TestValue("field1") - field2 = TestValue("field2") - self.assertEqual(field1.fingerprint(), field1_same.fingerprint()) - self.assertNotEqual(field1.fingerprint(), field2.fingerprint()) - - fingerprinted_field1 = FingerprintedField(field1) - fingerprinted_field1_same = FingerprintedField(field1_same) - fingerprinted_field2 = FingerprintedField(field2) - self.assertEqual( - fingerprinted_field1.fingerprint(), fingerprinted_field1_same.fingerprint() - ) - self.assertNotEqual(fingerprinted_field1.fingerprint(), fingerprinted_field2.fingerprint()) - - def test_set_of_primitives_field(self): - # Should preserve `None` values. - self.assertEqual(PrimitivesSetField(None).value, None) - - def sopf(underlying): - return PrimitivesSetField(underlying).fingerprint() - - self.assertEqual( - sopf({"one", "two"}), sopf({"two", "one"}), - ) - self.assertEqual( - sopf(["one", "two"]), sopf(["two", "one"]), - ) - self.assertEqual( - sopf(None), sopf(None), - ) - self.assertNotEqual( - sopf(None), sopf(["one"]), - ) - self.assertNotEqual( - sopf(None), sopf([]), - ) - - def test_unimplemented_fingerprinted_field(self): - class TestUnimplementedValue(FingerprintedMixin): - pass - - with self.assertRaises(NotImplementedError): - FingerprintedField(TestUnimplementedValue()).fingerprint()