Skip to content

Commit

Permalink
Fix all help and error messages to use the --pants-bin-name (#14414)
Browse files Browse the repository at this point in the history
This replaces all existing usages of "./pants", and the register.global_options.pants_bin_name as well as removes pants_bin.py

[ci skip-rust]
  • Loading branch information
thejcannon committed Feb 9, 2022
1 parent 62f9cd0 commit 3e9d830
Show file tree
Hide file tree
Showing 63 changed files with 175 additions and 205 deletions.
4 changes: 2 additions & 2 deletions src/python/pants/backend/awslambda/python/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
targets_with_sources_types,
)
from pants.engine.unions import UnionMembership, UnionRule
from pants.util.docutil import doc_url
from pants.util.docutil import bin_name, doc_url
from pants.util.logging import LogLevel

logger = logging.getLogger(__name__)
Expand All @@ -63,7 +63,7 @@ async def package_python_awslambda(
"AWS Lambdas built on macOS may fail to build. If your lambda uses any third-party"
" dependencies without binary wheels (bdist) for Linux available, it will fail to"
" build. If this happens, you will either need to update your dependencies to only use"
" dependencies with pre-built wheels, or find a Linux environment to run ./pants"
f" dependencies with pre-built wheels, or find a Linux environment to run {bin_name()}"
" package. (See https://realpython.com/python-wheels/ for more about wheels.)\n\n(If"
" the build does not raise an exception, it's safe to use macOS.)"
)
Expand Down
8 changes: 4 additions & 4 deletions src/python/pants/backend/debian/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
StringField,
Target,
)
from pants.util.docutil import doc_url
from pants.util.docutil import bin_name, doc_url


class DebianControlFile(MultipleSourcesField):
Expand Down Expand Up @@ -40,11 +40,11 @@ class DebianPackageDependencies(SpecialCasedDependencies):
alias = "packages"
required = True
help = (
"Addresses to any targets that can be built with `./pants package`, e.g. "
'`["project:app"]`.\n\nPants will build the assets as if you had run `./pants package`. '
f"Addresses to any targets that can be built with `{bin_name()} package`, e.g. "
f'`["project:app"]`.\n\nPants will build the assets as if you had run `{bin_name()} package`. '
"It will include the results in your Debian package using the same name they would normally have, "
"but without the `--distdir` prefix (e.g. `dist/`).\n\nYou can include anything that can "
"be built by `./pants package`, e.g. a `pex_binary`, a `python_distribution`, or an `archive`."
f"be built by `{bin_name()} package`, e.g. a `pex_binary`, a `python_distribution`, or an `archive`."
)


Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/backend/docker/lint/hadolint/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pants.core.util_rules.config_files import ConfigFilesRequest
from pants.core.util_rules.external_tool import TemplatedExternalTool
from pants.option.custom_types import file_option, shell_str
from pants.util.docutil import bin_name


class Hadolint(TemplatedExternalTool):
Expand Down Expand Up @@ -39,7 +40,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help="Don't use Hadolint when running `./pants lint`.",
help=f"Don't use Hadolint when running `{bin_name()} lint`.",
)
register(
"--args",
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/backend/docker/subsystems/docker_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pants.option.custom_types import shell_str
from pants.option.errors import ParseError
from pants.option.subsystem import Subsystem
from pants.util.docutil import bin_name
from pants.util.memo import memoized_method
from pants.util.ordered_set import OrderedSet
from pants.util.strutil import bullet_list
Expand Down Expand Up @@ -163,7 +164,7 @@ def register_options(cls, register):
help=(
"Additional arguments to use for `docker run` invocations.\n\n"
"Example:\n\n"
f' $ ./pants run --{cls.options_scope}-run-args="-p 127.0.0.1:80:8080/tcp '
f' $ {bin_name()} run --{cls.options_scope}-run-args="-p 127.0.0.1:80:8080/tcp '
'--name demo" src/example:image -- [image entrypoint args]\n\n'
"To provide the top-level options to the `docker` client, use "
f"`[{cls.options_scope}].env_vars` to configure the [Environment variables]("
Expand Down
6 changes: 4 additions & 2 deletions src/python/pants/backend/docker/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
StringSequenceField,
Target,
)
from pants.util.docutil import doc_url
from pants.util.docutil import bin_name, doc_url

# Common help text to be applied to each field that supports value interpolation.
_interpolation_help = (
Expand Down Expand Up @@ -191,7 +191,9 @@ class DockerImageRepositoryField(StringField):
class DockerImageSkipPushField(BoolField):
alias = "skip_push"
default = False
help = "If set to true, do not push this image to registries when running `./pants publish`."
help = (
f"If set to true, do not push this image to registries when running `{bin_name()} publish`."
)


OptionValueFormatter = Callable[[str], str]
Expand Down
6 changes: 2 additions & 4 deletions src/python/pants/backend/go/lint/gofmt/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from pants.option.subsystem import Subsystem
from pants.util.docutil import bin_name


class GofmtSubsystem(Subsystem):
Expand All @@ -15,8 +16,5 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use gofmt when running `{register.bootstrap.pants_bin_name} fmt` and "
f"`{register.bootstrap.pants_bin_name} lint`."
),
help=f"Don't use gofmt when running `{bin_name()} fmt` and `{bin_name()} lint`.",
)
3 changes: 2 additions & 1 deletion src/python/pants/backend/go/lint/vet/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import cast

