Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/+core-template-dependencies.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Parts of the SDK no longer fail to import on a plain `pip install infrahub-sdk`.

`infrahub_sdk.template`, `infrahub_sdk.yaml`, `infrahub_sdk.spec`, `infrahub_sdk.transfer` and `infrahub_sdk.protocols_generator` import Jinja2, PyYAML and rich, but those three were only installed by the `ctl` extra. Using any of them without that extra raised `ModuleNotFoundError`, even though none of it is CLI-specific: `template` renders your Transforms, and rich supplies the traceback types carried in Jinja error reporting.

All three are now installed with the SDK itself, so a plain install grows from 19 to 26 packages. The `ctl` extra is correspondingly smaller and now covers only what `infrahubctl` genuinely needs.
7 changes: 7 additions & 0 deletions changelog/+dependency-lower-bounds.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`infrahub-sdk` now requires `pydantic>=2.0.3`, up from `>=2.0.0`.

If you pin `pydantic` to 2.0, 2.0.1 or 2.0.2, installing the SDK now fails while resolving dependencies. Those versions never actually worked: `import infrahub_sdk` raised a `SchemaError` on them, because their regex engine rejects a pattern used by the schema models. Pin `pydantic>=2.0.3` to resolve it.

`anyio` and `typing-extensions` are now installed as direct requirements of the SDK itself. It has always imported them but relied on other packages to pull them in, so a minimal or heavily constrained environment could end up with the SDK installed and unusable. No action is needed, installs simply become reliable.

`packaging` is now a direct requirement of the `tests` extra, which is where the `infrahub_sdk.testing` helpers that import it live. A plain `pip install infrahub-sdk` does not install it.
1 change: 1 addition & 0 deletions changelog/+packaging-metadata-tests.housekeeping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added unit tests over the packaging metadata so the declared dependencies stay honest. They check that every requirement has a lower bound, that the `all` extra keeps covering the other extras, and that the packages the SDK imports and the packages it declares match each other.
3 changes: 3 additions & 0 deletions changelog/+rich-upper-bound.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The `rich` requirement is now `>=12` with no upper bound, so the SDK can be installed alongside rich 14 and later.

The previous `<14` cap would otherwise have applied to every install rather than only those using the `infrahubctl` CLI, and would have conflicted with any project already on a newer rich. The SDK's unit tests pass against rich 13, 14 and 15.
5 changes: 5 additions & 0 deletions changelog/+tests-extra.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
`pip install 'infrahub-sdk[tests]'` now works. The `tests` extra is described in the installation guide but was never actually published, so the command warned that no such extra existed and installed nothing beyond the base package.

Install it if you use the `pytest-infrahub` plugin to test Transforms, Queries and Checks, or the `infrahub_sdk.testing` helpers. Previously you had to work out the missing requirements and declare them yourself.

Be aware that it is a large install, adding around 61 packages on top of the base SDK, among them Docker, FastAPI and Prefect client libraries. These come from the `infrahub_sdk.testing` helpers, which run Infrahub in containers. If you only need the `infrahubctl` CLI, install `infrahub-sdk[ctl]` instead. `infrahub-sdk[all]` now covers both `ctl` and `tests`, so it pulls in considerably more than it used to.
5 changes: 5 additions & 0 deletions changelog/+unused-extra-dependencies.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
`numpy` and `mdxify` are no longer installed by the `ctl` and `all` extras.

Neither is used by the SDK. `numpy` was only ever needed because older `pyarrow` releases required it, and `pyarrow` still installs it itself on the versions that do. `mdxify` is a documentation tool used when building these docs, not at runtime.

