Skip to content
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

Support Python 3 when calling pip for extra E2E start up commands #4213

Merged
merged 2 commits into from
Jul 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions datadog_checks_dev/datadog_checks/dev/tooling/e2e/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def get_agent_exe(agent_version, platform=LINUX):
def get_pip_exe(python_version, platform=LINUX):
if platform == WINDOWS:
return [r'C:\Program Files\Datadog\Datadog Agent\embedded{}\python.exe'.format(python_version), '-m', 'pip']
elif platform == MAC:
pass
else:
return ['/opt/datadog-agent/embedded/bin/pip{}'.format(python_version)]

Expand Down
3 changes: 3 additions & 0 deletions datadog_checks_dev/datadog_checks/dev/tooling/e2e/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def exec_command(self, command, **kwargs):
if kwargs.pop('interactive', False):
cmd += ' -it'

if command.startswith('pip '):
command = command.replace('pip ', get_pip_exe(self.python_version), 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this working? you cannot replace a string with a list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command is a string, see line 86

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but get_pip_exe(self.python_version) returns an array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! #4225


cmd += ' {}'.format(self.container_name)
cmd += ' {}'.format(command)

Expand Down
3 changes: 3 additions & 0 deletions datadog_checks_dev/datadog_checks/dev/tooling/e2e/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def agent_command(self):
return get_agent_exe(self.agent_version, platform=self.platform)

def exec_command(self, command, **kwargs):
if command.startswith('pip '):
command = command.replace('pip ', get_pip_exe(self.python_version, self.platform), 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix get_pip_exe for MAC, otherwise it won't work for the majority of us.

Copy link
Contributor

@hithwen hithwen Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exec_command is to run commands in docker not on the local machine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well no this is local environment support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, there is another exec_command in docker.py

Copy link
Contributor

@hithwen hithwen Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for local environment should it use the tox pip rather than the agent pip? In that case its going to be already the right version or at most replace it with python -m pip


return run_command(command, **kwargs)

def write_config(self, config=None):
Expand Down