diff --git a/src/python/pants/backend/python/goals/tailor.py b/src/python/pants/backend/python/goals/tailor.py index 544db8bbd24..fb5ed0ec57c 100644 --- a/src/python/pants/backend/python/goals/tailor.py +++ b/src/python/pants/backend/python/goals/tailor.py @@ -94,15 +94,6 @@ def is_entry_point(content: bytes) -> bool: async def _find_source_targets( py_files_globs: PathGlobs, all_owned_sources: AllOwnedSources, python_setup: PythonSetup ) -> list[PutativeTarget]: - ignore_solitary_explicitly_set = not python_setup.options.is_default( - "tailor_ignore_solitary_init_files" - ) - ignore_solitary = ( - python_setup.tailor_ignore_solitary_init_files - if ignore_solitary_explicitly_set - else python_setup.tailor_ignore_empty_init_files - ) - result = [] check_if_init_file_empty: dict[str, tuple[str, str]] = {} # full_path: (dirname, filename) @@ -119,13 +110,12 @@ async def _find_source_targets( else: name = None if ( - ignore_solitary + python_setup.tailor_ignore_empty_init_files and tgt_type == PythonSourcesGeneratorTarget and filenames in ({"__init__.py"}, {"__init__.pyi"}) ): - if not ignore_solitary_explicitly_set: - f = next(iter(filenames)) - check_if_init_file_empty[os.path.join(dirname, f)] = (dirname, f) + f = next(iter(filenames)) + check_if_init_file_empty[os.path.join(dirname, f)] = (dirname, f) else: result.append( PutativeTarget.for_target_type( diff --git a/src/python/pants/backend/python/goals/tailor_test.py b/src/python/pants/backend/python/goals/tailor_test.py index e174419f2e2..dba898a6672 100644 --- a/src/python/pants/backend/python/goals/tailor_test.py +++ b/src/python/pants/backend/python/goals/tailor_test.py @@ -62,7 +62,7 @@ def rule_runner() -> RuleRunner: def test_find_putative_targets(rule_runner: RuleRunner) -> None: - rule_runner.set_options(["--no-python-tailor-ignore-solitary-init-files"]) + rule_runner.set_options(["--no-python-tailor-ignore-empty-init-files"]) rule_runner.write_files( { "3rdparty/Pipfile.lock": "{}", @@ -154,7 +154,7 @@ def test_find_putative_targets(rule_runner: RuleRunner) -> None: def test_skip_invalid_requirements(rule_runner: RuleRunner) -> None: - rule_runner.set_options(["--no-python-tailor-ignore-solitary-init-files"]) + rule_runner.set_options(["--no-python-tailor-ignore-empty-init-files"]) rule_runner.write_files( { "3rdparty/requirements-valid.txt": b"FooProject >= 1.2", diff --git a/src/python/pants/backend/python/subsystems/setup.py b/src/python/pants/backend/python/subsystems/setup.py index f58f7be69a3..60011bdc902 100644 --- a/src/python/pants/backend/python/subsystems/setup.py +++ b/src/python/pants/backend/python/subsystems/setup.py @@ -400,56 +400,6 @@ class PythonSetup(Subsystem): removal_version="3.0.0.dev0", removal_hint=__constraints_deprecation_msg, ) - no_binary = StrListOption( - help=softwrap( - """ - Do not use binary packages (i.e., wheels) for these 3rdparty projects. - - Also accepts `:all:` to disable all binary packages. - - Note that some packages are tricky to compile and may fail to install when this option - is used on them. See https://pip.pypa.io/en/stable/cli/pip_install/#install-no-binary - for details. - - Note: Only takes effect if you use Pex lockfiles. Use the default - `[python].lockfile_generator = "pex"` and run the `generate-lockfiles` goal. - """ - ), - removal_version="2.15.0.dev0", - removal_hint=softwrap( - f""" - Use `[python].resolves_to_no_binary`, which allows you to set `--no-binary` on a - per-resolve basis for more flexibility. To keep this option's behavior, set - `[python].resolves_to_no_binary` with the key `{RESOLVE_OPTION_KEY__DEFAULT}` and the - value you used on this option. - """ - ), - ) - only_binary = StrListOption( - help=softwrap( - """ - Do not use source packages (i.e., sdists) for these 3rdparty projects. - - Also accepts `:all:` to disable all source packages. - - Packages without binary distributions will fail to install when this option is used on - them. See https://pip.pypa.io/en/stable/cli/pip_install/#install-only-binary for - details. - - Note: Only takes effect if you use Pex lockfiles. Use the default - `[python].lockfile_generator = "pex"` and run the `generate-lockfiles` goal. - """ - ), - removal_version="2.15.0.dev0", - removal_hint=softwrap( - f""" - Use `[python].resolves_to_only_binary`, which allows you to set `--only-binary` on a - per-resolve basis for more flexibility. To keep this option's behavior, set - `[python].resolves_to_only_binary` with the key `{RESOLVE_OPTION_KEY__DEFAULT}` and the - value you used on this option. - """ - ), - ) resolver_manylinux = StrOption( default="manylinux2014", help=softwrap( @@ -471,27 +421,6 @@ class PythonSetup(Subsystem): ), advanced=True, ) - tailor_ignore_solitary_init_files = BoolOption( - default=True, - help=softwrap( - """ - If true, don't add `python_sources` targets for solitary `__init__.py` files with the - `tailor` goal. - - Solitary `__init__.py` files usually exist as import scaffolding rather than true - library code, so it can be noisy to add BUILD files. - - Set to false if you commonly have packages containing real code in - `__init__.py` without other `.py` files in the package. - """ - ), - advanced=True, - removal_version="2.15.0.dev0", - removal_hint=( - "Use `[python].tailor_ignore_empty_init_files`, which checks that the `__init__.py`" - "file is both solitary and also empty." - ), - ) tailor_ignore_empty_init_files = BoolOption( "--tailor-ignore-empty-init-files", default=True, @@ -603,27 +532,6 @@ def resolves_to_constraints_file( def resolves_to_no_binary( self, all_python_tool_resolve_names: tuple[str, ...] ) -> dict[str, list[PipRequirement]]: - if self.no_binary: - if self._resolves_to_no_binary: - raise ValueError( - softwrap( - """ - Conflicting options used. You used the new, preferred - `[python].resolves_to_no_binary`, but also used the deprecated - `[python].no_binary`. - - Please use only one of these (preferably `[python].resolves_to_no_binary`). - """ - ) - ) - no_binary_opt = [ - PipRequirement.parse(v, description_of_origin="the option `[python].no_binary`") - for v in self.no_binary - ] - return { - resolve: no_binary_opt - for resolve in {*self.resolves, *all_python_tool_resolve_names} - } return { resolve: [ PipRequirement.parse( @@ -645,27 +553,6 @@ def resolves_to_no_binary( def resolves_to_only_binary( self, all_python_tool_resolve_names: tuple[str, ...] ) -> dict[str, list[PipRequirement]]: - if self.only_binary: - if self._resolves_to_only_binary: - raise ValueError( - softwrap( - """ - Conflicting options used. You used the new, preferred - `[python].resolves_to_only_binary`, but also used the deprecated - `[python].only_binary`. - - Please use only one of these (preferably `[python].resolves_to_only_binary`). - """ - ) - ) - only_binary_opt = [ - PipRequirement.parse(v, description_of_origin="the option `[python].only_binary`") - for v in self.only_binary - ] - return { - resolve: only_binary_opt - for resolve in {*self.resolves, *all_python_tool_resolve_names} - } return { resolve: [ PipRequirement.parse( diff --git a/src/python/pants/backend/python/subsystems/setup_test.py b/src/python/pants/backend/python/subsystems/setup_test.py index 1c4db1d6b46..3d26962d73e 100644 --- a/src/python/pants/backend/python/subsystems/setup_test.py +++ b/src/python/pants/backend/python/subsystems/setup_test.py @@ -43,16 +43,12 @@ def create(resolves_to_constraints_file: dict[str, str]) -> dict[str, str]: def test_resolves_to_no_binary_and_only_binary() -> None: - def create( - resolves_to_projects: dict[str, list[str]], deprecated_options: list[str] | None = None - ) -> dict[str, list[PipRequirement]]: + def create(resolves_to_projects: dict[str, list[str]]) -> dict[str, list[PipRequirement]]: subsystem = create_subsystem( PythonSetup, resolves={"a": "a.lock"}, resolves_to_no_binary=resolves_to_projects, resolves_to_only_binary=resolves_to_projects, - only_binary=deprecated_options or [], - no_binary=deprecated_options or [], ) only_binary = subsystem.resolves_to_only_binary( all_python_tool_resolve_names=("tool1", "tool2") @@ -75,11 +71,3 @@ def create( } with pytest.raises(UnrecognizedResolveNamesError): create({"fake": []}) - - assert create({}, deprecated_options=["p1"]) == { - "a": [p1_req], - "tool1": [p1_req], - "tool2": [p1_req], - } - with pytest.raises(ValueError): - create({"a": ["p1"]}, deprecated_options=["p2"])