Skip to content

Commit 2523bf1

Browse files
Move BuiltinConfigurationProviderInterface to a separate top level package that does not have any dependencies. Having it be part of the package makes it very difficult to avoid circular dependencies.
1 parent 80787a6 commit 2523bf1

File tree

9 files changed

+49
-12
lines changed

9 files changed

+49
-12
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ::: planet_auth_config_injection
2+
options:
3+
show_root_full_path: true
4+
inherited_members: true
5+
show_submodules: true
6+
show_if_no_docstring: false

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ nav:
8080
- API Reference:
8181
- Planet Auth: 'api-planet-auth.md'
8282
- Planet Auth Utils: 'api-planet-auth-utils.md'
83+
- Planet Auth Config Injection: 'api-planet-auth-config-injection.md'
8384
- Examples:
8485
- Installation: 'examples-installation.md'
8586
- CLI: 'examples-cli.md'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2025 Planet Labs PBC.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
# The Planet Authentication Library Configration Injection Package: `planet_auth_config_injection`
17+
18+
This package provides interfaces and utilities for higher-level applications
19+
to inject configuration into the Planet Authentication Library.
20+
"""
21+
22+
from .builtins_provider import (
23+
AUTH_BUILTIN_PROVIDER,
24+
BuiltinConfigurationProviderInterface,
25+
EmptyBuiltinProfileConstants,
26+
)
27+
28+
__all__ = [
29+
"AUTH_BUILTIN_PROVIDER",
30+
"BuiltinConfigurationProviderInterface",
31+
"EmptyBuiltinProfileConstants",
32+
]

src/planet_auth_utils/builtins_provider.py renamed to src/planet_auth_config_injection/builtins_provider.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
# users.
2323
AUTH_BUILTIN_PROVIDER = "PL_AUTH_BUILTIN_CONFIG_PROVIDER"
2424
"""
25-
Specify a python module and class that implement the BuiltinConfigurationProviderInterface abstract
26-
interface to provide the library and utility commands with some built-in configurations.
25+
Environment variable to specify a python module and class that implement the
26+
BuiltinConfigurationProviderInterface abstract interface to provide the library
27+
and utility commands with some built-in configurations.
2728
"""
2829

2930
_NOOP_AUTH_CLIENT_CONFIG = {

src/planet_auth_utils/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@
9999
from .commands.cli.util import recast_exceptions_to_click
100100
from planet_auth_utils.constants import EnvironmentVariables
101101
from planet_auth_utils.plauth_factory import PlanetAuthFactory
102-
from planet_auth_utils.builtins import (
103-
Builtins,
104-
# Easily causes circular dependencies. Intentionally not part of the main package interface for now.
105-
# BuiltinConfigurationProviderInterface,
106-
)
102+
from planet_auth_utils.builtins import Builtins
107103
from planet_auth_utils.profile import Profile
108104
from planet_auth_utils.plauth_user_config import PlanetAuthUserConfig
109105

@@ -165,7 +161,6 @@
165161
"recast_exceptions_to_click",
166162
#
167163
"Builtins",
168-
# "BuiltinConfigurationProviderInterface",
169164
"EnvironmentVariables",
170165
"PlanetAuthFactory",
171166
"Profile",

src/planet_auth_utils/builtins.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from planet_auth import AuthClientConfig
1919
from planet_auth_utils.profile import ProfileException
2020
from planet_auth.logging.auth_logger import getAuthLogger
21-
from .builtins_provider import (
21+
from planet_auth_config_injection import (
2222
BuiltinConfigurationProviderInterface,
2323
EmptyBuiltinProfileConstants,
2424
AUTH_BUILTIN_PROVIDER,
@@ -36,6 +36,7 @@ def _load_builtins_worker(builtin_provider_fq_class_name, log_warning=False):
3636
return
3737

3838
module_name, _, class_name = builtin_provider_fq_class_name.rpartition(".")
39+
auth_logger.debug(msg=f'Loading built-in provider:"{builtin_provider_fq_class_name}".')
3940
if module_name and class_name:
4041
try:
4142
builtin_provider_module = importlib.import_module(module_name) # nosemgrep - WARNING - See below
@@ -89,6 +90,7 @@ class Builtins:
8990
def _load_builtin_jit():
9091
if not Builtins._builtin:
9192
Builtins._builtin = _load_builtins()
93+
auth_logger.debug(msg=f"Successfully loaded built-in provider: {Builtins._builtin.__class__.__name__}")
9294

9395
@staticmethod
9496
def is_builtin_profile(profile: str) -> bool:

tests/test_planet_auth_utils/unit/auth_utils/builtins_test_impl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from typing import Dict, List, Optional
16-
from planet_auth_utils.builtins_provider import BuiltinConfigurationProviderInterface
16+
from planet_auth_config_injection import BuiltinConfigurationProviderInterface
1717

1818

1919
class MockStagingEnv:

tests/test_planet_auth_utils/unit/auth_utils/test_builtins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import pytest
1717
import unittest
1818

19-
from planet_auth_utils.builtins_provider import AUTH_BUILTIN_PROVIDER
19+
from planet_auth_config_injection import AUTH_BUILTIN_PROVIDER
2020
from planet_auth_utils.builtins import Builtins, BuiltinsException
2121

2222
from tests.test_planet_auth_utils.util import TestWithHomeDirProfiles

tests/test_planet_auth_utils/unit/auth_utils/test_plauth_factory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import planet_auth.storage_utils
2121
from planet_auth.constants import AUTH_CONFIG_FILE_PLAIN
2222

23-
from planet_auth_utils.builtins_provider import AUTH_BUILTIN_PROVIDER
23+
from planet_auth_config_injection import AUTH_BUILTIN_PROVIDER
2424
from planet_auth_utils.builtins import Builtins
2525
from planet_auth_utils.constants import EnvironmentVariables
2626
from planet_auth_utils.plauth_factory import PlanetAuthFactory, MissingArgumentException

0 commit comments

Comments
 (0)