Repository: PrefectHQ/prefect

Issue:
deployment step requirement installation only works for a single dependency
### First check

- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the Prefect documentation for this issue.
- [X] I checked that this issue is related to Prefect and not one of its dependencies.

### Bug summary

When specifying more than one dependency in the requirements of a push or pull step, the installation fails.

### Reproduction

Deploy flow with pull or push step with at least 2 requirements in prefect.yaml

```yaml
  requires:
    - prefect-aws==0.4.2
    - mysecondpackage==0.0.1
```


### Error

```python3
Traceback (most recent call last):
  File "prefect/deployments/steps/core.py", line 124, in run_steps
    step_output = await run_step(step, upstream_outputs)
  File "prefect/deployments/steps/core.py", line 94, in run_step
    step_func = _get_function_for_step(fqn, requires=keywords.get("requires"))
  File "prefect/deployments/steps/core.py", line 60, in _get_function_for_step
    subprocess.check_call([sys.executable, "-m", "pip", "install", ",".join(packages)])
  File "python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/bin/python', '-m', 'pip', 'install', 'prefect-aws==0.4.2,mysecondpackage==0.0.1']' returned non-zero exit status 1.
```


### Versions

```Text
Version:             v2.14.6
API version:         0.8.4
Python version:      3.8.15
Git commit:          b99932a4
Built:               Wed, Nov 22, 2023 3:19 PM
OS/Arch:             linux/x86_64
Profile:             default
Server type:         ephemeral
Server:
  Database:          sqlite
  SQLite version:    3.37.2
```


### Additional context

This is because the pip install command is wrongly assembled in https://github.com/PrefectHQ/prefect/blob/e4bda76dc003ed9fc157b39852f2ea8da2c75f29/src/prefect/deployments/steps/core.py#L87
multiple dependencies need to be separated by spaces.


Discussion:

Resolving patch:
diff --git a/src/prefect/deployments/steps/core.py b/src/prefect/deployments/steps/core.py
--- a/src/prefect/deployments/steps/core.py
+++ b/src/prefect/deployments/steps/core.py
@@ -84,7 +84,7 @@ def _get_function_for_step(
 
     try:
         subprocess.check_call(
-            [get_sys_executable(), "-m", "pip", "install", ",".join(packages)]
+            [get_sys_executable(), "-m", "pip", "install", *packages],
         )
     except subprocess.CalledProcessError:
         get_logger("deployments.steps.core").warning(


Test patch:
diff --git a/tests/deployment/test_steps.py b/tests/deployment/test_steps.py
--- a/tests/deployment/test_steps.py
+++ b/tests/deployment/test_steps.py
@@ -177,7 +177,7 @@ async def test_install_multiple_requirements(self, monkeypatch):
 
         import_module_mock.assert_has_calls([call("test_package"), call("another")])
         subprocess.check_call.assert_called_once_with(
-            [sys.executable, "-m", "pip", "install", "test-package>=1.0.0,another"]
+            [sys.executable, "-m", "pip", "install", "test-package>=1.0.0", "another"]
         )
 
     async def test_requirement_installation_failure(self, monkeypatch, caplog):