diff --git a/docs/markdown/Python/python-goals/python-test-goal.md b/docs/markdown/Python/python-goals/python-test-goal.md index 0ed8b51fd9f..84c1d2354e7 100644 --- a/docs/markdown/Python/python-goals/python-test-goal.md +++ b/docs/markdown/Python/python-goals/python-test-goal.md @@ -449,7 +449,7 @@ You can include the result of `pants package` in your test through the `runtime_ This allows you to test your packaging pipeline by simply running `pants test ::`, without needing custom integration test scripts. -To depend on a built package, use the `runtime_package_dependencies` field on the `python_test` / `python_tests` target, which is a list of addresses to targets that can be built with `pants package`, such as `pex_binary`, `python_awslambda`, and `archive` targets. Pants will build the package before running your test, and insert the file into the test's chroot. It will use the same name it would normally use with `pants package`, except without the `dist/` prefix (set by the `output_path` field). +To depend on a built package, use the `runtime_package_dependencies` field on the `python_test` / `python_tests` target, which is a list of addresses to targets that can be built with `pants package`, such as `pex_binary`, `python_aws_lambda_function`, and `archive` targets. Pants will build the package before running your test, and insert the file into the test's chroot. It will use the same name it would normally use with `pants package`, except without the `dist/` prefix (set by the `output_path` field). For example: diff --git a/docs/markdown/Shell/shell.md b/docs/markdown/Shell/shell.md index 406c91a9e5d..3b2e8c91006 100644 --- a/docs/markdown/Shell/shell.md +++ b/docs/markdown/Shell/shell.md @@ -353,7 +353,7 @@ You can include the result of `pants package` in your test through the `runtime_ This allows you to test your packaging pipeline by simply running `pants test ::`, without needing custom integration test scripts. -To depend on a built package, use the `runtime_package_dependencies` field on the `shunit2_test` / `shunit2_tests` targets, which is a list of addresses to targets that can be built with `pants package`, such as [`pex_binary`](doc:python-package-goal), [`python_awslambda`](doc:awslambda-python), and [`archive`](doc:resources) targets. Pants will build the package before running your test, and insert the file into the test's chroot. It will use the same name it would normally use with `pants package`, except without the `dist/` prefix. +To depend on a built package, use the `runtime_package_dependencies` field on the `shunit2_test` / `shunit2_tests` targets, which is a list of addresses to targets that can be built with `pants package`, such as [`pex_binary`](doc:python-package-goal), [`python_aws_lambda_function`](doc:awslambda-python), and [`archive`](doc:resources) targets. Pants will build the package before running your test, and insert the file into the test's chroot. It will use the same name it would normally use with `pants package`, except without the `dist/` prefix. For example: diff --git a/docs/markdown/Using Pants/assets.md b/docs/markdown/Using Pants/assets.md index ce95b28712e..2c8760159de 100644 --- a/docs/markdown/Using Pants/assets.md +++ b/docs/markdown/Using Pants/assets.md @@ -80,8 +80,8 @@ Note that we open the file with its full path, including the `src/python` prefix > 🚧 `file` targets are not included with binaries like `pex_binary` > -> Pants will not include dependencies on `file` / `files` targets when creating binaries like `pex_binary` and `python_awslambda` via `pants package`. Filesystem APIs like Python's `open()` are relative to the current working directory, and they would try to read the files from where the binary is executed, rather than reading from the binary itself. > +> Pants will not include dependencies on `file` / `files` targets when creating binaries like `pex_binary` and `python_aws_lambda_function` via `pants package`. Filesystem APIs like Python's `open()` are relative to the current working directory, and they would try to read the files from where the binary is executed, rather than reading from the binary itself. > Instead, use `resource` / `resources` targets or an `archive` target. When to use each asset target type @@ -97,11 +97,11 @@ Use `file` / `files` for files that aren't tightly coupled to any specific code, When writing tests, it is also often more convenient to open a file than to load a resource. -| | `resource` | `file` | -| :-------------------- | :---------------------------------------------------------------------------------------------- | :---------------------------------------------------- | -| **Runtime path** | Relative to source root | Relative to repo root | -| **Loading mechanism** | Language's package loader, relative to package | Language's file loading idioms, relative to repo root | -| **Use with** | Targets that produce binaries, such as `pex_binary`, `python_distribution`, `python_awslambda`. | `archive` targets, tests | +| | `resource` | `file` | +|:----------------------|:----------------------------------------------------------------------------------------------------------|:------------------------------------------------------| +| **Runtime path** | Relative to source root | Relative to repo root | +| **Loading mechanism** | Language's package loader, relative to package | Language's file loading idioms, relative to repo root | +| **Use with** | Targets that produce binaries, such as `pex_binary`, `python_distribution`, `python_aws_lambda_function`. | `archive` targets, tests | `relocated_files` ----------------- @@ -152,7 +152,7 @@ archive( The format can be `zip`, `tar`, `tar.xz`, `tar.gz`, or `tar.bz2`. -The `packages` field is a list of targets that can be built using `pants package`, such as `pex_binary`, `python_awslambda`, and even other `archive` targets. Pants will build the packages as if you had run `pants package`. It will include the results in your archive using the same name they would normally have, but without the `dist/` prefix. +The `packages` field is a list of targets that can be built using `pants package`, such as `pex_binary`, `python_aws_lambda_function`, and even other `archive` targets. Pants will build the packages as if you had run `pants package`. It will include the results in your archive using the same name they would normally have, but without the `dist/` prefix. The `files` field is a list of `file`, `files`, and `relocated_files` targets. See [resources](doc:resources) for more details. diff --git a/src/python/pants/backend/awslambda/python/rules.py b/src/python/pants/backend/awslambda/python/rules.py index 0798b2b5d66..37de699db7f 100644 --- a/src/python/pants/backend/awslambda/python/rules.py +++ b/src/python/pants/backend/awslambda/python/rules.py @@ -57,8 +57,8 @@ class PythonAwsLambdaLayerFieldSet(_BaseFieldSet): include_sources: PythonAwsLambdaIncludeSources -@rule(desc="Create Python AWS Lambda", level=LogLevel.DEBUG) -async def package_python_awslambda( +@rule(desc="Create Python AWS Lambda Function", level=LogLevel.DEBUG) +async def package_python_aws_lambda_function( field_set: PythonAwsLambdaFieldSet, lambdex: Lambdex, ) -> BuiltPackage: diff --git a/src/python/pants/backend/awslambda/python/rules_test.py b/src/python/pants/backend/awslambda/python/rules_test.py index 4a8a87a3135..0b523cfe0be 100644 --- a/src/python/pants/backend/awslambda/python/rules_test.py +++ b/src/python/pants/backend/awslambda/python/rules_test.py @@ -154,14 +154,14 @@ def handler(event, context): python_sources(name='lib') file(name="platform", source="platform.json") - python_awslambda( + python_aws_lambda_function( name='lambda', dependencies=[':lib'], handler='foo.bar.hello_world:handler', runtime='python3.7', complete_platforms=[':platform'], ) - python_awslambda( + python_aws_lambda_function( name='slimlambda', include_requirements=False, dependencies=[':lib'], @@ -193,7 +193,9 @@ def handler(event, context): ".deps/mureq-0.2.0-py3-none-any.whl/mureq/__init__.py" in names ), "third-party dep `mureq` must be included" if sys.platform == "darwin": - assert "`python_awslambda` targets built on macOS may fail to build." in caplog.text + assert ( + "`python_aws_lambda_function` targets built on macOS may fail to build." in caplog.text + ) zip_file_relpath, content = create_python_awslambda( rule_runner, @@ -247,7 +249,7 @@ def handler(event, context): dependencies=['assets:files', 'assets:relocated', 'assets:resources'], ) - python_awslambda( + python_aws_lambda_function( name='lambda', dependencies=[':lib'], handler='foo.bar.hello_world:handler', @@ -271,7 +273,7 @@ def handler(event, context): assert caplog.records assert "src.py.project/lambda.zip" == zip_file_relpath assert ( - "The target src/py/project:lambda (`python_awslambda`) transitively depends on" + "The target src/py/project:lambda (`python_aws_lambda_function`) transitively depends on" in caplog.text ) assert "assets/f.txt:files" in caplog.text @@ -295,12 +297,12 @@ def handler(event, context): python_requirement(name="mureq", requirements=["mureq==0.2"]) python_sources() - python_awslambda( + python_aws_lambda_function( name='lambda', handler='foo.bar.hello_world:handler', runtime="python3.7", ) - python_awslambda( + python_aws_lambda_function( name='slimlambda', include_requirements=False, handler='foo.bar.hello_world:handler', diff --git a/src/python/pants/backend/awslambda/python/target_types.py b/src/python/pants/backend/awslambda/python/target_types.py index 84b1795509f..bf3a78450e8 100644 --- a/src/python/pants/backend/awslambda/python/target_types.py +++ b/src/python/pants/backend/awslambda/python/target_types.py @@ -153,8 +153,11 @@ def validate(self) -> None: class PythonAWSLambda(_AWSLambdaBaseTarget): - # TODO: rename to python_aws_lambda_function - alias = "python_awslambda" + alias = "python_aws_lambda_function" + + deprecated_alias = "python_awslambda" + deprecated_alias_removal_version = "2.19.0.dev0" + core_fields = ( *_AWSLambdaBaseTarget.core_fields, PythonFaaSDependencies, diff --git a/src/python/pants/backend/awslambda/python/target_types_test.py b/src/python/pants/backend/awslambda/python/target_types_test.py index f3580366da1..2364b3019e3 100644 --- a/src/python/pants/backend/awslambda/python/target_types_test.py +++ b/src/python/pants/backend/awslambda/python/target_types_test.py @@ -64,24 +64,24 @@ def test_at_least_one_target_platform(rule_runner: RuleRunner) -> None: "project/platform-py37.json": "", "project/BUILD": dedent( """\ - python_awslambda( + python_aws_lambda_function( name='runtime', handler='project.app:func', runtime='python3.7', ) file(name="python37", source="platform-py37.json") - python_awslambda( + python_aws_lambda_function( name='complete_platforms', handler='project.app:func', complete_platforms=[':python37'], ) - python_awslambda( + python_aws_lambda_function( name='both', handler='project.app:func', runtime='python3.7', complete_platforms=[':python37'], ) - python_awslambda( + python_aws_lambda_function( name='neither', handler='project.app:func', ) @@ -110,7 +110,7 @@ def test_at_least_one_target_platform(rule_runner: RuleRunner) -> None: re.escape( softwrap( """ - InvalidTargetException: The `python_awslambda` target project:neither must + InvalidTargetException: The `python_aws_lambda_function` target project:neither must specify either a `runtime` or `complete_platforms` or both. """ ) diff --git a/src/python/pants/backend/python/dependency_inference/subsystem.py b/src/python/pants/backend/python/dependency_inference/subsystem.py index d768cc5183c..37b1477685f 100644 --- a/src/python/pants/backend/python/dependency_inference/subsystem.py +++ b/src/python/pants/backend/python/dependency_inference/subsystem.py @@ -127,7 +127,7 @@ class PythonInferSubsystem(Subsystem): help=softwrap( """ Infer dependencies on targets' entry points, e.g. `pex_binary`'s - `entry_point` field, `python_awslambda`'s `handler` field and + `entry_point` field, `python_aws_lambda_function`'s `handler` field and `python_distribution`'s `entry_points` field. """ ), diff --git a/src/python/pants/backend/python/subsystems/lambdex.py b/src/python/pants/backend/python/subsystems/lambdex.py index ac078e612e2..678dd080083 100644 --- a/src/python/pants/backend/python/subsystems/lambdex.py +++ b/src/python/pants/backend/python/subsystems/lambdex.py @@ -34,9 +34,10 @@ class Lambdex(PythonToolBase): default=LambdexLayout.ZIP, help=softwrap( """ - Explicitly control the layout used for `python_awslambda` and - `python_google_cloud_function` targets. This option exists for the transition from - Lambdex-based layout to the plain zip layout, as recommended by cloud vendors. + Explicitly control the layout used for `python_aws_lambda_function` (formerly + `python_awslambda`) and `python_google_cloud_function` targets. This option exists for + the transition from Lambdex-based layout to the plain zip layout, as recommended by + cloud vendors. """ ), removal_version="2.19.0.dev0", @@ -47,9 +48,10 @@ class Lambdex(PythonToolBase): 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 + `python_aws_lambda_function` (formerly `python_awslambda`) and + `python_google_cloud_function` targets to using the `zip` layout, as recommended by + cloud vendors. (If you are using `python_aws_lambda_function`, you will need to also + update the handlers configured in the cloud from `lambdex_handler.handler` to `lambda_function.handler`.) See the docs for more details: diff --git a/src/python/pants/backend/python/util_rules/faas_test.py b/src/python/pants/backend/python/util_rules/faas_test.py index ae00dcdf06c..5ec76c155d3 100644 --- a/src/python/pants/backend/python/util_rules/faas_test.py +++ b/src/python/pants/backend/python/util_rules/faas_test.py @@ -200,7 +200,7 @@ def assert_inferred(address: Address, *, expected: Optional[Address]) -> None: # Test that using a file path results in ignoring all targets which are not an ancestor. We can # do this because we know the file name must be in the current directory or subdir of the - # `python_awslambda`. + # `python_aws_lambda_function`. assert_inferred( Address("project", target_name="another_root__file_used"), expected=Address( diff --git a/src/python/pants/core/goals/test.py b/src/python/pants/core/goals/test.py index 0c427aefd11..55064d14c68 100644 --- a/src/python/pants/core/goals/test.py +++ b/src/python/pants/core/goals/test.py @@ -1069,7 +1069,7 @@ class RuntimePackageDependenciesField(SpecialCasedDependencies): have, but without the `--distdir` prefix (e.g. `dist/`). You can include anything that can be built by `{bin_name()} package`, e.g. a `pex_binary`, - `python_awslambda`, or an `archive`. + `python_aws_lambda_function`, or an `archive`. """ ) diff --git a/src/python/pants/core/target_types.py b/src/python/pants/core/target_types.py index 3bf1b9844b6..6ae4b653764 100644 --- a/src/python/pants/core/target_types.py +++ b/src/python/pants/core/target_types.py @@ -736,7 +736,7 @@ class ArchivePackagesField(SpecialCasedDependencies): `["project:app"]`.\n\nPants will build the assets as if you had run `{bin_name()} package`. It will include the results in your archive 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 `{bin_name()} package`, e.g. a `pex_binary`, `python_awslambda`, or even another + be built by `{bin_name()} package`, e.g. a `pex_binary`, `python_aws_lambda_function`, or even another `archive`. """ ) diff --git a/src/python/pants/engine/internals/specs_rules.py b/src/python/pants/engine/internals/specs_rules.py index d31533588bb..cfb328a08c2 100644 --- a/src/python/pants/engine/internals/specs_rules.py +++ b/src/python/pants/engine/internals/specs_rules.py @@ -405,7 +405,7 @@ def __init__( # command only works if at least one of the targets has a SourcesField field. # # NB: Even with the "secondary owners" mechanism - used by target types like `pex_binary` - # and `python_awslambda` to still work with file args - those targets will not show the + # and `python_aws_lambda_function` to still work with file args - those targets will not show the # associated files when using filedeps. filedeps_goal_works = any( tgt.class_has_field(SourcesField, union_membership) for tgt in applicable_target_types