from pants.option.subsystem import Subsystem
from pants.util.docutil import bin_name


class GoVetSubsystem(Subsystem):
Expand All @@ -17,7 +18,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=f"Don't use `go vet` when running `{register.bootstrap.pants_bin_name} lint`.",
help=f"Don't use `go vet` when running `{bin_name()} lint`.",
)

@property
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/backend/go/util_rules/go_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
UnexpandedTargets,
WrappedTarget,
)
from pants.util.docutil import bin_name

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -56,7 +57,7 @@ async def find_nearest_go_mod(request: OwningGoModRequest) -> OwningGoMod:
raise InvalidTargetException(
f"The target {request.address} does not have a `go_mod` target in its BUILD file or "
"any ancestor BUILD files. To fix, please make sure your project has a `go.mod` file "
"and add a `go_mod` target (you can run `./pants tailor` to do this)."
f"and add a `go_mod` target (you can run `{bin_name()} tailor` to do this)."
)
nearest_go_mod_target = go_mod_targets[0]
return OwningGoMod(nearest_go_mod_target.address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
targets_with_sources_types,
)
from pants.engine.unions import UnionMembership, UnionRule
from pants.util.docutil import doc_url
from pants.util.docutil import bin_name, doc_url
from pants.util.logging import LogLevel

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -66,7 +66,7 @@ async def package_python_google_cloud_function(
" third-party dependencies without binary wheels (bdist) for Linux available, it will"
" fail to build. If this happens, you will either need to update your dependencies to"
" only use dependencies with pre-built wheels, or find a Linux environment to run"
" ./pants package. (See https://realpython.com/python-wheels/ for more about"
f" {bin_name()} package. (See https://realpython.com/python-wheels/ for more about"
" wheels.)\n\n(If the build does not raise an exception, it's safe to use macOS.)"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import cast

from pants.jvm.resolve.jvm_tool import JvmToolBase
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url


class GoogleJavaFormatSubsystem(JvmToolBase):
Expand All @@ -26,10 +26,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use Google Java Format when running `{register.bootstrap.pants_bin_name} fmt` and "
f"`{register.bootstrap.pants_bin_name} lint`"
),
help=f"Don't use Google Java Format when running `{bin_name()} fmt` and `{bin_name()} lint`",
)
register(
"--aosp",
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/dependency_inference/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from pants.option.global_options import OwnersNotFoundBehavior
from pants.option.option_types import BoolOption, EnumOption, IntOption
from pants.option.subsystem import Subsystem
from pants.util.docutil import doc_url
from pants.util.docutil import bin_name, doc_url
from pants.util.strutil import bullet_list

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -97,7 +97,7 @@ class PythonInferSubsystem(Subsystem):
"it is located in (recursively upward in the directory structure).\n\nEven if this "
"is disabled, Pants will still include any ancestor `__init__.py` files, only they "
"will not be 'proper' dependencies, e.g. they will not show up in "
"`./pants dependencies` and their own dependencies will not be used.\n\nIf you "
f"`{bin_name()} dependencies` and their own dependencies will not be used.\n\nIf you "
"have empty `__init__.py` files, it's safe to leave this option off; otherwise, "
"you should enable this option."
),
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/backend/python/goals/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import AllTargets
from pants.engine.unions import UnionRule
from pants.util.docutil import bin_name
from pants.util.logging import LogLevel
from pants.util.ordered_set import FrozenOrderedSet

