Skip to content

Commit 1862c2b

Browse files
committed
Sync with latest python-inspector
The key change is adding extra_data to dependencies tree-wide Also python_requires is treated as a package dependency now. Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent d1c9379 commit 1862c2b

File tree

635 files changed

+13010
-6585
lines changed

Some content is hidden

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

635 files changed

+13010
-6585
lines changed

CHANGELOG.rst

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Important API changes:
3434

3535
- There is a a new top-level "dependencies" attribute that contains each
3636
dependency instance, these can be standalone or releated to a package.
37+
These contain a new "extra_data" object.
3738

3839
- There is a new resource-level attribute "for_packages" which refers to
3940
packages through package_uuids (pURL + uuid string).
@@ -172,6 +173,10 @@ Package detection:
172173
- The package_data attribute `dependencies` (which is a list of DependentPackages),
173174
now has a new attribute `resolved_package` with a package data mapping.
174175
Also the `requirement` attribute is renamed to `extracted_requirement`.
176+
There is a new `extra_data` to collect extra data as needed.
177+
178+
- For Pypi packages, python_requires is treated as a package dependency.
179+
175180

176181

177182
License Clarity Scoring Update

src/packagedcode/models.py

+24-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
99

10+
import logging
1011
import os
1112
import uuid
1213
from fnmatch import fnmatchcase
13-
import logging
1414

1515
import attr
1616
from packageurl import normalize_qualifiers
@@ -26,7 +26,15 @@
2626
from commoncode.datautils import String
2727
from commoncode.fileutils import as_posixpath
2828
from commoncode.resource import Resource
29-
from typecode import contenttype
29+
try:
30+
from typecode import contenttype
31+
except ImportError:
32+
contenttype = None
33+
34+
try:
35+
from packagedcode import licensing
36+
except ImportError:
37+
licensing = None
3038

3139
"""
3240
This module contain data models for package and dependencies, abstracting and
@@ -366,6 +374,11 @@ class DependentPackage(ModelMixin):
366374
'lockfiles for Composer or Cargo contain extra dependency data.'
367375
)
368376

377+
extra_data = Mapping(
378+
label='extra data',
379+
help='A mapping of arbitrary extra data.',
380+
)
381+
369382

370383
@attr.attributes(slots=True)
371384
class Dependency(DependentPackage):
@@ -771,7 +784,13 @@ def compute_normalized_license(declared_license, expression_symbols=None):
771784
if not declared_license:
772785
return
773786

774-
from packagedcode import licensing
787+
if not licensing:
788+
if TRACE:
789+
logger_debug(
790+
f'Failed to compute license for {declared_license!r}: '
791+
'cannot import packagedcode.licensing')
792+
return 'unknown'
793+
775794
try:
776795
return licensing.get_normalized_expression(
777796
query_string=declared_license,
@@ -781,7 +800,6 @@ def compute_normalized_license(declared_license, expression_symbols=None):
781800
# we never fail just for this
782801
if TRACE:
783802
logger_debug(f'Failed to compute license for {declared_license!r}: {e!r}')
784-
# FIXME: add logging
785803
return 'unknown'
786804

787805

@@ -852,7 +870,8 @@ def is_datafile(cls, location, filetypes=tuple(), _bare_filename=False):
852870
filetypes = filetypes or cls.filetypes
853871
if not filetypes:
854872
return True
855-
else:
873+
# we check for contenttype IFF this is available
874+
if contenttype:
856875
T = contenttype.get_type(location)
857876
actual_type = T.filetype_file.lower()
858877
return any(ft in actual_type for ft in filetypes)

0 commit comments

Comments
 (0)