Skip to content

Commit bd36c8b

Browse files
Merge pull request #3757 from nexB/improve-pypi-package-detection
Upgrade python package detection
2 parents 60b0e0f + 56aa35d commit bd36c8b

File tree

92 files changed

+9842
-855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+9842
-855
lines changed

.github/workflows/scancode-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ jobs:
235235
strategy:
236236
fail-fast: true
237237
matrix:
238-
os: [ubuntu-22.04, ubuntu-22.04, macos-11, macos-12]
238+
os: [ubuntu-22.04, ubuntu-22.04, macos-12, macos-13]
239239
pyver: ["3.8", "3.9", "3.10", "3.11", "3.12"]
240240

241241
steps:
@@ -367,7 +367,7 @@ jobs:
367367
strategy:
368368
fail-fast: true
369369
matrix:
370-
os: [macos-11, macos-12]
370+
os: [macos-12, macos-13]
371371
pyver: ["3.8", "3.9", "3.10", "3.11", "3.12"]
372372

373373
steps:

CHANGELOG.rst

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ v33.0.0 (next next, roadmap)
4646
from swift `swift-show-dependencies.deplock` generated by DepLock.
4747
See https://github.com/nexB/scancode-toolkit/pull/3829
4848

49+
- Add support for `pip-inspect.deplock` files to parse and store
50+
resolved packages and dependency relationships, to statically
51+
resolve a python dependency graph.
52+
See https://github.com/nexB/scancode.io/issues/1262
53+
54+
- Add support for poetry packages, with poetry specific pyproject.toml
55+
support, poetry.lock and package assembly support. Also add support
56+
for parsing and storing resolved packages and dependency relationships
57+
required to statically resolve poetry dependecy graphs.
58+
See https://github.com/nexB/scancode-toolkit/issues/2109
59+
60+
- Add support for pyproject.toml files in python projects.
61+
See https://github.com/nexB/scancode-toolkit/issues/3753
62+
4963
v32.2.0 - 2024-06-19
5064
----------------------
5165

azure-pipelines.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,20 @@ jobs:
111111

112112
- template: etc/ci/azure-posix.yml
113113
parameters:
114-
job_name: macos11_cpython
115-
python_architecture: x64
116-
image_name: macOS-11
114+
job_name: macos12_cpython
115+
image_name: macOS-12
117116
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
117+
python_architecture: x64
118118
test_suites:
119119
all: venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py --reruns 2
120120

121121
- template: etc/ci/azure-posix.yml
122122
parameters:
123-
job_name: macos12_cpython
124-
image_name: macOS-12
123+
job_name: macos13_cpython
124+
image_name: macOS-13
125125
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
126-
python_architecture: x64
127126
test_suites:
128-
all: venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py --reruns 2
127+
all: venv/bin/pytest -n 2 -vvs
129128

130129
- template: etc/ci/azure-win.yml
131130
parameters:
@@ -204,19 +203,19 @@ jobs:
204203
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
205204
test_suites:
206205
all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e .[testing] && venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py
207-
206+
208207
- template: etc/ci/azure-posix.yml
209208
parameters:
210-
job_name: macos11_cpython_latest_from_pip
211-
image_name: macos-11
209+
job_name: macos12_cpython_latest_from_pip
210+
image_name: macos-12
212211
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
213212
test_suites:
214213
all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e .[testing] && venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py
215214

216215
- template: etc/ci/azure-posix.yml
217216
parameters:
218-
job_name: macos12_cpython_latest_from_pip
219-
image_name: macos-12
217+
job_name: macos13_cpython_latest_from_pip
218+
image_name: macos-13
220219
python_versions: ['3.8', '3.9', '3.10', '3.11', '3.12']
221220
test_suites:
222221
all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e .[testing] && venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py

docs/source/reference/available_package_parsers.rst

