Skip to content

Commit f2f9cd9

Browse files
authored
Merge branch 'main' into use-asyncio
2 parents f3bd8b0 + 31990dd commit f2f9cd9

Some content is hidden

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

42 files changed

+5662
-2371
lines changed

.github/workflows/pypi-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-20.04
2525

2626
steps:
27-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
2828
- name: Set up Python
2929
uses: actions/setup-python@v4
3030
with:
@@ -37,7 +37,7 @@ jobs:
3737
run: python -m build --sdist --wheel --outdir dist/
3838

3939
- name: Upload built archives
40-
uses: actions/upload-artifact@v3
40+
uses: actions/upload-artifact@v4
4141
with:
4242
name: pypi_archives
4343
path: dist/*
@@ -51,7 +51,7 @@ jobs:
5151

5252
steps:
5353
- name: Download built archives
54-
uses: actions/download-artifact@v3
54+
uses: actions/download-artifact@v4
5555
with:
5656
name: pypi_archives
5757
path: dist
@@ -71,7 +71,7 @@ jobs:
7171

7272
steps:
7373
- name: Download built archives
74-
uses: actions/download-artifact@v3
74+
uses: actions/download-artifact@v4
7575
with:
7676
name: pypi_archives
7777
path: dist

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
v0.13.1
5+
-----------
6+
7+
- Fix ResolutionImpossible for lief==0.15.1 #202
8+
- Add license expression data from pypi API #208
9+
- Add python 3.13 in python-inspector #196
10+
- Update homepage_url and fix CI and tests
11+
12+
413
v0.12.1
514
-----------
615

azure-pipelines.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,46 @@ jobs:
99
parameters:
1010
job_name: ubuntu20_cpython
1111
image_name: ubuntu-20.04
12-
python_versions: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
12+
python_versions: ["3.9", "3.10", "3.11", "3.12"]
1313
test_suites:
1414
all: venv/bin/pytest -n 2 -vvs --reruns 2
1515

1616
- template: etc/ci/azure-posix.yml
1717
parameters:
1818
job_name: ubuntu22_cpython
1919
image_name: ubuntu-22.04
20-
python_versions: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
20+
python_versions: ["3.9", "3.10", "3.11", "3.12"]
2121
test_suites:
2222
all: venv/bin/pytest -n 2 -vvs --reruns 2
2323

2424
- template: etc/ci/azure-posix.yml
2525
parameters:
26-
job_name: macos12_cpython
27-
image_name: macOS-12
28-
python_versions: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
26+
job_name: macos14_cpython
27+
image_name: macOS-14
28+
python_versions: ["3.9", "3.10", "3.11", "3.12"]
2929
test_suites:
3030
all: venv/bin/pytest -n 2 -vvs --reruns 2
3131

3232
- template: etc/ci/azure-posix.yml
3333
parameters:
3434
job_name: macos13_cpython
3535
image_name: macos-13
36-
python_versions: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
36+
python_versions: ["3.9", "3.10", "3.11", "3.12"]
3737
test_suites:
3838
all: venv/bin/pytest -n 2 -vvs --reruns 2
3939

4040
- template: etc/ci/azure-win.yml
4141
parameters:
4242
job_name: win2019_cpython
4343
image_name: windows-2019
44-
python_versions: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
44+
python_versions: ["3.9", "3.10", "3.11", "3.12"]
4545
test_suites:
4646
all: venv\Scripts\pytest -n 2 -vvs --reruns 2
4747

4848
- template: etc/ci/azure-win.yml
4949
parameters:
5050
job_name: win2022_cpython
5151
image_name: windows-2022
52-
python_versions: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
52+
python_versions: ["3.9", "3.10", "3.11", "3.12"]
5353
test_suites:
5454
all: venv\Scripts\pytest -n 2 -vvs --reruns 2

src/python_inspector/api.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ def to_dict(self, generic_paths=False):
6666
# clean file paths
6767
for file in files:
6868
path = file["path"]
69-
file["path"] = utils.remove_test_data_dir_variable_prefix(
70-
path=path)
69+
file["path"] = utils.remove_test_data_dir_variable_prefix(path=path)
7170
return {
7271
"files": files,
7372
"packages": [package for package in self.packages],
@@ -154,20 +153,16 @@ def resolve_dependencies(
154153

155154
# requirements
156155
for req_file in requirement_files:
157-
deps = dependencies.get_dependencies_from_requirements(
158-
requirements_file=req_file)
156+
deps = dependencies.get_dependencies_from_requirements(requirements_file=req_file)
159157
for extra_data in dependencies.get_extra_data_from_requirements(requirements_file=req_file):
160-
index_urls = (
161-
*index_urls, *tuple(extra_data.get("extra_index_urls") or []))
162-
index_urls = (
163-
*index_urls, *tuple(extra_data.get("index_url") or []))
158+
index_urls = (*index_urls, *tuple(extra_data.get("extra_index_urls") or []))
159+
index_urls = (*index_urls, *tuple(extra_data.get("index_url") or []))
164160
direct_dependencies.extend(deps)
165161
package_data = [
166162
pkg_data.to_dict() for pkg_data in PipRequirementsFileHandler.parse(location=req_file)
167163
]
168164
if generic_paths:
169-
req_file = utils.remove_test_data_dir_variable_prefix(
170-
path=req_file)
165+
req_file = utils.remove_test_data_dir_variable_prefix(path=req_file)
171166

172167
files.append(
173168
dict(
@@ -220,15 +215,13 @@ def resolve_dependencies(
220215
files=[setup_py_file],
221216
analyze_setup_py_insecurely=analyze_setup_py_insecurely,
222217
)
223-
setup_py_file_deps = list(
224-
get_dependent_packages_from_reqs(reqs))
218+
setup_py_file_deps = list(get_dependent_packages_from_reqs(reqs))
225219
direct_dependencies.extend(setup_py_file_deps)
226220

227221
package_data.dependencies = setup_py_file_deps
228222
file_package_data = [package_data.to_dict()]
229223
if generic_paths:
230-
setup_py_file = utils.remove_test_data_dir_variable_prefix(
231-
path=setup_py_file)
224+
setup_py_file = utils.remove_test_data_dir_variable_prefix(path=setup_py_file)
232225
files.append(
233226
dict(
234227
type="file",
@@ -269,11 +262,9 @@ def resolve_dependencies(
269262
else:
270263
credentials = None
271264
if parsed_netrc:
272-
login, password = utils.get_netrc_auth(
273-
index_url, parsed_netrc)
265+
login, password = utils.get_netrc_auth(index_url, parsed_netrc)
274266
credentials = (
275-
dict(login=login,
276-
password=password) if login and password else None
267+
dict(login=login, password=password) if login and password else None
277268
)
278269
repo = utils_pypi.PypiSimpleRepository(
279270
index_url=index_url,
@@ -451,9 +442,7 @@ async def get_dependencies(requirement: Requirement):
451442
provider=provider,
452443
reporter=BaseReporter(),
453444
)
454-
resolver_results = resolver.resolve(
455-
requirements=requirements, max_rounds=max_rounds)
456-
445+
resolver_results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
457446
package_list = get_package_list(results=resolver_results)
458447
if pdt_output:
459448
return format_pdt_tree(resolver_results), package_list

src/python_inspector/cli_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class FileOptionType(click.File):
2121

2222
def convert(self, value, param, ctx):
2323
known_opts = set(
24-
chain.from_iterable(
25-
p.opts for p in ctx.command.params if isinstance(p, click.Option))
24+
chain.from_iterable(p.opts for p in ctx.command.params if isinstance(p, click.Option))
2625
)
2726
if value in known_opts:
2827
self.fail(

src/python_inspector/package_data.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ async def get_pypi_data_from_purl(
5757
project_urls = info.get("project_urls") or {}
5858
code_view_url = get_pypi_codeview_url(project_urls)
5959
bug_tracking_url = get_pypi_bugtracker_url(project_urls)
60-
python_version = get_python_version_from_env_tag(
61-
python_version=environment.python_version)
60+
python_version = get_python_version_from_env_tag(python_version=environment.python_version)
6261
valid_distribution_urls = []
6362
sdist_url = await get_sdist_download_url(
6463
purl=parsed_purl, repos=repos, python_version=python_version
6564
)
6665
if sdist_url:
6766
valid_distribution_urls.append(sdist_url)
6867

68+
valid_distribution_urls = [url for url in valid_distribution_urls if url]
69+
6970
# if prefer_source is True then only source distribution is used
7071
# in case of no source distribution available then wheel is used
7172
if not valid_distribution_urls or not prefer_source:
@@ -99,6 +100,7 @@ async def get_pypi_data_from_purl(
99100
api_data_url=api_url,
100101
bug_tracking_url=bug_tracking_url,
101102
code_view_url=code_view_url,
103+
license_expression=info.get("license_expression"),
102104
declared_license=get_declared_license(info),
103105
download_url=dist_url,
104106
size=url_data.get("size"),

src/python_inspector/resolution.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,13 @@ def get_sdist_file_path_from_filename(sdist):
213213
sdist_file = sdist.rstrip(".tar.gz")
214214
with tarfile.open(os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, sdist)) as file:
215215
file.extractall(
216-
os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR,
217-
"extracted_sdists", sdist_file)
216+
os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file)
218217
)
219218
elif sdist.endswith(".zip"):
220219
sdist_file = sdist.rstrip(".zip")
221220
with ZipFile(os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, sdist)) as zip:
222221
zip.extractall(
223-
os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR,
224-
"extracted_sdists", sdist_file)
222+
os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file)
225223
)
226224

227225
else:
@@ -364,8 +362,7 @@ def __init__(
364362
ignore_errors=False,
365363
):
366364
self.environment = environment
367-
self.environment_marker = get_environment_marker_from_environment(
368-
self.environment)
365+
self.environment_marker = get_environment_marker_from_environment(self.environment)
369366
self.repos = repos or []
370367
self.versions_by_package: Dict[str, List[Version]] = {}
371368
self.dependencies_by_purl = {}
@@ -427,11 +424,9 @@ async def _get_versions_for_package_from_repo(
427424
versions = []
428425
for version, package in (await repo.get_package_versions(name)).items():
429426
python_version = parse_version(
430-
get_python_version_from_env_tag(
431-
python_version=self.environment.python_version)
427+
get_python_version_from_env_tag(python_version=self.environment.python_version)
432428
)
433-
wheels = list(package.get_supported_wheels(
434-
environment=self.environment))
429+
wheels = list(package.get_supported_wheels(environment=self.environment))
435430
valid_wheel_present = False
436431
pypi_valid_python_version = False
437432
if wheels:
@@ -496,8 +491,7 @@ async def _get_requirements_for_package_from_pypi_simple(
496491
Return requirements for a package from the simple repositories.
497492
"""
498493
python_version = parse_version(
499-
get_python_version_from_env_tag(
500-
python_version=self.environment.python_version)
494+
get_python_version_from_env_tag(python_version=self.environment.python_version)
501495
)
502496

503497
wheels = await utils_pypi.download_wheel(
@@ -510,8 +504,7 @@ async def _get_requirements_for_package_from_pypi_simple(
510504

511505
if wheels:
512506
for wheel in wheels:
513-
wheel_location = os.path.join(
514-
utils_pypi.CACHE_THIRDPARTY_DIR, wheel)
507+
wheel_location = os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, wheel)
515508
requirements = get_requirements_from_distribution(
516509
handler=PypiWheelHandler,
517510
location=wheel_location,
@@ -594,8 +587,7 @@ def get_candidates(
594587
):
595588
valid_versions.append(parsed_version)
596589
if not all(version.is_prerelease for version in valid_versions):
597-
valid_versions = [
598-
version for version in valid_versions if not version.is_prerelease]
590+
valid_versions = [version for version in valid_versions if not version.is_prerelease]
599591
for version in valid_versions:
600592
yield Candidate(name=name, version=version, extras=extras)
601593

@@ -611,7 +603,12 @@ def _iter_matches(
611603
name = remove_extras(identifier=identifier)
612604
bad_versions = {c.version for c in incompatibilities[identifier]}
613605
extras = {e for r in requirements[identifier] for e in r.extras}
614-
versions = self.get_versions_for_package(name)
606+
versions = []
607+
if not self.repos:
608+
versions.extend(self.get_versions_for_package(name=name))
609+
else:
610+
for repo in self.repos:
611+
versions.extend(self.get_versions_for_package(name=name, repo=repo))
615612

616613
if not versions:
617614
if self.ignore_errors:
@@ -702,8 +699,7 @@ def dfs(mapping: Dict, graph: DirectedGraph, src: str):
702699

703700
return dict(
704701
package=str(src_purl),
705-
dependencies=sorted([dfs(mapping, graph, c)
706-
for c in children], key=lambda d: d["package"]),
702+
dependencies=sorted([dfs(mapping, graph, c) for c in children], key=lambda d: d["package"]),
707703
)
708704

709705

@@ -821,8 +817,7 @@ def get_setup_requirements(sdist_location: str, setup_py_location: str, setup_cf
821817
"""
822818

823819
if not os.path.exists(setup_py_location) and not os.path.exists(setup_cfg_location):
824-
raise Exception(
825-
f"No setup.py or setup.cfg found in pypi sdist {sdist_location}")
820+
raise Exception(f"No setup.py or setup.cfg found in pypi sdist {sdist_location}")
826821

827822
# Some commonon packages like flask may have some dependencies in setup.cfg
828823
# and some dependencies in setup.py. We are going to check both.

src/python_inspector/resolve_cli.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
TRACE = False
2121

22-
__version__ = "0.12.0"
22+
__version__ = "0.13.0"
2323

2424
DEFAULT_PYTHON_VERSION = "38"
2525
PYPI_SIMPLE_URL = "https://pypi.org/simple"
@@ -84,8 +84,7 @@ def print_version(ctx, param, value):
8484
metavar="OS",
8585
show_default=True,
8686
required=True,
87-
help="OS to use for dependency resolution. One of " +
88-
", ".join(utils_pypi.PLATFORMS_BY_OS),
87+
help="OS to use for dependency resolution. One of " + ", ".join(utils_pypi.PLATFORMS_BY_OS),
8988
)
9089
@click.option(
9190
"--index-url",
@@ -229,8 +228,7 @@ def resolve_dependencies(
229228
from python_inspector.api import resolve_dependencies as resolver_api
230229

231230
if not (json_output or pdt_output):
232-
click.secho(
233-
"No output file specified. Use --json or --json-pdt.", err=True)
231+
click.secho("No output file specified. Use --json or --json-pdt.", err=True)
234232
ctx.exit(1)
235233

236234
if json_output and pdt_output:
@@ -339,8 +337,7 @@ def get_pretty_options(ctx, generic_paths=False):
339337
value = [value]
340338

341339
for val in value:
342-
val = get_pretty_value(param_type=param.type,
343-
value=val, generic_paths=generic_paths)
340+
val = get_pretty_value(param_type=param.type, value=val, generic_paths=generic_paths)
344341

345342
if isinstance(param, click.Argument):
346343
args.append(val)

src/python_inspector/utils_pip_compatibility_tags.py.ABOUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ package_url: pkg:github/pypa/[email protected]#src/pip/_internal/utils/compatibility_ta
1111
download_url: https://github.com/pypa/pip/blob/20.3.1/src/pip/_internal/utils/compatibility_tags.py
1212
copyright: Copyright (c) 2008-2020 The pip developers (see AUTHORS.txt file)
1313
license_expression: mit
14-
notes: subset copied from pip for tag handling
14+
notes: subset copied from pip for tag handling. Modified copy of pip compatibility_tags.py.

0 commit comments

Comments
 (0)