-
-
Notifications
You must be signed in to change notification settings - Fork 665
stop swallowing warnings from Pex by default #20480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d2d8ce3
3cb4995
cee1f14
9819b0d
b064a69
6633bee
fe1c470
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,7 @@ | |||||
|
||||||
from pants.backend.python.macros.python_artifact import PythonArtifact | ||||||
from pants.backend.python.subsystems.setup import PythonSetup | ||||||
from pants.base.deprecated import warn_or_error | ||||||
from pants.core.goals.generate_lockfiles import UnrecognizedResolveNamesError | ||||||
from pants.core.goals.package import OutputPathField | ||||||
from pants.core.goals.run import RestartableField | ||||||
|
@@ -381,6 +382,24 @@ class PexArgsField(StringSequenceField): | |||||
) | ||||||
|
||||||
|
||||||
class PexCheckField(StringField): | ||||||
alias = "check" | ||||||
valid_choices = ("none", "warn", "error") | ||||||
expected_type = str | ||||||
default = "error" | ||||||
help = help_text( | ||||||
""" | ||||||
Check that the built PEX is valid. Currently this only | ||||||
applies to `--layout zipapp` where the PEX zip is | ||||||
tested for importability of its `__main__` module by | ||||||
the Python zipimport module. This check will fail for | ||||||
PEX zips that use ZIP64 extensions since the Python | ||||||
zipimport zipimporter only works with 32 bit zips. The | ||||||
check no-ops for all other layouts. | ||||||
""" | ||||||
) | ||||||
|
||||||
|
||||||
class PexEnvField(DictStringToStringField): | ||||||
alias = "env" | ||||||
help = help_text( | ||||||
|
@@ -545,6 +564,19 @@ class PexEmitWarningsField(TriBoolField): | |||||
def value_or_global_default(self, pex_binary_defaults: PexBinaryDefaults) -> bool: | ||||||
if self.value is None: | ||||||
return pex_binary_defaults.emit_warnings | ||||||
warn_or_error( | ||||||
"2.21.0.dev0", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a relatively small amount of code, so maybe we could extend the deprecation for longer, to be nicer to users/make it easier to upgrade (e.g. if someone is using 2.19.0, and then testing major features/fixes in a hypothetical 2.20.0rc3 and 2.21.0.dev4, it's nice if they're not completely blocked until they make changes for "minor" stuff like shuffling fields around, which removing this in 2.21.0.dev0 would force.)
Suggested change
Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the fix-instead-of-deprecate option shot per other review feedback. |
||||||
softwrap( | ||||||
""" | ||||||
`emit_warnings` no longer set per target. | ||||||
Use `emit_warnings` on the [pex] subsytem to control warnings for | ||||||
all pex invocations | ||||||
""" | ||||||
), | ||||||
"use [pex] subsystem instead", | ||||||
start_version="2.20.0.dev0", | ||||||
) | ||||||
|
||||||
return self.value | ||||||
|
||||||
|
||||||
|
@@ -697,6 +729,7 @@ class PexVenvHermeticScripts(BoolField): | |||||
InterpreterConstraintsField, | ||||||
PythonResolveField, | ||||||
PexBinaryDependenciesField, | ||||||
PexCheckField, | ||||||
PexPlatformsField, | ||||||
PexCompletePlatformsField, | ||||||
PexResolveLocalPlatformsField, | ||||||
|
@@ -837,6 +870,8 @@ class PexBinaryDefaults(Subsystem): | |||||
`pex_binary` targets | ||||||
""" | ||||||
), | ||||||
removal_version="2.21.0.dev0", | ||||||
removal_hint="Use the [pex] subsystem to control warnings for all Pex invocations", | ||||||
advanced=True, | ||||||
) | ||||||
resolve_local_platforms = BoolOption( | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
from __future__ import annotations | ||
|
||
import dataclasses | ||
import logging | ||
import os.path | ||
from dataclasses import dataclass | ||
from typing import Iterable, List, Mapping, Optional, Tuple | ||
|
@@ -29,6 +30,8 @@ | |
from pants.util.logging import LogLevel | ||
from pants.util.meta import classproperty | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PexCli(TemplatedExternalTool): | ||
options_scope = "pex-cli" | ||
|
@@ -156,6 +159,8 @@ async def setup_pex_cli_process( | |
|
||
verbosity_args = [f"-{'v' * pex_subsystem.verbosity}"] if pex_subsystem.verbosity > 0 else [] | ||
|
||
warnings_args = [] if pex_subsystem.emit_warnings else ["--no-emit-warnings"] | ||
|
||
# NB: We should always pass `--python-path`, as that tells Pex where to look for interpreters | ||
# when `--python` isn't an absolute path. | ||
resolve_args = [ | ||
|
@@ -171,6 +176,7 @@ async def setup_pex_cli_process( | |
*request.subcommand, | ||
*global_args, | ||
*verbosity_args, | ||
*warnings_args, | ||
*pip_version_args, | ||
*resolve_args, | ||
# NB: This comes at the end because it may use `--` passthrough args, # which must come at | ||
|
@@ -202,6 +208,15 @@ async def setup_pex_cli_process( | |
) | ||
|
||
|
||
def maybe_log_pex_stderr(stderr: bytes, pex_verbosity: int) -> None: | ||
"""Forward Pex's stderr to a Pants logger if conditions are met.""" | ||
log_output = stderr.decode() | ||
if log_output and pex_verbosity > 0: | ||
logger.info("%s", log_output) | ||
elif log_output and "PEXWarning:" in log_output: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about potentially being even more lax here: I would think showing more warnings is better than missing some, e.g. just check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried about making a wishy washy guess that someday might cause someone to have to think about unicode case folding in a whacky corner case. I'd rather either have the |
||
logger.warning("%s", log_output) | ||
cognifloyd marked this conversation as resolved.
Show resolved
Hide resolved
cburroughs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def rules(): | ||
return [ | ||
*collect_rules(), | ||
|
Uh oh!
There was an error while loading. Please reload this page.