+25-1
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,12 @@ parsers in scancode-toolkit during documentation builds.
587587
- ``nuget_nupsec``
588588
- None
589589
- https://docs.microsoft.com/en-us/nuget/reference/nuspec
590+
* - NuGet packages.lock.json file
591+
- ``*packages.lock.json``
592+
- ``nuget``
593+
- ``nuget_packages_lock``
594+
- None
595+
- https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-restore
590596
* - Ocaml Opam file
591597
- ``*opam``
592598
- ``opam``
@@ -661,12 +667,30 @@ parsers in scancode-toolkit during documentation builds.
661667
- ``pypi_egg_pkginfo``
662668
- Python
663669
- https://peps.python.org/pep-0376/
670+
* - Python poetry pyproject.toml
671+
- ``*pip-inspect.deplock``
672+
- ``pypi``
673+
- ``pypi_inspect_deplock``
674+
- Python
675+
- https://pip.pypa.io/en/stable/cli/pip_inspect/
676+
* - Python poetry lockfile
677+
- ``*poetry.lock``
678+
- ``pypi``
679+
- ``pypi_poetry_lock``
680+
- Python
681+
- https://python-poetry.org/docs/basic-usage/#installing-with-poetrylock
682+
* - Python poetry pyproject.toml
683+
- ``*pyproject.toml``
684+
- ``pypi``
685+
- ``pypi_poetry_pyproject_toml``
686+
- Python
687+
- https://packaging.python.org/en/latest/specifications/pyproject-toml/
664688
* - Python pyproject.toml
665689
- ``*pyproject.toml``
666690
- ``pypi``
667691
- ``pypi_pyproject_toml``
668692
- Python
669-
- https://peps.python.org/pep-0621/
693+
- https://packaging.python.org/en/latest/specifications/pyproject-toml/
670694
* - PyPI extracted sdist PKG-INFO
671695
- ``*/PKG-INFO``
672696
- ``pypi``

src/packagedcode/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@
173173
# pypi.PypiSdistArchiveHandler,
174174
pypi.PypiWheelHandler,
175175
pypi.PyprojectTomlHandler,
176+
pypi.PoetryPyprojectTomlHandler,
177+
pypi.PoetryLockHandler,
176178
pypi.PythonEditableInstallationPkgInfoFile,
177179
pypi.PythonEggPkgInfoFile,
178180
pypi.PythonInstalledWheelMetadataFile,
@@ -208,6 +210,9 @@
208210
windows.MicrosoftUpdateManifestHandler,
209211

210212
win_pe.WindowsExecutableHandler,
213+
214+
# These are handlers for deplock generated files
215+
pypi.PipInspectDeplockHandler,
211216
]
212217

213218
if on_linux:

src/packagedcode/debian.py

+4-23
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from packagedcode import models
2323
from packagedcode.utils import get_ancestor
24+
from packagedcode.utils import parse_maintainer_name_email
2425

2526
"""
2627
Handle Debian package archives, control files and installed databases.
@@ -653,20 +654,20 @@ def build_package_data(debian_data, datasource_id, package_type='deb', distro=No
653654

654655
maintainer = debian_data.get('maintainer')
655656
if maintainer:
656-
maintainer_name, maintainer_email = parse_debian_maintainers(maintainer)
657+
maintainer_name, maintainer_email = parse_maintainer_name_email(maintainer)
657658
party = models.Party(role='maintainer', name=maintainer_name, email=maintainer_email)
658659
parties.append(party)
659660

660661
orig_maintainer = debian_data.get('original_maintainer')
661662
if orig_maintainer:
662-
maintainer_name, maintainer_email = parse_debian_maintainers(orig_maintainer)
663+
maintainer_name, maintainer_email = parse_maintainer_name_email(orig_maintainer)
663664
party = models.Party(role='maintainer', name=maintainer_name, email=maintainer_email)
664665
parties.append(party)
665666

666667
uploaders = debian_data.get('uploaders')
667668
if uploaders:
668669
for uploader in uploaders.split(", "):
669-
uploader_name, uploader_email = parse_debian_maintainers(uploader)
670+
uploader_name, uploader_email = parse_maintainer_name_email(uploader)
670671
party = models.Party(role='uploader', name=uploader_name, email=uploader_email)
671672
parties.append(party)
672673

@@ -736,26 +737,6 @@ def build_package_data(debian_data, datasource_id, package_type='deb', distro=No
736737
return models.PackageData.from_data(package_data, package_only)
737738

738739

739-
def parse_debian_maintainers(maintainer):
740-
"""
741-
Get name and email values from a debian maintainer string.
742-
743-
Example string:
744-
Debian systemd Maintainers <[email protected]>
745-
"""
746-
email_wrappers = ["<", ">"]
747-
has_email = "@" in maintainer and all([
748-
True
749-
for char in email_wrappers
750-
if char in maintainer
751-
])
752-
if not has_email:
753-
return maintainer, None
754-
755-
name, _, email = maintainer.rpartition("<")
756-
return name.rstrip(" "), email.rstrip(">")
757-
758-
759740
def populate_debian_namespace(packages):
760741
"""
761742
For an iterable of debian `packages`, populate the

0 commit comments

Comments
 (0)