Skip to content

Commit

Permalink
🚩 Poetry is now an optional dependancy
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatXliner committed Jul 4, 2021
1 parent c5e0a0b commit 158c1e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 17 additions & 2 deletions poethepoet/plugin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import shutil
import subprocess
import sys
from pathlib import Path
from typing import Iterator

import tomlkit
from cleo.commands.command import Command
from poetry.console import application as app
from poetry.plugins.application_plugin import ApplicationPlugin

try:
from poetry.console import application as app
from poetry.plugins.application_plugin import ApplicationPlugin
except ModuleNotFoundError:
app = type("application", (), {"Application": None})
ApplicationPlugin = type(
"ApplicationPlugin",
(),
{"PLUGIN_API_VERION": "1.0.0", "type": "application.plugin"},
)

from . import config

Expand All @@ -27,6 +37,11 @@ def run_poe_task(name: str) -> int:

class PoePlugin(ApplicationPlugin):
def activate(self, application: app.Application) -> None:
if app.Application is None:
print(
"Poetry not found. Did you install this plugin via `poetry plugin add poethepoet[poetry_plugin]`?"
)
sys.exit(1)
for task_name in get_poe_task_names(): # Assume this function exists somewhere
application.command_loader.register_factory(
task_name,
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ homepage = "https://github.com/nat-n/poethepoet"
python = "^3.6"
pastel = "^0.2.0"
tomlkit = ">=0.6.0,<1.0.0"
poetry = {version = "^1.1.7", allow-prereleases = true}
poetry = {version = "^1.1.7", allow-prereleases = true, optional = true}

[tool.poetry.extras]
poetry_plugin = ["poetry"]

[tool.poetry.dev-dependencies]
black = "^19.10b0"
Expand Down

0 comments on commit 158c1e7

Please sign in to comment.