-
Notifications
You must be signed in to change notification settings - Fork 139
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
Use Bespoke Tool Path for dotnet-lambda
Commands
#127
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
import sys | ||
import logging | ||
import os | ||
|
||
from .utils import OSUtils | ||
|
||
|
@@ -36,7 +37,7 @@ def __init__(self, dotnet_exe=None, os_utils=None): | |
|
||
self.dotnet_exe = dotnet_exe | ||
|
||
def run(self, args, cwd=None): | ||
def run(self, args, tool_dir=None, cwd=None): | ||
if not isinstance(args, list): | ||
raise ValueError('args must be a list') | ||
|
||
|
@@ -47,9 +48,17 @@ def run(self, args, cwd=None): | |
|
||
LOG.debug("executing dotnet: %s", invoke_dotnet) | ||
|
||
if tool_dir is None: | ||
env = None | ||
else: | ||
env = SubprocessDotnetCLI._merge( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm far from a Python expert, so if I've made a hash of this, please do let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have dropped support for running Lambda builder in Python 2. |
||
os.environ, | ||
PATH=os.pathsep.join([tool_dir, os.environ['PATH']])) | ||
|
||
p = self.os_utils.popen(invoke_dotnet, | ||
stdout=self.os_utils.pipe, | ||
stderr=self.os_utils.pipe, | ||
env=env, | ||
cwd=cwd) | ||
|
||
out, err = p.communicate() | ||
|
@@ -61,3 +70,15 @@ def run(self, args, cwd=None): | |
|
||
if p.returncode != 0: | ||
raise DotnetCLIExecutionError(message=err.decode('utf8').strip()) | ||
|
||
# The {**x, **y} syntax will not work in Python 2. | ||
@staticmethod | ||
def _merge(left, **right): | ||
""" | ||
Shallowly merges the elements of `right` onto a copy of `left` | ||
and returns that copy. | ||
""" | ||
|
||
output = left.copy() | ||
output.update(right) | ||
return output |
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.
This would still be a global tool but with a custom path.
https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
Maybe we can use local tools instead and check whether a global Amazon.Lambda.Tools is already installed.
We should also check whether a global version of the Amazon.Lambda.Tools is already installed and skip over if needed.