Add MANIFEST.in and Make Download Schema Accessible Through Module#156
Merged
Urist-McGit merged 3 commits intosiemens:mainfrom Dec 12, 2025
Merged
Conversation
Contributor
Author
|
Ah, nevermind, this fails in CI: I wonder why it's included in the |
Having a MANIFEST.in file is necessary so that setuptools can figure out what files to include in the final sdist (source distribution). By extension, this also lets Debian tooling like pybuild / dh_python3 [0] infer what to include in the final binary Debian package. The file contains a list of commands, each telling setuptools what files to include or exclude in the sdist. [1] In particular, this file ensures that `src/debsbom/schema/schema-download.json` is included in the final sdist, which is necessary for the `debsbom.schema` module. [0] https://packages.debian.org/dh-python [1] https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html Signed-off-by: Max R. Carrara <max@aequito.sh>
Make `schema` a proper Python module and load `schema-download.json` when the module is imported. This means that the schema can be accessed as a "quasi-constant" via `debsbom.schema.download` (similar to `math.pi`, for example). Note that module-level code is only executed once, namely during the initial import of the module, which means that the file is only loaded into memory once. Signed-off-by: Max R. Carrara <max@aequito.sh>
Instead of loading the download result schema as fixture, access it through the `schema` submodule of `debsbom` directly. This avoids any unexpected errors when running the tests in an environment where the directory structure may be slightly different, for example when building and testing the `debsbom` package using Debian's Python packaging tooling (pybuild specifically). Signed-off-by: Max R. Carrara <max@aequito.sh>
619e8ce to
d232297
Compare
Contributor
Author
|
Alright, seems good now. Sorry for the noise. |
This was referenced Dec 11, 2025
Closed
Urist-McGit
approved these changes
Dec 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While packaging
debsbomfor Debian, I found that some tests would fail when ran bypybuild, because it is assumed thatschema-download.jsonin a fixed path relative to thetests/directory (L270):debsbom/tests/test_download.py
Lines 268 to 273 in d8dd472
So, instead of loading
schema-download.jsonin the fixture, makedebsbom.schemaa proper Python module and load it during module import. This makes the JSON accessible without requiring a specific directory structure.I got the idea for this from the following band-aid fix I used for our internal packaging:
Since that felt a bit too dirty to upstream, I cooked up this PR instead.
Edit: Added acc8e9a, which I was originally planning to add through a separate PR; it adds a
MANIFEST.infile that ensures that everything undersrc/is included in the built package. This is necessary to makeschema-download.jsonaccessible.