Expand Down Expand Up @@ -233,7 +234,7 @@ async def generate_lockfile(
initial_lockfile_digest_contents[0].content,
regenerate_command=(
generate_lockfiles_subsystem.custom_command
or f"./pants generate-lockfiles --resolve={req.resolve_name}"
or f"{bin_name()} generate-lockfiles --resolve={req.resolve_name}"
),
)
final_lockfile_digest = await Get(
Expand Down
5 changes: 3 additions & 2 deletions src/python/pants/backend/python/goals/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import Target, TransitiveTargets, TransitiveTargetsRequest
from pants.engine.unions import UnionRule
from pants.util.docutil import bin_name
from pants.util.logging import LogLevel


Expand All @@ -48,8 +49,8 @@ def validate_compatible_resolve(root_targets: Iterable[Target], python_setup: Py
root_targets,
(
"To work around this, choose which resolve you want to use from above. "
'Then, run `./pants peek :: | jq -r \'.[] | select(.resolve == "example") | '
'.["address"]\' | xargs ./pants repl`, where you replace "example" with the '
f'Then, run `{bin_name()} peek :: | jq -r \'.[] | select(.resolve == "example") | '
f'.["address"]\' | xargs {bin_name()} repl`, where you replace "example" with the '
"resolve name, and possibly replace the specs `::` with what you were using "
"before. This will result in opening a REPL with only targets using the desired "
"resolve."
Expand Down
7 changes: 2 additions & 5 deletions src/python/pants/backend/python/lint/autoflake/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pants.engine.rules import collect_rules, rule
from pants.engine.unions import UnionRule
from pants.option.custom_types import shell_str
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url


class Autoflake(PythonToolBase):
Expand All @@ -38,10 +38,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use Autoflake when running `{register.bootstrap.pants_bin_name} fmt` and "
f"`{register.bootstrap.pants_bin_name} lint`"
),
help=f"Don't use Autoflake when running `{bin_name()} fmt` and `{bin_name()} lint`",
)
register(
"--args",
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/lint/bandit/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pants.engine.target import AllTargets, AllTargetsRequest, FieldSet, Target
from pants.engine.unions import UnionRule
from pants.option.custom_types import file_option, shell_str
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url
from pants.util.logging import LogLevel


Expand Down Expand Up @@ -68,7 +68,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=f"Don't use Bandit when running `{register.bootstrap.pants_bin_name} lint`",
help=f"Don't use Bandit when running `{bin_name()} lint`",
)
register(
"--args",
Expand Down
7 changes: 2 additions & 5 deletions src/python/pants/backend/python/lint/black/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pants.engine.target import AllTargets, AllTargetsRequest
from pants.engine.unions import UnionRule
from pants.option.custom_types import file_option, shell_str
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url
from pants.util.logging import LogLevel


Expand All @@ -46,10 +46,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use Black when running `{register.bootstrap.pants_bin_name} fmt` and "
f"`{register.bootstrap.pants_bin_name} lint`"
),
help=f"Don't use Black when running `{bin_name()} fmt` and `{bin_name()} lint`",
)
register(
"--args",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pants.engine.rules import collect_rules, rule
from pants.engine.unions import UnionRule
from pants.option.custom_types import shell_str
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url


class Docformatter(PythonToolBase):
Expand All @@ -36,10 +36,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use docformatter when running `{register.bootstrap.pants_bin_name} fmt` "
f"and `{register.bootstrap.pants_bin_name} lint`."
),
help=f"Don't use docformatter when running `{bin_name()} fmt` and `{bin_name()} lint`.",
)
register(
"--args",
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/lint/flake8/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)
from pants.engine.unions import UnionRule
from pants.option.custom_types import file_option, shell_str, target_option
from pants.util.docutil import doc_url, git_url
from pants.util.docutil import bin_name, doc_url, git_url
from pants.util.logging import LogLevel
from pants.util.ordered_set import FrozenOrderedSet, OrderedSet

Expand Down Expand Up @@ -77,7 +77,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=f"Don't use Flake8 when running `{register.bootstrap.pants_bin_name} lint`",
help=f"Don't use Flake8 when running `{bin_name()} lint`",
)
register(
"--args",
Expand Down
7 changes: 2 additions & 5 deletions src/python/pants/backend/python/lint/isort/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pants.engine.rules import collect_rules, rule
from pants.engine.unions import UnionRule
from pants.option.custom_types import file_option, shell_str
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url


class Isort(PythonToolBase):
Expand All @@ -40,10 +40,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use isort when running `{register.bootstrap.pants_bin_name} fmt` and "
f"`{register.bootstrap.pants_bin_name} lint`."
),
help=f"Don't use isort when running `{bin_name()} fmt` and `{bin_name()} lint`.",
)
register(
"--args",
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/lint/pylint/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)
from pants.engine.unions import UnionRule
from pants.option.custom_types import file_option, shell_str, target_option
from pants.util.docutil import doc_url, git_url
from pants.util.docutil import bin_name, doc_url, git_url
from pants.util.logging import LogLevel
from pants.util.ordered_set import FrozenOrderedSet, OrderedSet

Expand Down Expand Up @@ -85,7 +85,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=f"Don't use Pylint when running `{register.bootstrap.pants_bin_name} lint`",
help=f"Don't use Pylint when running `{bin_name()} lint`",
)
register(
"--args",
Expand Down
7 changes: 2 additions & 5 deletions src/python/pants/backend/python/lint/pyupgrade/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pants.engine.rules import collect_rules, rule
from pants.engine.unions import UnionRule
from pants.option.custom_types import shell_str
from pants.util.docutil import git_url
from pants.util.docutil import bin_name, git_url


class PyUpgrade(PythonToolBase):
Expand All @@ -40,10 +40,7 @@ def register_options(cls, register):
"--skip",
type=bool,
default=False,
help=(
f"Don't use pyupgrade when running `{register.bootstrap.pants_bin_name} fmt` and "
f"`{register.bootstrap.pants_bin_name} lint`."
),
help=f"Don't use pyupgrade when running `{bin_name()} fmt` and `{bin_name()} lint`.",
)
register(
"--args",
Expand Down

0 comments on commit 3e9d830

Please sign in to comment.