python-inspector 0.9.8__py3-none-any.whl → 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_inspector/api.py +27 -2
- python_inspector/resolution.py +12 -4
- python_inspector/resolve_cli.py +144 -23
- python_inspector/utils.py +14 -1
- python_inspector/utils_pypi.py +12 -1
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/CHANGELOG.rst +13 -0
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/METADATA +13 -8
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/RECORD +15 -15
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/WHEEL +1 -1
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/AUTHORS.rst +0 -0
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/CODE_OF_CONDUCT.rst +0 -0
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/NOTICE +0 -0
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/apache-2.0.LICENSE +0 -0
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/entry_points.txt +0 -0
- {python_inspector-0.9.8.dist-info → python_inspector-0.11.0.dist-info}/top_level.txt +0 -0
python_inspector/api.py
CHANGED
|
@@ -58,9 +58,15 @@ class Resolution(NamedTuple):
|
|
|
58
58
|
packages: List[PackageData]
|
|
59
59
|
files: List[Dict]
|
|
60
60
|
|
|
61
|
-
def to_dict(self):
|
|
61
|
+
def to_dict(self, generic_paths=False):
|
|
62
|
+
files = self.files
|
|
63
|
+
if generic_paths:
|
|
64
|
+
# clean file paths
|
|
65
|
+
for file in files:
|
|
66
|
+
path = file["path"]
|
|
67
|
+
file["path"] = utils.remove_test_data_dir_variable_prefix(path=path)
|
|
62
68
|
return {
|
|
63
|
-
"files":
|
|
69
|
+
"files": files,
|
|
64
70
|
"packages": [package for package in self.packages],
|
|
65
71
|
"resolution": self.resolution,
|
|
66
72
|
}
|
|
@@ -82,6 +88,8 @@ def resolve_dependencies(
|
|
|
82
88
|
analyze_setup_py_insecurely=False,
|
|
83
89
|
prefer_source=False,
|
|
84
90
|
printer=print,
|
|
91
|
+
generic_paths=False,
|
|
92
|
+
ignore_errors=False,
|
|
85
93
|
):
|
|
86
94
|
"""
|
|
87
95
|
Resolve the dependencies for the package requirements listed in one or
|
|
@@ -141,14 +149,19 @@ def resolve_dependencies(
|
|
|
141
149
|
if PYPI_SIMPLE_URL not in index_urls:
|
|
142
150
|
index_urls = tuple([PYPI_SIMPLE_URL]) + tuple(index_urls)
|
|
143
151
|
|
|
152
|
+
# requirements
|
|
144
153
|
for req_file in requirement_files:
|
|
145
154
|
deps = dependencies.get_dependencies_from_requirements(requirements_file=req_file)
|
|
146
155
|
for extra_data in dependencies.get_extra_data_from_requirements(requirements_file=req_file):
|
|
147
156
|
index_urls = (*index_urls, *tuple(extra_data.get("extra_index_urls") or []))
|
|
157
|
+
index_urls = (*index_urls, *tuple(extra_data.get("index_url") or []))
|
|
148
158
|
direct_dependencies.extend(deps)
|
|
149
159
|
package_data = [
|
|
150
160
|
pkg_data.to_dict() for pkg_data in PipRequirementsFileHandler.parse(location=req_file)
|
|
151
161
|
]
|
|
162
|
+
if generic_paths:
|
|
163
|
+
req_file = utils.remove_test_data_dir_variable_prefix(path=req_file)
|
|
164
|
+
|
|
152
165
|
files.append(
|
|
153
166
|
dict(
|
|
154
167
|
type="file",
|
|
@@ -157,10 +170,12 @@ def resolve_dependencies(
|
|
|
157
170
|
)
|
|
158
171
|
)
|
|
159
172
|
|
|
173
|
+
# specs
|
|
160
174
|
for specifier in specifiers:
|
|
161
175
|
dep = dependencies.get_dependency(specifier=specifier)
|
|
162
176
|
direct_dependencies.append(dep)
|
|
163
177
|
|
|
178
|
+
# setup.py
|
|
164
179
|
if setup_py_file:
|
|
165
180
|
package_data = list(PythonSetupPyHandler.parse(location=setup_py_file))
|
|
166
181
|
assert len(package_data) == 1
|
|
@@ -203,6 +218,8 @@ def resolve_dependencies(
|
|
|
203
218
|
|
|
204
219
|
package_data.dependencies = setup_py_file_deps
|
|
205
220
|
file_package_data = [package_data.to_dict()]
|
|
221
|
+
if generic_paths:
|
|
222
|
+
setup_py_file = utils.remove_test_data_dir_variable_prefix(path=setup_py_file)
|
|
206
223
|
files.append(
|
|
207
224
|
dict(
|
|
208
225
|
type="file",
|
|
@@ -268,6 +285,7 @@ def resolve_dependencies(
|
|
|
268
285
|
max_rounds=max_rounds,
|
|
269
286
|
pdt_output=pdt_output,
|
|
270
287
|
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
|
|
288
|
+
ignore_errors=ignore_errors,
|
|
271
289
|
)
|
|
272
290
|
|
|
273
291
|
packages = []
|
|
@@ -294,6 +312,9 @@ def resolve_dependencies(
|
|
|
294
312
|
)
|
|
295
313
|
|
|
296
314
|
|
|
315
|
+
resolver_api = resolve_dependencies
|
|
316
|
+
|
|
317
|
+
|
|
297
318
|
def resolve(
|
|
298
319
|
direct_dependencies,
|
|
299
320
|
environment,
|
|
@@ -302,6 +323,7 @@ def resolve(
|
|
|
302
323
|
max_rounds=200000,
|
|
303
324
|
pdt_output=False,
|
|
304
325
|
analyze_setup_py_insecurely=False,
|
|
326
|
+
ignore_errors=False,
|
|
305
327
|
):
|
|
306
328
|
"""
|
|
307
329
|
Resolve dependencies given a ``direct_dependencies`` list of
|
|
@@ -327,6 +349,7 @@ def resolve(
|
|
|
327
349
|
max_rounds=max_rounds,
|
|
328
350
|
pdt_output=pdt_output,
|
|
329
351
|
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
|
|
352
|
+
ignore_errors=ignore_errors,
|
|
330
353
|
)
|
|
331
354
|
|
|
332
355
|
return resolved_dependencies, packages
|
|
@@ -340,6 +363,7 @@ def get_resolved_dependencies(
|
|
|
340
363
|
max_rounds: int = 200000,
|
|
341
364
|
pdt_output: bool = False,
|
|
342
365
|
analyze_setup_py_insecurely: bool = False,
|
|
366
|
+
ignore_errors: bool = False,
|
|
343
367
|
):
|
|
344
368
|
"""
|
|
345
369
|
Return resolved dependencies of a ``requirements`` list of Requirement for
|
|
@@ -354,6 +378,7 @@ def get_resolved_dependencies(
|
|
|
354
378
|
environment=environment,
|
|
355
379
|
repos=repos,
|
|
356
380
|
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
|
|
381
|
+
ignore_errors=ignore_errors,
|
|
357
382
|
),
|
|
358
383
|
reporter=BaseReporter(),
|
|
359
384
|
)
|
python_inspector/resolution.py
CHANGED
|
@@ -303,7 +303,7 @@ def get_requirements_from_python_manifest(
|
|
|
303
303
|
else:
|
|
304
304
|
# Do not raise exception here as we may have a setup.py that does not
|
|
305
305
|
# have any dependencies.
|
|
306
|
-
with
|
|
306
|
+
with open(setup_py_location) as sf:
|
|
307
307
|
file_contents = sf.read()
|
|
308
308
|
node = ast.parse(file_contents)
|
|
309
309
|
setup_fct = [
|
|
@@ -352,7 +352,11 @@ DEFAULT_ENVIRONMENT = utils_pypi.Environment.from_pyver_and_os(
|
|
|
352
352
|
|
|
353
353
|
class PythonInputProvider(AbstractProvider):
|
|
354
354
|
def __init__(
|
|
355
|
-
self,
|
|
355
|
+
self,
|
|
356
|
+
environment=DEFAULT_ENVIRONMENT,
|
|
357
|
+
repos=tuple(),
|
|
358
|
+
analyze_setup_py_insecurely=True,
|
|
359
|
+
ignore_errors=False,
|
|
356
360
|
):
|
|
357
361
|
self.environment = environment
|
|
358
362
|
self.environment_marker = get_environment_marker_from_environment(self.environment)
|
|
@@ -361,6 +365,7 @@ class PythonInputProvider(AbstractProvider):
|
|
|
361
365
|
self.dependencies_by_purl = {}
|
|
362
366
|
self.wheel_or_sdist_by_package = {}
|
|
363
367
|
self.analyze_setup_py_insecurely = analyze_setup_py_insecurely
|
|
368
|
+
self.ignore_errors = ignore_errors
|
|
364
369
|
|
|
365
370
|
def identify(self, requirement_or_candidate: Union[Candidate, Requirement]) -> str:
|
|
366
371
|
"""Given a requirement, return an identifier for it. Overridden."""
|
|
@@ -583,8 +588,11 @@ class PythonInputProvider(AbstractProvider):
|
|
|
583
588
|
versions.extend(self.get_versions_for_package(name=name, repo=repo))
|
|
584
589
|
|
|
585
590
|
if not versions:
|
|
586
|
-
|
|
587
|
-
|
|
591
|
+
if self.ignore_errors:
|
|
592
|
+
yield from [Candidate("NonExistant", "0.0.0", "")]
|
|
593
|
+
return
|
|
594
|
+
else:
|
|
595
|
+
raise NoVersionsFound(f"This package does not exist: {name}")
|
|
588
596
|
yield from self.get_candidates(
|
|
589
597
|
all_versions=versions,
|
|
590
598
|
requirements=requirements,
|
python_inspector/resolve_cli.py
CHANGED
|
@@ -14,13 +14,12 @@ from typing import Dict
|
|
|
14
14
|
import click
|
|
15
15
|
|
|
16
16
|
from python_inspector import utils_pypi
|
|
17
|
-
from python_inspector.api import resolve_dependencies as resolver_api
|
|
18
17
|
from python_inspector.cli_utils import FileOptionType
|
|
19
18
|
from python_inspector.utils import write_output_in_file
|
|
20
19
|
|
|
21
20
|
TRACE = False
|
|
22
21
|
|
|
23
|
-
__version__ = "0.
|
|
22
|
+
__version__ = "0.11.0"
|
|
24
23
|
|
|
25
24
|
DEFAULT_PYTHON_VERSION = "38"
|
|
26
25
|
PYPI_SIMPLE_URL = "https://pypi.org/simple"
|
|
@@ -52,9 +51,9 @@ def print_version(ctx, param, value):
|
|
|
52
51
|
"setup_py_file",
|
|
53
52
|
type=click.Path(exists=True, readable=True, path_type=str, dir_okay=False),
|
|
54
53
|
metavar="SETUP-PY-FILE",
|
|
54
|
+
multiple=False,
|
|
55
55
|
required=False,
|
|
56
|
-
help="Path to setuptools setup.py file listing dependencies and metadata.
|
|
57
|
-
"This option can be used multiple times.",
|
|
56
|
+
help="Path to setuptools setup.py file listing dependencies and metadata.",
|
|
58
57
|
)
|
|
59
58
|
@click.option(
|
|
60
59
|
"--spec",
|
|
@@ -74,7 +73,8 @@ def print_version(ctx, param, value):
|
|
|
74
73
|
metavar="PYVER",
|
|
75
74
|
show_default=True,
|
|
76
75
|
required=True,
|
|
77
|
-
help="Python version to use for dependency resolution."
|
|
76
|
+
help="Python version to use for dependency resolution. One of "
|
|
77
|
+
+ ", ".join(utils_pypi.PYTHON_DOT_VERSIONS_BY_VER.values()),
|
|
78
78
|
)
|
|
79
79
|
@click.option(
|
|
80
80
|
"-o",
|
|
@@ -84,7 +84,7 @@ def print_version(ctx, param, value):
|
|
|
84
84
|
metavar="OS",
|
|
85
85
|
show_default=True,
|
|
86
86
|
required=True,
|
|
87
|
-
help="OS to use for dependency resolution.",
|
|
87
|
+
help="OS to use for dependency resolution. One of " + ", ".join(utils_pypi.PLATFORMS_BY_OS),
|
|
88
88
|
)
|
|
89
89
|
@click.option(
|
|
90
90
|
"--index-url",
|
|
@@ -123,7 +123,7 @@ def print_version(ctx, param, value):
|
|
|
123
123
|
metavar="NETRC-FILE",
|
|
124
124
|
hidden=True,
|
|
125
125
|
required=False,
|
|
126
|
-
help="Netrc file to use for authentication.
|
|
126
|
+
help="Netrc file to use for authentication.",
|
|
127
127
|
)
|
|
128
128
|
@click.option(
|
|
129
129
|
"--max-rounds",
|
|
@@ -131,13 +131,15 @@ def print_version(ctx, param, value):
|
|
|
131
131
|
hidden=True,
|
|
132
132
|
type=int,
|
|
133
133
|
default=200000,
|
|
134
|
-
help="Increase the
|
|
134
|
+
help="Increase the maximum number of resolution rounds. "
|
|
135
|
+
"Use in the rare cases where the resolution graph is very deep.",
|
|
135
136
|
)
|
|
136
137
|
@click.option(
|
|
137
138
|
"--use-cached-index",
|
|
138
139
|
is_flag=True,
|
|
139
140
|
hidden=True,
|
|
140
|
-
help="Use cached on-disk PyPI simple package indexes
|
|
141
|
+
help="Use cached on-disk PyPI simple package indexes "
|
|
142
|
+
"and do not refetch package index if cache is present.",
|
|
141
143
|
)
|
|
142
144
|
@click.option(
|
|
143
145
|
"--use-pypi-json-api",
|
|
@@ -148,20 +150,19 @@ def print_version(ctx, param, value):
|
|
|
148
150
|
@click.option(
|
|
149
151
|
"--analyze-setup-py-insecurely",
|
|
150
152
|
is_flag=True,
|
|
151
|
-
help="Enable collection of requirements in setup.py that compute these"
|
|
152
|
-
"
|
|
153
|
+
help="Enable collection of requirements in setup.py that compute these "
|
|
154
|
+
"dynamically. This is an insecure operation as it can run arbitrary code.",
|
|
153
155
|
)
|
|
154
156
|
@click.option(
|
|
155
157
|
"--prefer-source",
|
|
156
158
|
is_flag=True,
|
|
157
|
-
help="Prefer source distributions over binary distributions"
|
|
158
|
-
"
|
|
159
|
+
help="Prefer source distributions over binary distributions if no source "
|
|
160
|
+
"distribution is available then binary distributions are used",
|
|
159
161
|
)
|
|
160
162
|
@click.option(
|
|
161
163
|
"--verbose",
|
|
162
164
|
is_flag=True,
|
|
163
|
-
|
|
164
|
-
help="Enable debug output.",
|
|
165
|
+
help="Enable verbose debug output.",
|
|
165
166
|
)
|
|
166
167
|
@click.option(
|
|
167
168
|
"-V",
|
|
@@ -172,7 +173,17 @@ def print_version(ctx, param, value):
|
|
|
172
173
|
callback=print_version,
|
|
173
174
|
help="Show the version and exit.",
|
|
174
175
|
)
|
|
176
|
+
@click.option(
|
|
177
|
+
"--ignore-errors", is_flag=True, default=False, help="Ignore errors and continue execution."
|
|
178
|
+
)
|
|
175
179
|
@click.help_option("-h", "--help")
|
|
180
|
+
@click.option(
|
|
181
|
+
"--generic-paths",
|
|
182
|
+
is_flag=True,
|
|
183
|
+
hidden=True,
|
|
184
|
+
help="Use generic or truncated paths in the JSON output header and files sections. "
|
|
185
|
+
"Used only for testing to avoid absolute paths and paths changing at each run.",
|
|
186
|
+
)
|
|
176
187
|
def resolve_dependencies(
|
|
177
188
|
ctx,
|
|
178
189
|
requirement_files,
|
|
@@ -190,6 +201,8 @@ def resolve_dependencies(
|
|
|
190
201
|
analyze_setup_py_insecurely=False,
|
|
191
202
|
prefer_source=False,
|
|
192
203
|
verbose=TRACE,
|
|
204
|
+
generic_paths=False,
|
|
205
|
+
ignore_errors=False,
|
|
193
206
|
):
|
|
194
207
|
"""
|
|
195
208
|
Resolve the dependencies for the package requirements listed in one or
|
|
@@ -212,6 +225,8 @@ def resolve_dependencies(
|
|
|
212
225
|
|
|
213
226
|
python-inspector --spec "flask==2.1.2" --json -
|
|
214
227
|
"""
|
|
228
|
+
from python_inspector.api import resolve_dependencies as resolver_api
|
|
229
|
+
|
|
215
230
|
if not (json_output or pdt_output):
|
|
216
231
|
click.secho("No output file specified. Use --json or --json-pdt.", err=True)
|
|
217
232
|
ctx.exit(1)
|
|
@@ -220,12 +235,7 @@ def resolve_dependencies(
|
|
|
220
235
|
click.secho("Only one of --json or --json-pdt can be used.", err=True)
|
|
221
236
|
ctx.exit(1)
|
|
222
237
|
|
|
223
|
-
options =
|
|
224
|
-
options += [f"--specifier {sp}" for sp in specifiers]
|
|
225
|
-
options += [f"--index-url {iu}" for iu in index_urls]
|
|
226
|
-
options += [f"--python-version {python_version}"]
|
|
227
|
-
options += [f"--operating-system {operating_system}"]
|
|
228
|
-
options += ["--json <file>"]
|
|
238
|
+
options = get_pretty_options(ctx, generic_paths=generic_paths)
|
|
229
239
|
|
|
230
240
|
notice = (
|
|
231
241
|
"Dependency tree generated with python-inspector.\n"
|
|
@@ -260,10 +270,14 @@ def resolve_dependencies(
|
|
|
260
270
|
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
|
|
261
271
|
printer=click.secho,
|
|
262
272
|
prefer_source=prefer_source,
|
|
273
|
+
ignore_errors=ignore_errors,
|
|
274
|
+
generic_paths=generic_paths,
|
|
263
275
|
)
|
|
276
|
+
|
|
277
|
+
files = resolution_result.files or []
|
|
264
278
|
output = dict(
|
|
265
279
|
headers=headers,
|
|
266
|
-
files=
|
|
280
|
+
files=files,
|
|
267
281
|
packages=resolution_result.packages,
|
|
268
282
|
resolved_dependencies_graph=resolution_result.resolution,
|
|
269
283
|
)
|
|
@@ -271,12 +285,119 @@ def resolve_dependencies(
|
|
|
271
285
|
output=output,
|
|
272
286
|
location=json_output or pdt_output,
|
|
273
287
|
)
|
|
274
|
-
except Exception
|
|
288
|
+
except Exception:
|
|
275
289
|
import traceback
|
|
276
290
|
|
|
277
291
|
click.secho(traceback.format_exc(), err=True)
|
|
278
292
|
ctx.exit(1)
|
|
279
293
|
|
|
280
294
|
|
|
295
|
+
def get_pretty_options(ctx, generic_paths=False):
|
|
296
|
+
"""
|
|
297
|
+
Return a sorted list of formatted strings for the selected CLI options of
|
|
298
|
+
the `ctx` Click.context, putting arguments first then options:
|
|
299
|
+
|
|
300
|
+
["~/some/path", "--license", ...]
|
|
301
|
+
|
|
302
|
+
Skip options that are hidden or flags that are not set.
|
|
303
|
+
If ``generic_paths`` is True, click.File and click.Path parameters are made
|
|
304
|
+
"generic" replacing their value with a placeholder. This is used mostly for
|
|
305
|
+
testing.
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
args = []
|
|
309
|
+
options = []
|
|
310
|
+
|
|
311
|
+
param_values = ctx.params
|
|
312
|
+
for param in ctx.command.params:
|
|
313
|
+
name = param.name
|
|
314
|
+
value = param_values.get(name)
|
|
315
|
+
|
|
316
|
+
if param.is_eager:
|
|
317
|
+
continue
|
|
318
|
+
|
|
319
|
+
if getattr(param, "hidden", False):
|
|
320
|
+
continue
|
|
321
|
+
|
|
322
|
+
if value == param.default:
|
|
323
|
+
continue
|
|
324
|
+
|
|
325
|
+
if value in (None, False):
|
|
326
|
+
continue
|
|
327
|
+
|
|
328
|
+
if value in (tuple(), []):
|
|
329
|
+
# option with multiple values, the value is a emoty tuple
|
|
330
|
+
continue
|
|
331
|
+
|
|
332
|
+
# opts is a list of CLI options as in "--verbose": the last opt is
|
|
333
|
+
# the CLI option long form by convention
|
|
334
|
+
cli_opt = param.opts[-1]
|
|
335
|
+
|
|
336
|
+
if not isinstance(value, (tuple, list)):
|
|
337
|
+
value = [value]
|
|
338
|
+
|
|
339
|
+
for val in value:
|
|
340
|
+
val = get_pretty_value(param_type=param.type, value=val, generic_paths=generic_paths)
|
|
341
|
+
|
|
342
|
+
if isinstance(param, click.Argument):
|
|
343
|
+
args.append(val)
|
|
344
|
+
else:
|
|
345
|
+
# an option
|
|
346
|
+
if val is True:
|
|
347
|
+
# mere flag... do not add the "true" value
|
|
348
|
+
options.append(f"{cli_opt}")
|
|
349
|
+
else:
|
|
350
|
+
options.append(f"{cli_opt} {val}")
|
|
351
|
+
|
|
352
|
+
return sorted(args) + sorted(options)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def get_pretty_value(param_type, value, generic_paths=False):
|
|
356
|
+
"""
|
|
357
|
+
Return pretty formatted string extracted from a parameter ``value``.
|
|
358
|
+
Make paths generic (by using a placeholder or truncating the path) if
|
|
359
|
+
``generic_paths`` is True.
|
|
360
|
+
"""
|
|
361
|
+
if isinstance(param_type, (click.Path, click.File)):
|
|
362
|
+
return get_pretty_path(param_type, value, generic_paths)
|
|
363
|
+
|
|
364
|
+
elif not (value is None or isinstance(value, (str, bytes, tuple, list, dict, bool))):
|
|
365
|
+
# coerce to string for non-basic types
|
|
366
|
+
return repr(value)
|
|
367
|
+
|
|
368
|
+
else:
|
|
369
|
+
return value
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def get_pretty_path(param_type, value, generic_paths=False):
|
|
373
|
+
"""
|
|
374
|
+
Return a pretty path value for a Path or File option. Truncate the path or
|
|
375
|
+
use a placeholder as needed if ``generic_paths`` is True. Used for testing.
|
|
376
|
+
"""
|
|
377
|
+
from python_inspector.utils import remove_test_data_dir_variable_prefix
|
|
378
|
+
|
|
379
|
+
if value == "-":
|
|
380
|
+
return value
|
|
381
|
+
|
|
382
|
+
if isinstance(param_type, click.Path):
|
|
383
|
+
if generic_paths:
|
|
384
|
+
return remove_test_data_dir_variable_prefix(path=value)
|
|
385
|
+
return value
|
|
386
|
+
|
|
387
|
+
elif isinstance(param_type, click.File):
|
|
388
|
+
# the value cannot be displayed as-is as this may be an opened file-
|
|
389
|
+
# like object
|
|
390
|
+
vname = getattr(value, "name", None)
|
|
391
|
+
if not vname:
|
|
392
|
+
return "<file>"
|
|
393
|
+
else:
|
|
394
|
+
value = vname
|
|
395
|
+
|
|
396
|
+
if generic_paths:
|
|
397
|
+
return remove_test_data_dir_variable_prefix(path=value, placeholder="<file>")
|
|
398
|
+
|
|
399
|
+
return value
|
|
400
|
+
|
|
401
|
+
|
|
281
402
|
if __name__ == "__main__":
|
|
282
403
|
resolve_dependencies()
|
python_inspector/utils.py
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
import json
|
|
13
13
|
import os
|
|
14
|
-
import tempfile
|
|
15
14
|
from typing import Dict
|
|
16
15
|
from typing import List
|
|
17
16
|
from typing import NamedTuple
|
|
@@ -73,3 +72,17 @@ def get_response(url: str) -> Dict:
|
|
|
73
72
|
resp = requests.get(url)
|
|
74
73
|
if resp.status_code == 200:
|
|
75
74
|
return resp.json()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def remove_test_data_dir_variable_prefix(path, placeholder="<file>"):
|
|
78
|
+
"""
|
|
79
|
+
Return a clean path, removing variable test path prefix or using a ``placeholder``.
|
|
80
|
+
Used for testing to ensure that results are stable across runs.
|
|
81
|
+
"""
|
|
82
|
+
path = path.replace("\\", "/")
|
|
83
|
+
if "tests/data/" in path:
|
|
84
|
+
_junk, test_dir, cleaned = path.partition("tests/data/")
|
|
85
|
+
cleaned = f"{test_dir}{cleaned}"
|
|
86
|
+
return cleaned.replace("\\", "/")
|
|
87
|
+
else:
|
|
88
|
+
return placeholder
|
python_inspector/utils_pypi.py
CHANGED
|
@@ -20,6 +20,7 @@ from collections import defaultdict
|
|
|
20
20
|
from typing import List
|
|
21
21
|
from typing import NamedTuple
|
|
22
22
|
from urllib.parse import quote_plus
|
|
23
|
+
from urllib.parse import unquote
|
|
23
24
|
from urllib.parse import urlparse
|
|
24
25
|
from urllib.parse import urlunparse
|
|
25
26
|
|
|
@@ -700,7 +701,6 @@ class Distribution(NameVer):
|
|
|
700
701
|
Return a distribution built from the data found in a `filename` string.
|
|
701
702
|
Raise an exception if this is not a valid filename
|
|
702
703
|
"""
|
|
703
|
-
filename = os.path.basename(filename.strip("/"))
|
|
704
704
|
clazz = cls.get_dist_class(filename)
|
|
705
705
|
return clazz.from_filename(filename)
|
|
706
706
|
|
|
@@ -949,6 +949,15 @@ def get_sdist_name_ver_ext(filename):
|
|
|
949
949
|
return name, version, extension
|
|
950
950
|
|
|
951
951
|
|
|
952
|
+
def get_filename(filename):
|
|
953
|
+
"""
|
|
954
|
+
Return a filename from a ``filename`` path or name string. Unquote as needed.
|
|
955
|
+
"""
|
|
956
|
+
filename = filename.strip("/")
|
|
957
|
+
filename = os.path.basename(filename)
|
|
958
|
+
return unquote(filename)
|
|
959
|
+
|
|
960
|
+
|
|
952
961
|
@attr.attributes
|
|
953
962
|
class Sdist(Distribution):
|
|
954
963
|
extension = attr.ib(
|
|
@@ -964,6 +973,7 @@ class Sdist(Distribution):
|
|
|
964
973
|
Return a Sdist object built from a filename.
|
|
965
974
|
Raise an exception if this is not a valid sdist filename
|
|
966
975
|
"""
|
|
976
|
+
filename = get_filename(filename)
|
|
967
977
|
name_ver_ext = get_sdist_name_ver_ext(filename)
|
|
968
978
|
if not name_ver_ext:
|
|
969
979
|
raise InvalidDistributionFilename(filename)
|
|
@@ -1068,6 +1078,7 @@ class Wheel(Distribution):
|
|
|
1068
1078
|
Return a wheel object built from a filename.
|
|
1069
1079
|
Raise an exception if this is not a valid wheel filename
|
|
1070
1080
|
"""
|
|
1081
|
+
filename = get_filename(filename)
|
|
1071
1082
|
wheel_info = cls.get_wheel_from_filename(filename)
|
|
1072
1083
|
if not wheel_info:
|
|
1073
1084
|
raise InvalidDistributionFilename(filename)
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
v0.11.0
|
|
5
|
+
-----------
|
|
6
|
+
|
|
7
|
+
- Add ignore error mode.
|
|
8
|
+
- Fix missing index_urls parsing.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
v0.10.0
|
|
12
|
+
-----------
|
|
13
|
+
|
|
14
|
+
- Fix resolving requirements with percent encoded characters.
|
|
15
|
+
|
|
16
|
+
|
|
4
17
|
v0.9.8
|
|
5
18
|
-------------
|
|
6
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-inspector
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: python-inspector is is a collection of utilities to collect PyPI package metadata and resolve packages dependencies.
|
|
5
5
|
Home-page: https://github.com/nexB/python-inspector
|
|
6
6
|
Author: nexB. Inc. and others
|
|
@@ -36,17 +36,18 @@ Requires-Dist: toml >=0.10.0
|
|
|
36
36
|
Requires-Dist: mock >=3.0.5
|
|
37
37
|
Requires-Dist: packvers >=21.5
|
|
38
38
|
Provides-Extra: docs
|
|
39
|
-
Requires-Dist: Sphinx >=
|
|
40
|
-
Requires-Dist: sphinx-rtd-theme >=0.
|
|
41
|
-
Requires-Dist:
|
|
39
|
+
Requires-Dist: Sphinx >=5.0.2 ; extra == 'docs'
|
|
40
|
+
Requires-Dist: sphinx-rtd-theme >=1.0.0 ; extra == 'docs'
|
|
41
|
+
Requires-Dist: sphinx-reredirects >=0.1.2 ; extra == 'docs'
|
|
42
|
+
Requires-Dist: doc8 >=0.11.2 ; extra == 'docs'
|
|
42
43
|
Provides-Extra: testing
|
|
43
44
|
Requires-Dist: pytest !=7.0.0,>=6 ; extra == 'testing'
|
|
44
45
|
Requires-Dist: pytest-xdist >=2 ; extra == 'testing'
|
|
45
46
|
Requires-Dist: aboutcode-toolkit >=7.0.2 ; extra == 'testing'
|
|
47
|
+
Requires-Dist: pycodestyle >=2.8.0 ; extra == 'testing'
|
|
46
48
|
Requires-Dist: twine ; extra == 'testing'
|
|
47
49
|
Requires-Dist: black ; extra == 'testing'
|
|
48
50
|
Requires-Dist: isort ; extra == 'testing'
|
|
49
|
-
Requires-Dist: pycodestyle ; extra == 'testing'
|
|
50
51
|
Requires-Dist: pytest-rerunfailures ; extra == 'testing'
|
|
51
52
|
|
|
52
53
|
python-inspector - inspect Python packages dependencies and metadata
|
|
@@ -62,9 +63,13 @@ Homepage: https://github.com/nexB/python-inspector and https://www.aboutcode.org
|
|
|
62
63
|
|
|
63
64
|
- resolve PyPI packages dependencies
|
|
64
65
|
|
|
65
|
-
- parse various
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
- parse various requirements.txt files and setup.py files as input
|
|
67
|
+
for resolving dependencies.
|
|
68
|
+
|
|
69
|
+
- parse additionally various manifests and packages files such as
|
|
70
|
+
Pipfile, pyproject.toml, poetry.lock and setup.cfg and legacy and
|
|
71
|
+
current metadata file formats for eggs, wheels and sdist. These
|
|
72
|
+
have not been wired with the command line yet.
|
|
68
73
|
|
|
69
74
|
- query PyPI JSON and simple APIs for package information
|
|
70
75
|
|
|
@@ -8,32 +8,32 @@ _packagedcode/pypi_setup_py.py.ABOUT,sha256=7FLC7R73YDfzEu47fij39PxteCqmojKSexCh
|
|
|
8
8
|
_packagedcode/pypi_setup_py.py.LICENSE,sha256=EsVAqcPMzlhNkyJ3j6EW_yF02WLs94p0w2igJYrUcxs,1077
|
|
9
9
|
_packagedcode/utils.py,sha256=ibgl7lQLUFuC09Go9mSY4D455W4AvagaJ_kg1EO9eXo,6949
|
|
10
10
|
python_inspector/__init__.py,sha256=-WeiNn9hvD3sGqwxrZQr0by1J7oo5QDPDAMe_cT5okQ,389
|
|
11
|
-
python_inspector/api.py,sha256=
|
|
11
|
+
python_inspector/api.py,sha256=u95X6NvnhcsqWpDkTXY01S38Nh50bQWRL0flyZrqZic,14491
|
|
12
12
|
python_inspector/cli_utils.py,sha256=SDc-L5P_QWcEyRPYe_VMTU_9biirGbvHBX45tj2t5WI,1131
|
|
13
13
|
python_inspector/dependencies.py,sha256=2MYJZSUGokE3zSrOxUUyMfItyDSZ7YgMHgtVC-bglOU,2817
|
|
14
14
|
python_inspector/error.py,sha256=WvTR5JTjziD42hxKftedb-pe2LUWWTsagW66gT3rtBo,448
|
|
15
15
|
python_inspector/package_data.py,sha256=kCKHlc8yX25jdNBMvtn4fiw99YTs57DMQow8uwFW3jU,5849
|
|
16
|
-
python_inspector/resolution.py,sha256=
|
|
16
|
+
python_inspector/resolution.py,sha256=Q-UoLg7gDT-YJw2zvVWOas5iS5kuNXyhH-I71jhiCss,29356
|
|
17
17
|
python_inspector/resolution.py.ABOUT,sha256=tYLeHLgyo4zZrPlMXlVF59EjC-GGDaQeFKogf7M7rXg,705
|
|
18
18
|
python_inspector/resolution.py.LICENSE,sha256=84j9OMrRMRLB3A9mm76A5_hFQe26-3LzAw0sp2QsPJ0,751
|
|
19
|
-
python_inspector/resolve_cli.py,sha256=
|
|
19
|
+
python_inspector/resolve_cli.py,sha256=BIQWIh9Rw8C238Zst5PRqRXVtmMp6g_MYfnpSywx18E,12039
|
|
20
20
|
python_inspector/setup_py_live_eval.py,sha256=6iFI1u1fusqa_zF2w1V8buZgmLl2dUSZASclwuI551E,7607
|
|
21
21
|
python_inspector/setup_py_live_eval.py.ABOUT,sha256=ecRsdi0Z--mX8gnSwQzE2OqucpmD0AsmPlojp70uPxI,396
|
|
22
22
|
python_inspector/setup_py_live_eval.py.LICENSE,sha256=5wfEqJLf5ANizw20WUURuTgoZOzMRK_4iGA39BApyRk,1643
|
|
23
|
-
python_inspector/utils.py,sha256=
|
|
23
|
+
python_inspector/utils.py,sha256=czDA_6lmXrX3PzY222xUTrUDYmfN_uWmNPMjTRc8OuE,2422
|
|
24
24
|
python_inspector/utils_pip_compatibility_tags.py,sha256=oD6elof52LxPF9HOtPXPAi2mZkbqAXjDd1dCeRHI3Q4,6825
|
|
25
25
|
python_inspector/utils_pip_compatibility_tags.py.ABOUT,sha256=v9PEBLLQGH1cJuJU7SeHd7q4b2li3_HOTlvgsQoMuRw,494
|
|
26
|
-
python_inspector/utils_pypi.py,sha256=
|
|
26
|
+
python_inspector/utils_pypi.py,sha256=PQc0iBANiH6ayVOjSt6CQ9w1K8hpCFhPb5TgYW5DBjQ,57396
|
|
27
27
|
python_inspector/utils_pypi.py.ABOUT,sha256=7s9WCNmS-qJJgHC979fI4whrM5Y41-Ar-LZoIfZXPVU,635
|
|
28
28
|
python_inspector/utils_pypi_supported_tags.py,sha256=SdbIlKoCgyqBZIesEdrFhVMnYikBirvSDvPUPIomTSo,2850
|
|
29
29
|
python_inspector/utils_pypi_supported_tags.py.ABOUT,sha256=ndJ1kQS6u7caYmLc6XVnNIdKfpnvGjKepxpmhQJWJyA,741
|
|
30
|
-
python_inspector-0.
|
|
31
|
-
python_inspector-0.
|
|
32
|
-
python_inspector-0.
|
|
33
|
-
python_inspector-0.
|
|
34
|
-
python_inspector-0.
|
|
35
|
-
python_inspector-0.
|
|
36
|
-
python_inspector-0.
|
|
37
|
-
python_inspector-0.
|
|
38
|
-
python_inspector-0.
|
|
39
|
-
python_inspector-0.
|
|
30
|
+
python_inspector-0.11.0.dist-info/AUTHORS.rst,sha256=rRa-_IwbfBl84NqT5QZWFTXHsJnvRz8SP9dymwrEDAE,87
|
|
31
|
+
python_inspector-0.11.0.dist-info/CHANGELOG.rst,sha256=Yu6byIbO5yqNmN_U8hVl6wwN6kSiEyJMfoaECX5w_ow,3577
|
|
32
|
+
python_inspector-0.11.0.dist-info/CODE_OF_CONDUCT.rst,sha256=xXDTFpYY3Y7JoxrWADihieUvhGlwJc_oxsbmLJaBvE4,3422
|
|
33
|
+
python_inspector-0.11.0.dist-info/METADATA,sha256=nAF_s-24NA-BpH8nxj-uczlC6VkClXET0Cv93REibnU,4264
|
|
34
|
+
python_inspector-0.11.0.dist-info/NOTICE,sha256=uEf5AAY7zIAS_ILkcEjEJ0Wt6wYWyU9d6FGPiAlpig4,770
|
|
35
|
+
python_inspector-0.11.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
36
|
+
python_inspector-0.11.0.dist-info/apache-2.0.LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
37
|
+
python_inspector-0.11.0.dist-info/entry_points.txt,sha256=2s9F95rPWbgz3cOnKN3Z7PwzglPt2EsX2qf7W0Xubpk,87
|
|
38
|
+
python_inspector-0.11.0.dist-info/top_level.txt,sha256=C-KAHTL8C6jd7QULvFk83YjOBVxDrnyefG3RikRHRlw,31
|
|
39
|
+
python_inspector-0.11.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|