Skip to content

bindings: small improvements to Python API#411

Merged
andrius-puksta-sensmetry merged 3 commits into
mainfrom
sd/python-print-root
Jul 3, 2026
Merged

bindings: small improvements to Python API#411
andrius-puksta-sensmetry merged 3 commits into
mainfrom
sd/python-print-root

Conversation

@simonas-drauksas-sensmetry

@simonas-drauksas-sensmetry simonas-drauksas-sensmetry commented Jun 16, 2026

Copy link
Copy Markdown
Member

This PR contains small Python API improvements that I need for integrating Sysand into Syside ReqIF functionality, namely:

  1. The ability to obtain the project root (Sysand CLI already can do this through print-root, but not in Python)
  2. The ability to obtain a list of dependencies the current project depends on (so I could check if the ReqIF library is imported)

These changes required a bit of changes on the Sysand core / CLI, namely the introduction of "source modes":

  • own, which represents the "I only want to list the included files" and was achievable through CLI as sysand sources --no-deps (still possible)
  • own_with_deps, which is what the default is sysand sources
  • deps, which is new and returns only the dependencies without included files

While the CLI only got a new flag --only-deps and thus there is no breaking change on the CLI side, the Python API lost the include_deps argument and gained no_deps and only_deps instead to better align with the CLI. Not sure if we should consider this a breaking change, or should I try to keep what was already in the Python API?

For context, this is how I would need to get only the deps with the current API:

all_srcs = sysand.sources(root, env_path=root / ".sysand")
own_srcs = sysand.sources(root, env_path=root / ".sysand", include_deps=False)
dep_srcs = [p for p in all_srcs if p not in set(own_srcs)]

While after this PR I will be able to do:

dep_srcs = sysand.sources(root, env_path=root / ".sysand", only_deps=True)

P.S.: The commits are pretty atomic and contain nice commit messages. If not a lot of changes after review are required, I'd like NOT to squash the commits on merge.

@andrius-puksta-sensmetry

Copy link
Copy Markdown
Collaborator

Not sure if we should consider this a breaking change, or should I try to keep what was already in the Python API?

For now I don't consider bindings/core API a part of stability guarantee; too few users to matter.

@andrius-puksta-sensmetry

Copy link
Copy Markdown
Collaborator

gained no_deps and only_deps instead to better align with the CLI

It would be better to use an enum in Python API, otherwise we have to check if both no_deps and only_deps are given. IMO CLI should also change, but since this is breaking, CLI change won't happen until 0.2.0.

Comment thread bindings/py/python/sysand/_model.py Outdated
Comment thread bindings/py/src/lib.rs Outdated
Comment thread core/src/commands/root.rs Outdated

@andrius-puksta-sensmetry andrius-puksta-sensmetry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Implementation is fine, but I really don't like the design and defaults. I'd like to make invalid states unrepresentable, my previous comment details what that would look like.

Bindings can be more or less freely altered (very few users), so I would like bindings to have my proposed design, while CLI will wait until 0.2.0 to match. Alternatively, we could release this now, but I would still like to make the change on the next breaking release, and breaking the functionality soon after releasing it is not appealing.

Comment thread core/src/commands/sources.rs Outdated
Comment thread core/src/commands/sources.rs Outdated
@andrius-puksta-sensmetry andrius-puksta-sensmetry changed the title Small improvements to Python API bindings: small improvements to Python API Jun 26, 2026
Signed-off-by: Simonas Drauksas <simonas.drauksas@sensmetry.com>
Signed-off-by: Simonas Drauksas <simonas.drauksas@sensmetry.com>
…n API

Signed-off-by: Simonas Drauksas <simonas.drauksas@sensmetry.com>
@simonas-drauksas-sensmetry simonas-drauksas-sensmetry force-pushed the sd/python-print-root branch 2 times, most recently from db076d3 to d76abd1 Compare July 2, 2026 13:03
@andrius-puksta-sensmetry andrius-puksta-sensmetry marked this pull request as ready for review July 3, 2026 05:01
@andrius-puksta-sensmetry andrius-puksta-sensmetry enabled auto-merge (rebase) July 3, 2026 05:02
@andrius-puksta-sensmetry andrius-puksta-sensmetry merged commit b8310ea into main Jul 3, 2026
57 checks passed
@andrius-puksta-sensmetry andrius-puksta-sensmetry deleted the sd/python-print-root branch July 3, 2026 05:06
@andrius-puksta-sensmetry andrius-puksta-sensmetry added the enhancement New feature or request label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants