Repository: python-poetry/poetry

Issue:
`poetry env use` on Windows needs to deal with spaces in path or take a command line list
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [ ] ~~If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).~~

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: Windows 10 1909 x64
- **Poetry version**: 1.0.0
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: N/A

## Issue
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->

On Windows, Python is typically installed into `C:\Program Files`, i.e. `C:\Program Files\Python38\python.exe`. Attempting to make poetry use it rather than the Python it is installed for results in:

```
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

[EnvCommandError]
Command C:\Program Files\Python38\python.exe -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return 
code 1, and output:
```

In this case, the path must be treated as `["C:\\Program Files\\Python38\\python.exe"]`.

Python for Windows also comes with the `py` program for selecting which installed Python gets called. You can call it like `py` and it will start the latest Python, or like `py -2.7-32` to start that other thing. In that case, the string must be interpreted as `["py", "-2.7-32"]`


Discussion:

Resolving patch:
diff --git a/poetry/utils/env.py b/poetry/utils/env.py
--- a/poetry/utils/env.py
+++ b/poetry/utils/env.py
@@ -190,7 +190,7 @@ def activate(self, python, io):  # type: (str, IO) -> Env
         try:
             python_version = decode(
                 subprocess.check_output(
-                    " ".join(
+                    list_to_shell_command(
                         [
                             python,
                             "-c",
@@ -427,7 +427,7 @@ def remove(self, python):  # type: (str) -> Env
         try:
             python_version = decode(
                 subprocess.check_output(
-                    " ".join(
+                    list_to_shell_command(
                         [
                             python,
                             "-c",
@@ -496,7 +496,7 @@ def create_venv(
         if executable:
             python_patch = decode(
                 subprocess.check_output(
-                    " ".join(
+                    list_to_shell_command(
                         [
                             executable,
                             "-c",
@@ -553,7 +553,7 @@ def create_venv(
                 try:
                     python_patch = decode(
                         subprocess.check_output(
-                            " ".join(
+                            list_to_shell_command(
                                 [
                                     python,
                                     "-c",
@@ -638,7 +638,9 @@ def build_venv(cls, path, executable=None):
             # Create virtualenv by using an external executable
             try:
                 p = subprocess.Popen(
-                    " ".join([executable, "-"]), stdin=subprocess.PIPE, shell=True
+                    list_to_shell_command([executable, "-"]),
+                    stdin=subprocess.PIPE,
+                    shell=True,
                 )
                 p.communicate(encode(CREATE_VENV_COMMAND.format(path)))
             except CalledProcessError as e:


Test patch: