From 2966ab177206e8f8f888f6050a5f39b18cbda16b Mon Sep 17 00:00:00 2001 From: David Cramer Date: Thu, 10 Oct 2019 10:36:51 -0400 Subject: [PATCH] Support POETRY_HOME for install (#794) 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 9e4f35cf2ee..fc28d7e1a93 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`. - Added support for declaring a specific source for dependencies. - Added support for disabling PyPI and making another repository the default one. - Added support for declaring private repositories as secondary. diff --git a/docs/docs/index.md b/docs/docs/index.md index 2d4d12a0bf6..66fb0ade021 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 e369c866d32..e6cbe6db8fb 100644 --- a/get-poetry.py +++ b/get-poetry.py @@ -187,7 +187,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")