Skip to content

Commit

Permalink
Add additional directories with register.py to pants bin deps (pantsb…
Browse files Browse the repository at this point in the history
…uild#19848)

I compared the output of `find . -name register.py` and the dependencies
of the `src/python/pants/bin:plugins` target: this identified several
backends that seemingly weren't being packaged into the Pants binary,
and thus not available for users, similar to pantsbuild#19836.

- `pants.backend.experimental.helm.check.kubeconform`
- `pants.backend.experimental.python.framework.django`
- `pants.backend.experimental.python.typecheck.pytype`
- `pants.backend.experimental.rust`
- `pants.backend.experimental.swift`
- `pants.backend.experimental.terraform.lint.tfsec`
- `pants.backend.python.providers.experimental.pyenv.custom_install`

Two of these (Django and Rust) also had minor issues the caused errors
when being loaded, which this PR resolves.

There were also two that have been upgraded from experimental to stable,
that were depended upon via the old/deprecated experimental name, but
not the stable name:

- `pants.backend.python.lint.autoflake`
- `pants.backend.python.lint.pyupgrade`

This doesn't try to solve the problem of keeping this up to date. I can
think of two approaches (definitely for a separate PR):

- pantsbuild#17301, with a test that reads the `BUILD` file and compares the
dependencies to a `find` for `register.py` files
- a target that exposes the output of `pants peek ::` as a file, with a
test that reads that file and does the appropriate validation
  • Loading branch information
huonw authored Sep 18, 2023
1 parent 0afc51c commit 0ad8ce1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
from pathlib import PurePath

from pants.backend.python import dependency_inference
from pants.backend.python.dependency_inference.parse_python_dependencies import (
ParsedPythonAssetPaths,
ParsedPythonDependencies,
Expand All @@ -19,6 +20,7 @@
from pants.backend.python.framework.django.detect_apps import DjangoApps
from pants.backend.python.subsystems.setup import PythonSetup
from pants.backend.python.target_types import EntryPoint
from pants.backend.python.util_rules import pex
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
from pants.backend.python.util_rules.pex import PexRequest, VenvPex, VenvPexProcess
from pants.core.util_rules.source_files import SourceFilesRequest
Expand Down Expand Up @@ -118,5 +120,7 @@ async def django_parser_script(
def rules():
return [
*collect_rules(),
*pex.rules(),
*dependency_inference.rules.rules(),
UnionRule(InferDependenciesRequest, InferDjangoDependencies),
]
11 changes: 10 additions & 1 deletion src/python/pants/backend/rust/target_types.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from pants.engine.target import COMMON_TARGET_FIELDS, MultipleSourcesField, Target
from pants.engine.target import (
COMMON_TARGET_FIELDS,
MultipleSourcesField,
Target,
generate_multiple_sources_field_help_message,
)
from pants.util.strutil import help_text


class RustPackageSourcesField(MultipleSourcesField):
default = ("src/**/*.rs", "tests/**/*.rs")
uses_source_roots = False

help = generate_multiple_sources_field_help_message(
"Example: `sources=['src/main.rs', 'src/new_*.rs', '!src/old_ignore.py']`"
)


class RustPackageTarget(Target):
alias = "rust_package"
Expand Down
9 changes: 9 additions & 0 deletions src/python/pants/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target(
"src/python/pants/backend/experimental/go/lint/golangci_lint",
"src/python/pants/backend/experimental/go/lint/vet",
"src/python/pants/backend/experimental/helm",
"src/python/pants/backend/experimental/helm/check/kubeconform",
"src/python/pants/backend/experimental/java",
"src/python/pants/backend/experimental/java/debug_goals",
"src/python/pants/backend/experimental/java/lint/google_java_format",
Expand All @@ -53,17 +54,22 @@ target(
"src/python/pants/backend/experimental/openapi/lint/openapi_format",
"src/python/pants/backend/experimental/openapi/lint/spectral",
"src/python/pants/backend/experimental/python",
"src/python/pants/backend/experimental/python/framework/django",
"src/python/pants/backend/experimental/python/framework/stevedore",
"src/python/pants/backend/experimental/python/lint/add_trailing_comma",
"src/python/pants/backend/experimental/python/lint/autoflake",
"src/python/pants/backend/experimental/python/lint/pyupgrade",
"src/python/pants/backend/experimental/python/lint/ruff",
"src/python/pants/backend/experimental/python/packaging/pyoxidizer",
"src/python/pants/backend/experimental/python/typecheck/pyright",
"src/python/pants/backend/experimental/python/typecheck/pytype",
"src/python/pants/backend/experimental/rust",
"src/python/pants/backend/experimental/scala",
"src/python/pants/backend/experimental/scala/debug_goals",
"src/python/pants/backend/experimental/scala/lint/scalafmt",
"src/python/pants/backend/experimental/swift",
"src/python/pants/backend/experimental/terraform",
"src/python/pants/backend/experimental/terraform/lint/tfsec",
"src/python/pants/backend/experimental/tools/semgrep",
"src/python/pants/backend/experimental/tools/yamllint",
"src/python/pants/backend/experimental/tools/workunit_logger",
Expand All @@ -72,16 +78,19 @@ target(
"src/python/pants/backend/plugin_development",
"src/python/pants/backend/project_info",
"src/python/pants/backend/python",
"src/python/pants/backend/python/lint/autoflake",
"src/python/pants/backend/python/lint/bandit",
"src/python/pants/backend/python/lint/black",
"src/python/pants/backend/python/lint/docformatter",
"src/python/pants/backend/python/lint/flake8",
"src/python/pants/backend/python/lint/isort",
"src/python/pants/backend/python/lint/pydocstyle",
"src/python/pants/backend/python/lint/pylint",
"src/python/pants/backend/python/lint/pyupgrade",
"src/python/pants/backend/python/lint/yapf",
"src/python/pants/backend/python/mixed_interpreter_constraints",
"src/python/pants/backend/python/providers/experimental/pyenv",
"src/python/pants/backend/python/providers/experimental/pyenv/custom_install",
"src/python/pants/backend/python/typecheck/mypy",
"src/python/pants/backend/shell",
"src/python/pants/backend/shell/lint/shellcheck",
Expand Down

0 comments on commit 0ad8ce1

Please sign in to comment.