Skip to content

Stac command crashes when installed in clean venv without [validate] option #477

Open
@matthewscottgordon

Description

@matthewscottgordon

Describe the bug
The test_data data uses the requests library but it is not listed as a required dependency. If requests is not installed, stac crashes while loading plugins.

To reproduce
Steps to reproduce the behavior:

  1. Create a fresh virtual environment and activate it. (e.g. python -m venv ./test_venv && source ./test_venv/bin/activate)
  2. Use pip to install stactools without the [validate] option. (e.g. pip install stactools or pip install 'stactools[s3]'
  3. Try to run stac. (e.g. stac --help)
  4. stac throws a ModuleNotFoundError.

Expected behavior
I should be able to run stac --help.

Screenshots and shell session dumps

> ../venv/bin/stac --help            
Traceback (most recent call last):
  File "/home/mgordon/tmp/stactools/../venv/bin/stac", line 5, in <module>
    from stactools.cli.cli import run_cli
  File "/home/mgordon/tmp/venv/lib/python3.12/site-packages/stactools/cli/__init__.py", line 110, in <module>
    registry.load_plugins()
  File "/home/mgordon/tmp/venv/lib/python3.12/site-packages/stactools/cli/registry.py", line 43, in load_plugins
    name: importlib.import_module(name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgordon/tmp/venv/lib/python3.12/site-packages/stactools/testing/__init__.py", line 4, in <module>
    from .test_data import TestData
  File "/home/mgordon/tmp/venv/lib/python3.12/site-packages/stactools/testing/test_data.py", line 9, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions