2525from collections .abc import Generator
2626from os .path import dirname , join
2727from typing import TYPE_CHECKING , Any , AnyStr
28+ from pathlib import PurePosixPath , Path
2829
2930from cyclonedx .model import AttachedText , Encoding
3031from cyclonedx .model .license import DisjunctiveLicense , LicenseAcknowledgement
@@ -55,7 +56,7 @@ def project2licenses(project: dict[str, Any], lfac: 'LicenseFactory',
5556 # https://peps.python.org/pep-0639/#add-license-files-key
5657 plfiles_root = dirname (fpath )
5758 for plfile_glob in plfiles :
58- for plfile in glob (plfile_glob , root_dir = plfiles_root , recursive = True ):
59+ for plfile in glob (join ( * PurePosixPath ( plfile_glob ). parts ) , root_dir = plfiles_root , recursive = True ):
5960 # per spec:
6061 # > Tools MUST assume that license file content is valid UTF-8 encoded text
6162 # anyway, we don't trust this and assume binary
@@ -68,7 +69,7 @@ def project2licenses(project: dict[str, Any], lfac: 'LicenseFactory',
6869 continue
6970 with plicense_fileh :
7071 content = plicense_fileh .read ()
71- yield _make_license_from_content (plfile , content , lack )
72+ yield _make_license_from_content ('/' . join ( Path ( plfile ). parts ) , content , lack )
7273 # Silently skip any other types (including string/PEP 621)
7374 return None
7475
0 commit comments