Skip to content

Commit

Permalink
Switch deprecation to the layout option
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed May 23, 2023
1 parent 1f81440 commit 4023b6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
42 changes: 14 additions & 28 deletions src/python/pants/backend/python/subsystems/lambdex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from pants.backend.python.subsystems.python_tool_base import LockfileRules, PythonToolBase
from pants.backend.python.target_types import ConsoleScript
from pants.base.deprecated import warn_or_error
from pants.engine.rules import collect_rules
from pants.option.option_types import EnumOption
from pants.util.strutil import softwrap
Expand Down Expand Up @@ -39,35 +38,22 @@ class Lambdex(PythonToolBase):
Lambdex-based layout to the plain zip layout, as recommended by cloud vendors.
"""
),
removal_version="2.19.0.dev0",
removal_hint=softwrap(
"""
Remove the whole [lambdex] section, as Lambdex is deprecated and its functionality be
removed. If you have `layout = "zip"`, no further action is required, as you are already using
the recommended layout.
If you have `layout = "lambdex"`, removing the section will switch any
`python_awslambda` and `python_google_cloud_function` targets to using the `zip` layout,
as recommended by cloud vendors. (If you are using `python_awslambda`, you will need to
also update the handlers configured in the cloud from `lambdex_handler.handler` to
`lambda_function.handler`.)
"""
),
)

def warn_for_layout(self, target_alias: str) -> None:
if self.options.is_default("layout"):
lambda_message = (
" (you will need to also update the handlers configured in the cloud from `lambdex_handler.handler` to `lambda_function.handler`)"
if target_alias == "python_awslambda"
else ""
)

warn_or_error(
"2.19.0.dev0",
f"using the Lambdex layout for `{target_alias}` targets",
softwrap(
f"""
Set the `[lambdex].layout` option explicitly to `zip` (recommended) or `lambdex`
(compatibility), in `pants.toml`. Recommended: set to `zip` to opt-in to the new
layout recommended by cloud vendors{lambda_message}:
[lambdex]
layout = "zip"
You can also explicitly set `layout = "lambdex"` to silence this warning and
continue using the Lambdex-based layout in this release of Pants. This layout
will disappear in future.
"""
),
)


def rules():
return collect_rules()
1 change: 0 additions & 1 deletion src/python/pants/backend/python/util_rules/faas.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ async def build_lambdex(
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.)"
)
lambdex.warn_for_layout(request.target_name)

output_filename = request.output_path.value_or_default(
# FaaS typically use the .zip suffix, so we use that instead of .pex.
Expand Down

0 comments on commit 4023b6d

Please sign in to comment.