-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try relpath first, if failed use the user specified path #1337
Conversation
For compatibility with Windows. relpath() fails when the specified path is on a different drive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this change. I have two minor comments, and then we should be good to go :)
samcli/commands/build/command.py
Outdated
output_template_path = os.path.relpath(ctx.output_template_path) | ||
except ValueError: | ||
LOG.debug("Failed to retrieve relpath - using abspath instead") | ||
build_dir = os.path.abspath(ctx.build_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we got a ValueError computing relative path, I would just use the original path without computing absolute path.
samcli/commands/build/command.py
Outdated
# under Windows, when SAM and (build_dir or output_template_path) are | ||
# on different drive, relpath() fails. | ||
try: | ||
build_dir = os.path.relpath(ctx.build_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you rename build_dir
and output_template_path
to be something more descriptive? I just don't want someone to use these values without knowing what it means.
Also rename a couple of variables to be a little more descriptive.
@sanathkr - Thank you for your comment. I think your suggestion makes sense, so I made a couple of changes. Let me know your thoughts about it - especially the renaming looks in-line with what you meant? |
Appreciate the changes. Approved. |
For compatibility with Windows. relpath() fails when the specified path is on a different drive.
Issue #, if available: #1336
Description of changes: use abspath() instead of relpath(), so cli command succeeds even when running on windows where sam and build_dir/template are located on different drive.
Checklist:
make pr
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.