adamant-airport-25400
05/04/2022, 6:53 PMwitty-crayon-22786
05/04/2022, 7:09 PMI tried the archive, but I can’t get archive target to work with python_sources. Is it normal?yea, that’s correct: currently when sources are “typed” as python via
python_sources
, they are not treated as loose files which can be packaged into an archive
files
targets are typed as loose files, and so can be… but then they are not typed as python, and so don’t have dependency inference, for examplewitty-crayon-22786
05/04/2022, 7:10 PMAs it using PEX, it needs to have a runtime defined. This means that I have to define it in the Pants target, but also again in my IaC tool (Using CDK). Is there any way to avoid it ? My guess is no.what do you mean by “runtime” here?
adamant-airport-25400
05/04/2022, 7:13 PMruntime
should be one of the values from https://docs.aws.amazon.com/lambda/latest/dg/lambda-python.html. ”
So basically, it’s the Python version.
Also, It is required to define the lambda handler, which, as the runtime, I have to redefine in my IaC tool.hundreds-father-404
05/04/2022, 7:15 PMwitty-crayon-22786
05/04/2022, 7:17 PMarchive
anymoreadamant-airport-25400
05/04/2022, 7:23 PMconst fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
It requires a runtime, a handler and an asset. Currently in my case, the asset is the archive file generated by our internal tool. My idea was to replace this asset by one generated by Pants.
The idea of a target generator seems interesting. I’ll have to work more on the doc. I just started playing with Pants some hours ago. Do you have any useful resources for this ?hundreds-father-404
05/04/2022, 7:29 PMpex_binaries
, but even simpler because you are generating 1->1 rather than 1->n so no need for things like the overrides
field
https://github.com/pantsbuild/pants/blob/cf172080a5de8140b4e244e15a2f6265498e957e/src/python/pants/backend/python/target_types_rules.py#L77-L124