Closed lorengordon closed 5 years ago
Hi again. Thanks for this.
I wonder if argparse handles it correctly, something like:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('filename')
parser.add_argument('runtime')
parser.add_argument('source_path')
args = parser.parse_args()
filename = args.filename
runtime = args.runtime
source_path = args.source_path
I'd lean towards using argparse over shlex if it works.
Good idea! I'll give that a try also, probably tomorrow.
@raymondbutcher Unfortunately, no, argparse preserves the quotes also, and so the error reported in the linked issue still occurs.
I suppose I'm not too sure what the difference is on Windows, that the argument is quoted in *argv, where on Linux it is not. I've tried both double quotes and single quotes in build_command
and both fail the same way.
I've also tried no quotes, which changes the behavior and gets further, but then fails in a different way that I understand even less at the moment. It also probably would not work at all when there are spaces in the path.
I eventually fell back to treating the symptom with shlex
, which at least gets things working across platforms again.
Any other concerns @raymondbutcher?
Thanks for trying argparse. One last idea, if you wouldn't mind trying it.
The quote is probably coming from here:
variable "build_command" {
description = "The command that creates the Lambda package zip file"
type = "string"
default = "python build.py '$filename' '$runtime' '$source'"
}
Could you please try with double quotes instead of single quotes?
variable "build_command" {
description = "The command that creates the Lambda package zip file"
type = "string"
default = "python build.py \"$filename\" \"$runtime\" \"source\""
}
Maybe Windows handles double quotes and single quotes differently.
Hi @raymondbutcher, that was one of the first things I tried, thinking the same thing. :smile: No luck though. The double quotes are passed through, and then os.path.dirname
strips off the closing quote as mentioned in the linked issue, resulting in an invalid path.
OK, I guess this will have to go in then :smile:
Thanks @raymondbutcher! Mind tagging that also?
@lorengordon sorry for the delay, it's now in v0.11.5
Awesome, thanks @raymondbutcher!
With this patch, the inputs in build.py resolve the same on both linux and windows.
Fixes #43