Skip to content

Commit

Permalink
pkg_resources is optional fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Oct 20, 2023
1 parent 464400a commit 29968f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scooby/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import sys
from typing import Any, Dict, List, Optional

import pkg_resources

import scooby
from scooby.report import Report

Expand Down Expand Up @@ -85,10 +83,18 @@ def act(args_dict: Dict[str, Any]) -> None:
pass

try:
import pkg_resources

# Generate our own report based on package requirements
dist = pkg_resources.get_distribution(report)
dist.requires()
packages = [report] + [pkg.name for pkg in dist.requires()] + packages
except ImportError:
print(
f"Package `{report}` has no report and `pkg_resources` could not be used to autogenerate one.",
file=sys.stderr,
)
sys.exit(1)
except pkg_resources.DistributionNotFound:
print(f"Package `{report}` has no distribution or Report class.", file=sys.stderr)
sys.exit(1)
Expand Down

0 comments on commit 29968f6

Please sign in to comment.