If your project imports either package directly, add it to your own dependencies rather than relying on `infrahub-sdk[ctl]` to supply it.
6 changes: 6 additions & 0 deletions docs/docs/python-sdk/guides/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ The `tests` extra provides all the components for the testing framework of Trans
pip install 'infrahub-sdk[tests]'
```

:::note

This extra is much larger than the others. The `infrahub_sdk.testing` helpers run Infrahub in containers, which adds roughly 61 packages on top of the base SDK. Install the `ctl` extra on its own if you only need the `infrahubctl` command.

:::

<!-- vale off -->

### all
Expand Down
44 changes: 25 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ classifiers = [
"Programming Language :: Python :: 3.14",
]
dependencies = [
"pydantic>=2.0.0,!=2.0.1,!=2.1.0,<3.0.0",
# 2.0 and 2.0.2 cannot build the generated schema models: their regex engine rejects the
# `\_` escape in the model field patterns, so `import infrahub_sdk` fails outright.
"pydantic>=2.0.3,!=2.1.0,<3.0.0",
"pydantic-settings>=2.0",
"graphql-core>=3.1,<3.3",
"httpx>=0.20",
"anyio>=3.3.0", # 3.3.0 introduced `anyio.Path`, used by the async file handler
"typing-extensions>=4.4.0", # 4.4.0 introduced PEP 696 `TypeVar(default=...)`
"Jinja2>=3", # template rendering in `template/` and `protocols_generator/`
"pyyaml>=6", # YAML parsing in `yaml.py`, `spec/`, `template/infrahub_filters.py` and the pytest plugin
"rich>=12", # `Traceback`/`Frame`/`Syntax` in the Jinja error model, and transfer progress bars
"ujson>=5",
"dulwich>=0.24.7",
"whenever>=0.9.3,<0.10.0",
Expand All @@ -42,31 +49,26 @@ infrahubctl = "infrahub_sdk.ctl.cli:app"

[project.optional-dependencies]
ctl = [
"Jinja2>=3",
"numpy>=1.24.2; python_version<'3.12'",
"numpy>=1.26.2; python_version>='3.12'",
"pyarrow>=14",
"pyyaml>=6",
"ruamel.yaml>=0.18",
"rich>=12,<14",
"ruamel.yaml>=0.18", # round-trip mode preserves comments when `schema format` rewrites a file
"typer>=0.15.0",
# Not imported directly; constrains the `click` that `typer` resolves to.
"click>=8.3,<9",
"ariadne-codegen==0.18.0",
"mdxify>=0.2.23; python_version>='3.10'",
]

# The user-facing testing surface: `infrahub_sdk.testing` and the bundled `pytest-infrahub`
# plugin. Both ship in the wheel but import packages that no other extra installs. Distinct from
# the `tests` dependency group below, which is the tooling used to test the SDK itself.
tests = [
"infrahub-testcontainers>=1.7.3",
"packaging>=21.0",
"pytest>=7.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Custom agent: Detect conflicting package versions across dependency files

The new tests extra declares pytest>=7.0, but the same file's tests dependency group declares pytest>=9.0,<9.1. Align these pytest specifiers or otherwise avoid declaring conflicting versions in the same dependency metadata.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pyproject.toml, line 66:

<comment>The new `tests` extra declares `pytest>=7.0`, but the same file's `tests` dependency group declares `pytest>=9.0,<9.1`. Align these pytest specifiers or otherwise avoid declaring conflicting versions in the same dependency metadata.</comment>

<file context>
@@ -43,30 +47,28 @@ infrahubctl = "infrahub_sdk.ctl.cli:app"
+tests = [
+    "infrahub-testcontainers>=1.7.3",
+    "packaging>=21.0",
+    "pytest>=7.0",
+]
+
</file context>

]

# Self-referential so it cannot drift out of sync with the extras it aggregates.
all = [
"Jinja2>=3",
"numpy>=1.24.2; python_version<'3.12'",
"numpy>=1.26.2; python_version>='3.12'",
"pyarrow>=14",
"pytest",
"pyyaml>=6",
"ruamel.yaml>=0.18",
"rich>=12,<14",
"typer>=0.15.0",
"click>=8.3,<9",
"ariadne-codegen==0.18.0",
"infrahub-sdk[ctl,tests]",
]

[dependency-groups]
Expand Down Expand Up @@ -94,10 +96,14 @@ types = [
"types-pyyaml",
"types-python-slugify>=8.0.0.3",
]
docs = [
"mdxify>=0.2.23",
]
dev = [
{include-group = "tests"},
{include-group = "lint"},
{include-group = "types"},
{include-group = "docs"},
"ipython",
"requests>=2.33.0",
"prek>=0.3.0",
Expand Down
4 changes: 4 additions & 0 deletions tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
TEST_DIR = Path(__file__).parent
FIXTURES_DIR = TEST_DIR / "fixtures"
FIXTURE_REPOS_DIR = FIXTURES_DIR / "repos"

REPO_ROOT = TEST_DIR.parent
PACKAGE_DIR = REPO_ROOT / "infrahub_sdk"
PYPROJECT_FILE = REPO_ROOT / "pyproject.toml"
Loading
Loading