Skip to content

Support pydantic>=2.0.0 #58

Closed
Closed

Description

Currently, a pip install planetary-computer followed by planetarycomputer configure will fail, because pydantic split settings into a separate package:

» planetarycomputer configure
Traceback (most recent call last):
  File "/home/taugspurger/src/Microsoft/planetary-computer-sdk-for-python/.direnv/python-3.10.10/bin/planetarycomputer", line 5, in <module>
    from planetary_computer.scripts.cli import app
  File "/home/taugspurger/src/Microsoft/planetary-computer-sdk-for-python/planetary_computer/__init__.py", line 4, in <module>
    from planetary_computer.sas import (
  File "/home/taugspurger/src/Microsoft/planetary-computer-sdk-for-python/planetary_computer/sas.py", line 20, in <module>
    from planetary_computer.settings import Settings
  File "/home/taugspurger/src/Microsoft/planetary-computer-sdk-for-python/planetary_computer/settings.py", line 11, in <module>
    class Settings(pydantic.BaseSettings):
  File "/home/taugspurger/src/Microsoft/planetary-computer-sdk-for-python/.direnv/python-3.10.10/lib/python3.10/site-packages/pydantic/__init__.py", line 206, in __getattr__
    return _getattr_migration(attr_name)
  File "/home/taugspurger/src/Microsoft/planetary-computer-sdk-for-python/.direnv/python-3.10.10/lib/python3.10/site-packages/pydantic/_migration.py", line 279, in wrapper
    raise PydanticImportError(
pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.0/migration/#basesettings-has-moved-to-pydantic-settings for more details.

A temporary workaround for users is to pip install planetary-computer pydantic-settings.


I'm not sure how to fix this. I'd rather not put a hard requirement on pydantic>=2.0.0, in case there are downstream dependencies unable to migrate. I don't think there's a way to use environment markers to specify an optional dependency, which is only needed depending on the version of some other package.

Ideally pydantic would provide some kind of pydantic[settings] extra that worked with both 1.x and 2.x.

It's probably easiest to just remove the usage of pydantic and drop the dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions