Skip to content

Migrate to a src-layout - #196

Open
garrison wants to merge 3 commits into
mainfrom
src-layout
Open

Migrate to a src-layout#196
garrison wants to merge 3 commits into
mainfrom
src-layout

Conversation

@garrison

@garrison garrison commented Jun 30, 2026

Copy link
Copy Markdown
Member

This commit migrates this package to a src-layout, which has a number of advantages. Another advantage is that this change requires fewer mentions of the package name in tox.ini, which means that as addons adopt this change, there will be fewer lines which must diverge among them. In particular, tox.ini no longer contains any references to the package name.

The disadvantage to merging this is that any new files in outstanding pull requests will need to have their locations updated before merging.

This commit migrates this package to a src-layout, which has [a number of
advantages](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/).
Another advantage is that this change requires fewer mentions of the
package name in `tox.ini`, which means that as addons adopt this change,
there will be fewer lines which must diverge among them.

The disadvantage to merging this is that any new files in outstanding
pull requests will need to have their locations updated before merging.
@coveralls

coveralls commented Jun 30, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28464688763

Coverage remained the same at 93.685%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 871
Covered Lines: 816
Line Coverage: 93.69%
Coverage Strength: 0.94 hits per line

💛 - Coveralls

@garrison
garrison marked this pull request as draft June 30, 2026 16:40
garrison added 2 commits June 30, 2026 12:43
Point ruff to `src/qiskit_addon_utils` so qiskit_addon_utils is
classified as a first-party import, fixing the spurious I001 lint
failures.
@garrison
garrison marked this pull request as ready for review June 30, 2026 17:52
@dekelmeirom

dekelmeirom commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

I think that the benefits of this change worth the small disadvantage of changing the current open PRs.
I think we should have a naming convention of the src folder across addons, including those that have a rust core. Currently, the addons which have a rust core already have a folder named src for the rust files.

@mrossinek mrossinek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great, thanks 👍

Two comments:

  1. I agree with @dekelmeirom that it would be great if we can find one working convention for pure-Python as well as mixed Rust+Python repositories. In the latter, src/ would more typically be the location of the Rust code. In qiskit-fermions I use python/ for the Python package and crates/ for the Rust crates (since I have more than one). I am not sure whether using python/ here makes sense though or would be considered confusing 🤔

  2. The other comment is w.r.t. the name of the test-folder. Here we use test which technically conflicts with Python's historical test module. That is why I more commonly use tests (note the plural form). It's technically not the scope of this PR, but on the same topic so I figured I raise this now.

Comment thread pyproject.toml
only-include = [
"qiskit_addon_utils",
packages = [
"src/qiskit_addon_utils",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As part of this PR, we should also re-evaluate whether the following lines are necessary. If they are, the path should be updated.

# The following line is required for autodoc to be able to find and import the code whose API should
# be documented.
sys.path.insert(0, os.path.abspath(".."))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW I tried to locally remove them in my qiskit-fermions clone and the docs still generate just fine! So your hunch with this no longer being required seems correct 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants