Skip to content

Commit 294b446

Browse files
committed
Temporary skip test on Windows
Until official spdx-python-model 0.0.6 release Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent 85e16d0 commit 294b446

5 files changed

Lines changed: 54 additions & 4 deletions

File tree

.github/workflows/install_and_test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ jobs:
3636
python -m pip install tzdata
3737
python -m pip install networkx
3838
shell: bash
39+
- name: Install SPDX 3 bindings
40+
# The spdx-python-model bindings are built from git and their build-time
41+
# code generation does not currently work on Windows; install them only
42+
# where they build so the SPDX 3 tests run there (and are skipped elsewhere).
43+
if: runner.os != 'Windows'
44+
run: python -m pip install ".[spdx3]"
45+
shell: bash
3946
- name: Run tests
4047
run: pytest
4148
- name: Run CLI

pyproject.toml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,22 @@ dependencies = [
3737
"pyyaml",
3838
"rdflib",
3939
"semantic_version",
40-
"spdx-python-model @ git+https://github.com/spdx/spdx-python-model.git@main",
4140
"uritools",
4241
"xmltodict",
4342
]
4443
dynamic = ["version"]
4544

4645
[project.optional-dependencies]
4746
test = ["pyshacl", "pytest", "tzdata"]
48-
code_style = ["black", "flake8", "isort"]
47+
code_style = ["black", "flake8", "isort", "mypy"]
4948
graph_generation = ["networkx", "pygraphviz"]
50-
development = ["black", "flake8", "isort", "networkx", "pyshacl", "pytest"]
49+
# Experimental SPDX 3.0 support is built on the spdx-python-model bindings.
50+
# It is an optional extra (not a core dependency) because the bindings are not
51+
# yet published to PyPI and must be built from git, where the build-time code
52+
# generation does not currently work on Windows. Keeping it optional ensures the
53+
# core package installs on all platforms. Install with: pip install ".[spdx3]"
54+
spdx3 = ["spdx-python-model @ git+https://github.com/spdx/spdx-python-model.git@main"]
55+
development = ["black", "flake8", "isort", "mypy", "networkx", "pyshacl", "pytest"]
5156

5257
[project.scripts]
5358
pyspdxtools = "spdx_tools.spdx.clitools.pyspdxtools:main"
@@ -60,6 +65,31 @@ Repository = "https://github.com/spdx/tools-python.git"
6065
Issues = "https://github.com/spdx/tools-python/issues"
6166
Changelog = "https://github.com/spdx/tools-python/blob/main/CHANGELOG.md"
6267

68+
[tool.mypy]
69+
python_version = "3.10"
70+
strict = true
71+
mypy_path = "src"
72+
explicit_package_bases = true
73+
# The new SPDX 3 code is fully typed and checked under --strict.
74+
# The legacy SPDX 2 modules are not strict-clean yet and are out of scope here;
75+
# they are excluded below so they don't mask issues in the new code.
76+
files = [
77+
"src/spdx_tools/spdx3/formats.py",
78+
"src/spdx_tools/spdx3/parser",
79+
]
80+
81+
# spdx-python-model ships a py.typed marker but its generated bindings expose
82+
# many attributes as Any; this keeps strict checks meaningful without noise.
83+
[[tool.mypy.overrides]]
84+
module = ["spdx_python_model.*"]
85+
ignore_missing_imports = true
86+
87+
# Pre-existing SPDX 2 code imported by the new modules (e.g. SPDXParsingError)
88+
# is not yet strict-typed; do not fail the new-code check on it.
89+
[[tool.mypy.overrides]]
90+
module = ["spdx_tools.spdx.*"]
91+
ignore_errors = true
92+
6393
[tool.setuptools]
6494
include-package-data = true
6595

src/spdx_tools/spdx3/parser/json_ld/json_ld_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def parse_from_file(file_name: str, encoding: str = "utf-8") -> spdx_3_0.SHACLObjectSet:
99
"""Read a SPDX 3 JSON-LD file into a SHACLObjectSet (the in-memory representation
1010
provided by the spdx-python-model bindings)."""
11-
object_set = spdx_3_0.SHACLObjectSet()
11+
object_set: spdx_3_0.SHACLObjectSet = spdx_3_0.SHACLObjectSet()
1212
try:
1313
# The binding's deserializer reads from a binary stream.
1414
with open(file_name, "rb") as file:

src/spdx_tools/spdx3/parser/parse_anything.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from spdx_tools.spdx3.formats import FileFormat, file_name_to_format
66
from spdx_tools.spdx3.parser.json_ld import json_ld_parser
7+
from spdx_tools.spdx.parser.error import SPDXParsingError
78

89

910
def parse_file(file_name: str, encoding: str = "utf-8") -> spdx_3_0.SHACLObjectSet:
@@ -15,3 +16,4 @@ def parse_file(file_name: str, encoding: str = "utf-8") -> spdx_3_0.SHACLObjectS
1516
input_format = file_name_to_format(file_name)
1617
if input_format == FileFormat.JSON_LD:
1718
return json_ld_parser.parse_from_file(file_name, encoding)
19+
raise SPDXParsingError([f"Unsupported SPDX 3 file format: {input_format}"])

tests/spdx3/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: 2026-present SPDX contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# The SPDX 3 support depends on the optional `spdx-python-model` bindings, which
5+
# are not installed by default and currently cannot be built from git on Windows.
6+
# When the bindings are unavailable, skip collecting the SPDX 3 test suite instead
7+
# of failing at import time.
8+
try:
9+
import spdx_python_model # noqa: F401
10+
except ImportError:
11+
collect_ignore_glob = ["*"]

0 commit comments

Comments
 (0)