summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2024-07-28 13:29:59 +0200
committerGravatar Johannes Christ <[email protected]>2024-07-28 13:29:59 +0200
commit271b36bf1c1493dc09a1e05d7caf66f740d298dc (patch)
treee20b59023a816a9afa688dc745f884fd93f73728
parentDevelop on alpha 3 (diff)
Add escape hatch via POETRY_NO_RESTRICT=1
-rw-r--r--README.md7
-rw-r--r--poetry_restrict_plugin/plugin.py7
2 files changed, 14 insertions, 0 deletions
diff --git a/README.md b/README.md
index 15089ce..e5529bd 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,13 @@ For other installation methods, see the [Poetry plugin
documentation](https://python-poetry.org/docs/plugins/#using-plugins).
+## Usage
+
+The plugin will automatically run whenever you invoke poetry. If you run into an
+error with it and need an escape hatch, you can re-run your command with the
+environment variable `POETRY_NO_RESTRICT=1` set.
+
+
## Disclaimer
`poetry-restrict-plugin` is not a perfect sandbox, and probably never will be.
diff --git a/poetry_restrict_plugin/plugin.py b/poetry_restrict_plugin/plugin.py
index 4c59bbc..652f7a2 100644
--- a/poetry_restrict_plugin/plugin.py
+++ b/poetry_restrict_plugin/plugin.py
@@ -92,6 +92,13 @@ class RestrictPlugin(Plugin):
ruleset.apply()
def activate(self, poetry: Poetry, io: IO):
+ if os.getenv("POETRY_NO_RESTRICT") == "1":
+ io.write_line(
+ "<info>poetry-restrict-plugin</info>: "
+ "<comment>Disabled via POETRY_NO_RESTRICT environment variable!</comment>"
+ )
+ return
+
try:
self.landlock(poetry)
io.write_line("<info>poetry-restrict-plugin</info>: Landlock engaged.")