From 424646d4df5b3d0809ed6a751602a1d816217772 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Sun, 13 Jan 2019 10:17:54 -0800 Subject: [PATCH] Support POETRY_HOME for install Allow the `POETRY_HOME` environment variable to be passed during installation to change the default installation directory of `~/.poetry`: ``` POETRY_HOME=/etc/poetry python get-poetry.py ``` --- CHANGELOG.md | 1 + docs/docs/index.md | 6 ++++++ get-poetry.py | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca5f24aabfa..9298df0268c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Added a `env use` command to control the Python version used by the project. - Added a `env list` command to list the virtualenvs associated with the current project. - Added a `env remove` command to delete virtualenvs associated with the current project. +- Added support for `POETRY_HOME` declaration within `get-poetry.py`. ### Changed diff --git a/docs/docs/index.md b/docs/docs/index.md index 62fa34d7f54..403a5fe42b4 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -46,6 +46,12 @@ python get-poetry.py --uninstall POETRY_UNINSTALL=1 python get-poetry.py ``` +By default, Poetry is installed into the user's platform-specific home directory. If you wish to change this, you may define the `POETRY_HOME` environment variable: + +```bash +POETRY_HOME=/etc/poetry python get-poetry.py +``` + If you want to install prerelease versions, you can do so by passing `--preview` to `get-poetry.py` or by using the `POETRY_PREVIEW` environment variable: diff --git a/get-poetry.py b/get-poetry.py index 2ebb45e30cb..9f924513cd0 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -183,7 +183,7 @@ def expanduser(path): HOME = expanduser("~") -POETRY_HOME = os.path.join(HOME, ".poetry") +POETRY_HOME = os.environ.get("POETRY_HOME") or os.path.join(HOME, ".poetry") POETRY_BIN = os.path.join(POETRY_HOME, "bin") POETRY_ENV = os.path.join(POETRY_HOME, "env") POETRY_LIB = os.path.join(POETRY_HOME, "lib")