Fix installing Poetry for Python3#1494
Conversation
Co-Authored-By: Aliaksei Urbanski <mimworkmail@gmail.com>
|
Similar PR: #1042. |
|
|
||
|
|
||
| BIN = """#!/usr/bin/env python | ||
| BIN = """#!/usr/bin/env {python_exe} |
There was a problem hiding this comment.
I would simple replace BIN with f"#!{sys.executable}". What is the purpose of using env ? Why use project python to run poetry ?
There was a problem hiding this comment.
I don't know if replacing BIN with f"#!{sys.executable}" could break the behavior.
Currently, poetry install correctly install the Python packages to pre-selected virtual env. If change to f"#!{sys.executable}", I wonder if that behaviour can still be kept.
There was a problem hiding this comment.
> /home/kamal/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/commands/install.py(52)handle()
-> extras = []
(Pdb) l
47 installer = Installer(
48 self.io, self.env, self.poetry.package, self.poetry.locker, self.poetry.pool
49 )
50 import pdb;pdb.set_trace()
51
52 -> extras = []
53 for extra in self.option("extras"):
54 if " " in extra:
55 extras += [e.strip() for e in extra.split(" ")]
56 else:
57 extras.append(extra)
(Pdb) self.env
VirtualEnv("/home/kamal/python/demo/.venv")
(Pdb) import sys
(Pdb) sys.executable
'/home/kamal/.local/pipx/venvs/poetry/bin/python'
As we can see above, the installer already running with correct venv context, independent of sys.executable.
There was a problem hiding this comment.
Can confirm that this small delta fixes the script:
--- get-poetry.py 2020-03-25 17:06:28.451064345 -0400
+++ get-poetry.py.new 2020-03-25 17:04:19.746420009 -0400
@@ -197,7 +197,7 @@
POETRY_LIB_BACKUP = os.path.join(POETRY_HOME, "lib-backup")
-BIN = """#!/usr/bin/env python
+BIN = f"""#!{sys.executable}
# -*- coding: utf-8 -*-
import glob
import sysalong with invoking the script with python3, on Debian Buster (10.x).
There was a problem hiding this comment.
If so, I opt for f"#!{sys.executable}". The only issue is that f-string can only work with Python 3.6+.
I wonder if @sdispater want to maintain compatibility with Python 3.5. This is the default Python version of Debian Stretch (9).
There was a problem hiding this comment.
Right, in my parallel PR I moved back to a .format() approach, see #2222 .
Happy to close mine if this one has traction, but mine's passing all the tests right now.
| curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python | ||
| ``` | ||
|
|
||
| or, to install Poetry with Python 3: |
There was a problem hiding this comment.
Probably, this should be the first option, as Python 2 is unsupported.
| @@ -27,6 +35,12 @@ If you want to install prerelease versions, you can do so by passing `--preview` | |||
| python get-poetry.py --preview | |||
There was a problem hiding this comment.
It's absolutely not clear from the docs, where to find this get-poetry.py, because curl (or wget) doesn't save it.
There was a problem hiding this comment.
wget https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py(Replace curl -sSL with just wget)
will save the install script to file.
There was a problem hiding this comment.
@hongquan Sure, it will. But documentation just supposes that the file is already there. It can confuse readers.
|
This PR is just great and I'd love to see it merged. Is there anything I could help with, like testing on different systems and Python versions? |
|
Thanks a lot for your contribution. 👍 In the meantime #2547 was created and merged. So I will close this one here. fin swimmer |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Previously, running get-poetry.py with Python 3 didn't give you ability to invoke Poetry with Python 3. This PR is to fix that.
The PR also update installation documentation, giving more examples.
Pull Request Check List