cold-jackal-89755
05/15/2024, 3:57 PMpython_aws_lambda_layer
integration to make a layer that includes redshift-connector
and it works great except that I can't seem to get it to not package boto3/botocore. I am trying like this
python_aws_lambda_layer(
name="redshift_connector_layer",
dependencies=[
"!!//:reqs0#boto3",
"!!//:reqs0#botocore",
"//:reqs0#redshift-connector",
],
include_sources=False,
)
I would like to exclude boto3/botocore since it's already in the lambda runtimecold-jackal-89755
05/15/2024, 5:46 PMredshift-connector
declares boto3/botocore as dependencies.happy-kitchen-89482
05/15/2024, 10:12 PMbroad-processor-92400
05/15/2024, 10:25 PM--exclude
flag required, so we could expose that. Are you interested in implementing it?cold-jackal-89755
05/16/2024, 1:29 AMcold-jackal-89755
05/16/2024, 1:37 AMpackage_python_aws_lambda_function
code but that made me wonder, would this use case be outside of the faas packages?broad-processor-92400
05/16/2024, 4:50 AMpex_binary
etc. too. I'm not exactly sure the best way to expose it. Potentially 4 options for doing it in a dedicated way:
1. translate the !!...
exclusions of python_requirement
targets into --exclude
arguments somehow
2. have an exclude=["//:reqs0#boto3"]
field that takes target addresses, that are translated into PyPI names for --exclude
3. have an exclude=["boto3"]
that takes PyPI package names that just get passed to --exclude
directly
4. both 2 and 3 (i.e. exclude=["//:reqs0#boto3", "botocore"]
would pass --exclude=boto3 --exclude=botocore
)
An extra choice would be adding an escape hatch for passing arbitrary args to the underlying pex creation, similar to https://github.com/pantsbuild/pants/pull/20737 / https://github.com/pantsbuild/pants/pull/20237. This last one would be good as a stop-gap, to unlock this feature (and any future ones pex has) without having to solve "harder" design problems.cold-jackal-89755
05/16/2024, 4:37 PMbroad-processor-92400
05/16/2024, 11:29 PMpex_build_extra_args
that is splatted at the end of https://github.com/pantsbuild/pants/blob/40e8bc94803a70f42b2c2889f73573c914c153dd/src/python/pants/backend/python/util_rules/faas.py#L454-L460 to be passed to the PexFromTargetsRequest
below?cold-jackal-89755
05/16/2024, 11:39 PM@rule
async def build_python_faas(
request: BuildPythonFaaSRequest,
pex_build_extra_args,
) -> BuiltPackage:
additional_pex_args = (
# Ensure we can resolve manylinux wheels in addition to any AMI-specific wheels.
"--manylinux=manylinux2014",
# When we're executing Pex on Linux, allow a local interpreter to be resolved if
# available and matching the AMI platform.
"--resolve-local-platforms",
) + pexbuild_extra_args
Would that be something as simple as that?cold-jackal-89755
05/16/2024, 11:40 PMpex_build_extra_args
could be added to BuildPythonFaaSRequest
broad-processor-92400
05/16/2024, 11:41 PMBuildPythonFaaSRequest
. I'd be expecting the changes to be very similar to https://github.com/pantsbuild/pants/pull/20237/files#diff-48c7912f30acce7d7d55171a4f13831981e2aaae3660cf853016dd622a13c5bf (and the rest of that PR), in terms of type structure and how things are set up, just the details of the docs, which invocation it is passed to and the tests that differ.cold-jackal-89755
05/16/2024, 11:45 PMbroad-processor-92400
05/16/2024, 11:47 PMcold-jackal-89755
05/16/2024, 11:47 PMcold-jackal-89755
05/16/2024, 11:48 PMcold-jackal-89755
05/19/2024, 7:25 PMbroad-processor-92400
05/19/2024, 10:33 PMif
+ +=
, I'd suggest using a *
splat into the original tuple construction:
additional_pex_args = (
...
*request.pex_build_extra_args.value,
)
cold-jackal-89755
05/20/2024, 1:18 PMrequest.pex_build_extra_args.value
can be None.cold-jackal-89755
05/20/2024, 1:22 PMadditional_pex_args = (
# Ensure we can resolve manylinux wheels in addition to any AMI-specific wheels.
"--manylinux=manylinux2014",
# When we're executing Pex on Linux, allow a local interpreter to be resolved if
# available and matching the AMI platform.
"--resolve-local-platforms",
*(request.pex_build_extra_args.value or ()),
)
cold-jackal-89755
05/21/2024, 12:41 AMcold-jackal-89755
05/21/2024, 1:00 AMpex_build_extra_args=["--exclude=boto3", "--exclude=botocore", "--ignore-errors"],
and it packaged it up without boto3/botocore!cold-jackal-89755
05/21/2024, 1:01 AM"--ignore-errors"
was needed because Pex throws an error that it can't resolve a requirementbroad-processor-92400
05/21/2024, 1:03 AMcold-jackal-89755
05/21/2024, 1:06 AMbroad-processor-92400
05/21/2024, 2:18 AMcold-jackal-89755
05/21/2024, 11:02 AM