diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 554ddee0..e458e6cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,10 +2,20 @@ Changelog ========= +v0.7.2 +------ + +- Change Output Format to look like ScanCode-Toolkit #68 + https://github.com/nexB/python-inspector/issues/68 , we have removed + "requirements" from the ouptut and added a new field "files". + + v0.7.1 ------ -- Correct version reporting #70. +- Correct version reporting #70 + https://github.com/nexB/python-inspector/issues/70 . + v0.7.0 ------ diff --git a/src/python_inspector/resolve_cli.py b/src/python_inspector/resolve_cli.py index 130136f1..cf2cc545 100644 --- a/src/python_inspector/resolve_cli.py +++ b/src/python_inspector/resolve_cli.py @@ -36,7 +36,7 @@ TRACE = False -__version__ = "0.7.1" +__version__ = "0.7.2" DEFAULT_PYTHON_VERSION = "38" PYPI_SIMPLE_URL = "https://pypi.org/simple" @@ -251,6 +251,8 @@ def resolve_dependencies( # TODO: deduplicate me direct_dependencies = [] + files = [] + if PYPI_SIMPLE_URL not in index_urls: index_urls = tuple([PYPI_SIMPLE_URL]) + tuple(index_urls) @@ -259,6 +261,16 @@ def resolve_dependencies( for extra_data in dependencies.get_extra_data_from_requirements(requirements_file=req_file): index_urls = (*index_urls, *tuple(extra_data.get("extra_index_urls") or [])) direct_dependencies.extend(deps) + package_data = [ + pkg_data.to_dict() for pkg_data in PipRequirementsFileHandler.parse(location=req_file) + ] + files.append( + dict( + type="file", + path=req_file, + package_data=package_data, + ) + ) for specifier in specifiers: dep = dependencies.get_dependency(specifier=specifier) @@ -282,6 +294,7 @@ def resolve_dependencies( ) ctx.exit(1) + setup_py_file_deps = package_data.dependencies for dep in package_data.dependencies: # TODO : we need to handle to all the scopes if dep.scope == "install": @@ -303,17 +316,30 @@ def resolve_dependencies( location=requirement_location, ) if deps: + setup_py_file_deps = list(deps) has_deps = True direct_dependencies.extend(deps) if not has_deps and contain_string(string="_require", files=[setup_py_file]): if analyze_setup_py_insecurely: - direct_dependencies.extend( + insecure_setup_py_deps = list( parse_deps_from_setup_py_insecurely(setup_py=setup_py_file) ) + setup_py_file_deps = insecure_setup_py_deps + direct_dependencies.extend(insecure_setup_py_deps) else: raise Exception("Unable to collect setup.py dependencies securely") + package_data.dependencies = setup_py_file_deps + file_package_data = [package_data.to_dict()] + files.append( + dict( + type="file", + path=setup_py_file, + package_data=file_package_data, + ) + ) + if not direct_dependencies: click.secho("Error: no requirements requested.") ctx.exit(1) @@ -360,7 +386,7 @@ def resolve_dependencies( click.secho(f" {repo}") # resolve dependencies proper - requirements, resolved_dependencies, purls = resolve( + resolved_dependencies, purls = resolve( direct_dependencies=direct_dependencies, environment=environment, repos=repos, @@ -381,7 +407,7 @@ def resolve_dependencies( notice = ( "Dependency tree generated with python-inspector.\n" "python-inspector is a free software tool from nexB Inc. and others.\n" - "Visit https://github.com/nexB/scancode-toolkit/ for support and download." + "Visit https://github.com/nexB/python-inspector/ for support and download." ) headers = dict( @@ -401,24 +427,17 @@ def resolve_dependencies( list(get_pypi_data_from_purl(package, repos=repos, environment=environment)), ) - if json_output: - write_output( - headers=headers, - requirements=requirements, - resolved_dependencies=resolved_dependencies, - json_output=json_output, - packages=packages, - ) + output = dict( + headers=headers, + files=files, + resolved_dependencies_graph=resolved_dependencies, + packages=packages, + ) - else: - write_output( - headers=headers, - requirements=requirements, - resolved_dependencies=resolved_dependencies, - json_output=pdt_output, - packages=packages, - pdt_output=True, - ) + write_output( + json_output=json_output or pdt_output, + output=output, + ) if verbose: click.secho("done!") @@ -461,9 +480,7 @@ def resolve( analyze_setup_py_insecurely=analyze_setup_py_insecurely, ) - initial_requirements = [d.to_dict() for d in direct_dependencies] - - return initial_requirements, resolved_dependencies, packages + return resolved_dependencies, packages def get_requirements_from_direct_dependencies( @@ -483,27 +500,11 @@ def get_requirements_from_direct_dependencies( yield req -def write_output( - headers, requirements, resolved_dependencies, json_output, packages, pdt_output=False -): +def write_output(output, json_output): """ Write headers, requirements and resolved_dependencies as JSON to ``json_output``. Return the output data. """ - - if not pdt_output: - output = dict( - headers=headers, - requirements=requirements, - resolved_dependencies=resolved_dependencies, - packages=packages, - ) - else: - output = dict( - resolved_dependencies=resolved_dependencies, - packages=packages, - ) - json.dump(output, json_output, indent=2) return output diff --git a/tests/data/default-url-expected.json b/tests/data/default-url-expected.json index 3dd5e45c..28ced30b 100644 --- a/tests/data/default-url-expected.json +++ b/tests/data/default-url-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--specifier zipp==3.8.0", "--index-url https://pypi.org/simple", @@ -10,23 +10,12 @@ "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ - { - "purl": "pkg:pypi/zipp@3.8.0", - "extracted_requirement": "zipp==3.8.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": {} - } - ], - "resolved_dependencies": [ + "files": [], + "resolved_dependencies_graph": [ { "package": "pkg:pypi/zipp@3.8.0", "dependencies": [] diff --git a/tests/data/environment-marker-test-requirements.txt-expected.json b/tests/data/environment-marker-test-requirements.txt-expected.json index 022c3090..0aa2b9ce 100644 --- a/tests/data/environment-marker-test-requirements.txt-expected.json +++ b/tests/data/environment-marker-test-requirements.txt-expected.json @@ -1,5 +1,212 @@ { - "resolved_dependencies": [ + "headers": { + "tool_name": "python-inspector", + "tool_homepageurl": "https://github.com/nexB/python-inspector", + "tool_version": "0.7.2", + "options": [ + "--requirement /home/tg1999/Desktop/python-inspector-1/tests/data/environment-marker-test-requirements.txt", + "--index-url https://pypi.org/simple", + "--python-version 37", + "--operating-system linux", + "--json " + ], + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", + "warnings": [], + "errors": [] + }, + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/environment-marker-test-requirements.txt", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/click", + "extracted_requirement": "click>6,<6.8", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/flask@1.0", + "extracted_requirement": "Flask==1.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/itsdangerous", + "extracted_requirement": "itsdangerous<0.25", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/license-expression", + "extracted_requirement": "license-expression; platform_system == \"Windows\"", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/jinja2@2.11.3", + "extracted_requirement": "Jinja2==2.11.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/markupsafe@1.0", + "extracted_requirement": "MarkupSafe==1.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/werkzeug@0.15.3", + "extracted_requirement": "Werkzeug==0.15.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "pip_requirements", + "purl": null + } + ] + } + ], + "resolved_dependencies_graph": [ { "key": "flask", "package_name": "flask", diff --git a/tests/data/frozen-requirements.txt-expected.json b/tests/data/frozen-requirements.txt-expected.json index 7ac60b4d..54de1b9f 100644 --- a/tests/data/frozen-requirements.txt-expected.json +++ b/tests/data/frozen-requirements.txt-expected.json @@ -1,5 +1,1514 @@ { - "resolved_dependencies": [ + "headers": { + "tool_name": "python-inspector", + "tool_homepageurl": "https://github.com/nexB/python-inspector", + "tool_version": "0.7.2", + "options": [ + "--requirement /home/tg1999/Desktop/python-inspector-1/tests/data/frozen-requirements.txt", + "--index-url https://pypi.org/simple", + "--python-version 38", + "--operating-system linux", + "--json " + ], + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", + "warnings": [], + "errors": [] + }, + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/frozen-requirements.txt", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/aboutcode-toolkit@7.0.2", + "extracted_requirement": "aboutcode-toolkit==7.0.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/attrs@21.4.0", + "extracted_requirement": "attrs==21.4.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/beautifulsoup4@4.11.1", + "extracted_requirement": "beautifulsoup4==4.11.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/black@22.3.0", + "extracted_requirement": "black==22.3.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/bleach@4.1.0", + "extracted_requirement": "bleach==4.1.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/boolean-py@4.0", + "extracted_requirement": "boolean.py==4.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/certifi@2022.5.18.1", + "extracted_requirement": "certifi==2022.5.18.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/cffi@1.15.0", + "extracted_requirement": "cffi==1.15.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/charset-normalizer@2.0.12", + "extracted_requirement": "charset-normalizer==2.0.12", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/click@8.0.4", + "extracted_requirement": "click==8.0.4", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/colorama@0.4.4", + "extracted_requirement": "colorama==0.4.4", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/commoncode@30.2.0", + "extracted_requirement": "commoncode==30.2.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/cryptography@37.0.2", + "extracted_requirement": "cryptography==37.0.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/docutils@0.18.1", + "extracted_requirement": "docutils==0.18.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/dparse2@0.6.1", + "extracted_requirement": "dparse2==0.6.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/et-xmlfile@1.1.0", + "extracted_requirement": "et-xmlfile==1.1.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/execnet@1.9.0", + "extracted_requirement": "execnet==1.9.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/flask@2.1.2", + "extracted_requirement": "Flask==2.1.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/idna@3.3", + "extracted_requirement": "idna==3.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/importlib-metadata@4.8.3", + "extracted_requirement": "importlib-metadata==4.8.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/iniconfig@1.1.1", + "extracted_requirement": "iniconfig==1.1.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/intbitset@3.0.1", + "extracted_requirement": "intbitset==3.0.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/isort@5.10.1", + "extracted_requirement": "isort==5.10.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/itsdangerous@2.1.2", + "extracted_requirement": "itsdangerous==2.1.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/jeepney@0.7.1", + "extracted_requirement": "jeepney==0.7.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/jinja2@3.0.3", + "extracted_requirement": "Jinja2==3.0.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/keyring@23.4.1", + "extracted_requirement": "keyring==23.4.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/license-expression@30.0.0", + "extracted_requirement": "license-expression==30.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/markupsafe@2.0.1", + "extracted_requirement": "MarkupSafe==2.0.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/mypy-extensions@0.4.3", + "extracted_requirement": "mypy-extensions==0.4.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/openpyxl@3.0.10", + "extracted_requirement": "openpyxl==3.0.10", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/packageurl-python@0.9.9", + "extracted_requirement": "packageurl-python==0.9.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/packaging@21.3", + "extracted_requirement": "packaging==21.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pathspec@0.9.0", + "extracted_requirement": "pathspec==0.9.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pip-requirements-parser@31.2.0", + "extracted_requirement": "pip-requirements-parser==31.2.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pipdeptree@2.2.1", + "extracted_requirement": "pipdeptree==2.2.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pkginfo@1.8.3", + "extracted_requirement": "pkginfo==1.8.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pkginfo2@30.0.0", + "extracted_requirement": "pkginfo2==30.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/platformdirs@2.4.0", + "extracted_requirement": "platformdirs==2.4.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pluggy@1.0.0", + "extracted_requirement": "pluggy==1.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/py@1.11.0", + "extracted_requirement": "py==1.11.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pycodestyle@2.8.0", + "extracted_requirement": "pycodestyle==2.8.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pycparser@2.21", + "extracted_requirement": "pycparser==2.21", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pygments@2.12.0", + "extracted_requirement": "Pygments==2.12.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pyparsing@3.0.9", + "extracted_requirement": "pyparsing==3.0.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pytest@7.0.1", + "extracted_requirement": "pytest==7.0.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pytest-forked@1.4.0", + "extracted_requirement": "pytest-forked==1.4.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pytest-xdist@2.5.0", + "extracted_requirement": "pytest-xdist==2.5.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pyyaml@6.0", + "extracted_requirement": "PyYAML==6.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/readme-renderer@34.0", + "extracted_requirement": "readme-renderer==34.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/requests@2.27.1", + "extracted_requirement": "requests==2.27.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/requests-toolbelt@0.9.1", + "extracted_requirement": "requests-toolbelt==0.9.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/resolvelib@0.8.1", + "extracted_requirement": "resolvelib==0.8.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/rfc3986@1.5.0", + "extracted_requirement": "rfc3986==1.5.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/saneyaml@0.5.2", + "extracted_requirement": "saneyaml==0.5.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/secretstorage@3.3.2", + "extracted_requirement": "SecretStorage==3.3.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/six@1.16.0", + "extracted_requirement": "six==1.16.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/soupsieve@2.3.2.post1", + "extracted_requirement": "soupsieve==2.3.2.post1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/text-unidecode@1.3", + "extracted_requirement": "text-unidecode==1.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/tinynetrc@1.3.1", + "extracted_requirement": "tinynetrc==1.3.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/toml@0.10.2", + "extracted_requirement": "toml==0.10.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/tomli@1.2.3", + "extracted_requirement": "tomli==1.2.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/tqdm@4.64.0", + "extracted_requirement": "tqdm==4.64.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/twine@3.8.0", + "extracted_requirement": "twine==3.8.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/typing-extensions@4.1.1", + "extracted_requirement": "typing_extensions==4.1.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/urllib3@1.26.9", + "extracted_requirement": "urllib3==1.26.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/webencodings@0.5.1", + "extracted_requirement": "webencodings==0.5.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/werkzeug@2.1.2", + "extracted_requirement": "Werkzeug==2.1.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/zipp@3.6.0", + "extracted_requirement": "zipp==3.6.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "pip_requirements", + "purl": null + } + ] + } + ], + "resolved_dependencies_graph": [ { "key": "aboutcode-toolkit", "package_name": "aboutcode-toolkit", diff --git a/tests/data/insecure-setup-2/setup.py-expected.json b/tests/data/insecure-setup-2/setup.py-expected.json index 1810e90d..b0c91b61 100644 --- a/tests/data/insecure-setup-2/setup.py-expected.json +++ b/tests/data/insecure-setup-2/setup.py-expected.json @@ -2,70 +2,153 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--index-url https://pypi.org/simple", "--python-version 27", "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ - { - "purl": "pkg:pypi/click", - "extracted_requirement": "click>=5.0.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - }, - { - "purl": "pkg:pypi/mock", - "extracted_requirement": "mock>=1.3.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - }, - { - "purl": "pkg:pypi/cairosvg", - "extracted_requirement": "CairoSVG<2.0.0,>=1.0.20", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - }, - { - "purl": "pkg:pypi/invenio-records", - "extracted_requirement": "invenio-records~=1.0.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - }, - { - "purl": "pkg:pypi/invenio", - "extracted_requirement": "invenio[auth,base,metadata]>=3.0.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/insecure-setup-2/setup.py", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": "testpkh", + "version": "0.0.1", + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": "", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": {}, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/click", + "extracted_requirement": "click>=5.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/mock", + "extracted_requirement": "mock>=1.3.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/cairosvg", + "extracted_requirement": "CairoSVG<2.0.0,>=1.0.20", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/invenio-records", + "extracted_requirement": "invenio-records~=1.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/invenio", + "extracted_requirement": "invenio[auth,base,metadata]>=3.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/sphinx", + "extracted_requirement": "Sphinx>=1.4.2", + "scope": "docs", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/pytest", + "extracted_requirement": "pytest>=2.7", + "scope": "tests", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/flask", + "extracted_requirement": "Flask>=0.11", + "scope": "flask", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/ipaddr", + "extracted_requirement": "ipaddr>=2.1.11", + "scope": ":python_version==\"2.7\"", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://pypi.org/project/testpkh", + "repository_download_url": "https://pypi.org/packages/source/t/testpkh/testpkh-0.0.1.tar.gz", + "api_data_url": "https://pypi.org/pypi/testpkh/0.0.1/json", + "datasource_id": "pypi_setup_py", + "purl": "pkg:pypi/testpkh@0.0.1" + } + ] } ], - "resolved_dependencies": [ + "resolved_dependencies_graph": [ { "package": "pkg:pypi/amqp@2.6.1", "dependencies": [ @@ -79,7 +162,7 @@ { "package": "pkg:pypi/babel@2.9.1", "dependencies": [ - "pkg:pypi/pytz@2022.2.1" + "pkg:pypi/pytz@2022.4" ] }, { @@ -115,7 +198,7 @@ "dependencies": [ "pkg:pypi/billiard@3.6.4.0", "pkg:pypi/kombu@4.6.11", - "pkg:pypi/pytz@2022.2.1", + "pkg:pypi/pytz@2022.4", "pkg:pypi/vine@1.3.0" ] }, @@ -442,7 +525,7 @@ ] }, { - "package": "pkg:pypi/pytz@2022.2.1", + "package": "pkg:pypi/pytz@2022.4", "dependencies": [] }, { @@ -5869,12 +5952,12 @@ "type": "pypi", "namespace": null, "name": "pytz", - "version": "2022.2.1", + "version": "2022.4", "qualifiers": {}, "subpath": null, "primary_language": "Python", "description": "pytz - World Timezone Definitions for Python\n============================================\n\n:Author: Stuart Bishop \n\nIntroduction\n~~~~~~~~~~~~\n\npytz brings the Olson tz database into Python. This library allows\naccurate and cross platform timezone calculations using Python 2.4\nor higher. It also solves the issue of ambiguous times at the end\nof daylight saving time, which you can read more about in the Python\nLibrary Reference (``datetime.tzinfo``).\n\nAlmost all of the Olson timezones are supported.\n\n.. note::\n\n This library differs from the documented Python API for\n tzinfo implementations; if you want to create local wallclock\n times you need to use the ``localize()`` method documented in this\n document. In addition, if you perform date arithmetic on local\n times that cross DST boundaries, the result may be in an incorrect\n timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get\n 2002-10-27 0:59 EST instead of the correct 2002-10-27 1:59 EDT). A\n ``normalize()`` method is provided to correct this. Unfortunately these\n issues cannot be resolved without modifying the Python datetime\n implementation (see PEP-431).\n\n\nInstallation\n~~~~~~~~~~~~\n\nThis package can either be installed using ``pip`` or from a tarball using the\nstandard Python distutils.\n\nIf you are installing using ``pip``, you don't need to download anything as the\nlatest version will be downloaded for you from PyPI::\n\n pip install pytz\n\nIf you are installing from a tarball, run the following command as an\nadministrative user::\n\n python setup.py install\n\n\npytz for Enterprise\n~~~~~~~~~~~~~~~~~~~\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of pytz and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. `Learn more. `_.\n\n\nExample & Usage\n~~~~~~~~~~~~~~~\n\nLocalized times and date arithmetic\n-----------------------------------\n\n>>> from datetime import datetime, timedelta\n>>> from pytz import timezone\n>>> import pytz\n>>> utc = pytz.utc\n>>> utc.zone\n'UTC'\n>>> eastern = timezone('US/Eastern')\n>>> eastern.zone\n'US/Eastern'\n>>> amsterdam = timezone('Europe/Amsterdam')\n>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'\n\nThis library only supports two ways of building a localized time. The\nfirst is to use the ``localize()`` method provided by the pytz library.\nThis is used to localize a naive datetime (datetime with no timezone\ninformation):\n\n>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))\n>>> print(loc_dt.strftime(fmt))\n2002-10-27 06:00:00 EST-0500\n\nThe second way of building a localized time is by converting an existing\nlocalized time using the standard ``astimezone()`` method:\n\n>>> ams_dt = loc_dt.astimezone(amsterdam)\n>>> ams_dt.strftime(fmt)\n'2002-10-27 12:00:00 CET+0100'\n\nUnfortunately using the tzinfo argument of the standard datetime\nconstructors ''does not work'' with pytz for many timezones.\n\n>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt) # /!\\ Does not work this way!\n'2002-10-27 12:00:00 LMT+0018'\n\nIt is safe for timezones without daylight saving transitions though, such\nas UTC:\n\n>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt) # /!\\ Not recommended except for UTC\n'2002-10-27 12:00:00 UTC+0000'\n\nThe preferred way of dealing with times is to always work in UTC,\nconverting to localtime only when generating output to be read\nby humans.\n\n>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)\n>>> loc_dt = utc_dt.astimezone(eastern)\n>>> loc_dt.strftime(fmt)\n'2002-10-27 01:00:00 EST-0500'\n\nThis library also allows you to do date arithmetic using local\ntimes, although it is more complicated than working in UTC as you\nneed to use the ``normalize()`` method to handle daylight saving time\nand other timezone transitions. In this example, ``loc_dt`` is set\nto the instant when daylight saving time ends in the US/Eastern\ntimezone.\n\n>>> before = loc_dt - timedelta(minutes=10)\n>>> before.strftime(fmt)\n'2002-10-27 00:50:00 EST-0500'\n>>> eastern.normalize(before).strftime(fmt)\n'2002-10-27 01:50:00 EDT-0400'\n>>> after = eastern.normalize(before + timedelta(minutes=20))\n>>> after.strftime(fmt)\n'2002-10-27 01:10:00 EST-0500'\n\nCreating local times is also tricky, and the reason why working with\nlocal times is not recommended. Unfortunately, you cannot just pass\na ``tzinfo`` argument when constructing a datetime (see the next\nsection for more details)\n\n>>> dt = datetime(2002, 10, 27, 1, 30, 0)\n>>> dt1 = eastern.localize(dt, is_dst=True)\n>>> dt1.strftime(fmt)\n'2002-10-27 01:30:00 EDT-0400'\n>>> dt2 = eastern.localize(dt, is_dst=False)\n>>> dt2.strftime(fmt)\n'2002-10-27 01:30:00 EST-0500'\n\nConverting between timezones is more easily done, using the\nstandard astimezone method.\n\n>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))\n>>> utc_dt.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n>>> au_tz = timezone('Australia/Sydney')\n>>> au_dt = utc_dt.astimezone(au_tz)\n>>> au_dt.strftime(fmt)\n'2006-03-27 08:34:59 AEDT+1100'\n>>> utc_dt2 = au_dt.astimezone(utc)\n>>> utc_dt2.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n>>> utc_dt == utc_dt2\nTrue\n\nYou can take shortcuts when dealing with the UTC side of timezone\nconversions. ``normalize()`` and ``localize()`` are not really\nnecessary when there are no daylight saving time transitions to\ndeal with.\n\n>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)\n>>> utc_dt.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n>>> au_tz = timezone('Australia/Sydney')\n>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))\n>>> au_dt.strftime(fmt)\n'2006-03-27 08:34:59 AEDT+1100'\n>>> utc_dt2 = au_dt.astimezone(utc)\n>>> utc_dt2.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n\n\n``tzinfo`` API\n--------------\n\nThe ``tzinfo`` instances returned by the ``timezone()`` function have\nbeen extended to cope with ambiguous times by adding an ``is_dst``\nparameter to the ``utcoffset()``, ``dst()`` && ``tzname()`` methods.\n\n>>> tz = timezone('America/St_Johns')\n\n>>> normal = datetime(2009, 9, 1)\n>>> ambiguous = datetime(2009, 10, 31, 23, 30)\n\nThe ``is_dst`` parameter is ignored for most timestamps. It is only used\nduring DST transition ambiguous periods to resolve that ambiguity.\n\n>>> print(tz.utcoffset(normal, is_dst=True))\n-1 day, 21:30:00\n>>> print(tz.dst(normal, is_dst=True))\n1:00:00\n>>> tz.tzname(normal, is_dst=True)\n'NDT'\n\n>>> print(tz.utcoffset(ambiguous, is_dst=True))\n-1 day, 21:30:00\n>>> print(tz.dst(ambiguous, is_dst=True))\n1:00:00\n>>> tz.tzname(ambiguous, is_dst=True)\n'NDT'\n\n>>> print(tz.utcoffset(normal, is_dst=False))\n-1 day, 21:30:00\n>>> tz.dst(normal, is_dst=False).seconds\n3600\n>>> tz.tzname(normal, is_dst=False)\n'NDT'\n\n>>> print(tz.utcoffset(ambiguous, is_dst=False))\n-1 day, 20:30:00\n>>> tz.dst(ambiguous, is_dst=False)\ndatetime.timedelta(0)\n>>> tz.tzname(ambiguous, is_dst=False)\n'NST'\n\nIf ``is_dst`` is not specified, ambiguous timestamps will raise\nan ``pytz.exceptions.AmbiguousTimeError`` exception.\n\n>>> print(tz.utcoffset(normal))\n-1 day, 21:30:00\n>>> print(tz.dst(normal))\n1:00:00\n>>> tz.tzname(normal)\n'NDT'\n\n>>> import pytz.exceptions\n>>> try:\n... tz.utcoffset(ambiguous)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)\npytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00\n>>> try:\n... tz.dst(ambiguous)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)\npytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00\n>>> try:\n... tz.tzname(ambiguous)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)\npytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00\n\n\nProblems with Localtime\n~~~~~~~~~~~~~~~~~~~~~~~\n\nThe major problem we have to deal with is that certain datetimes\nmay occur twice in a year. For example, in the US/Eastern timezone\non the last Sunday morning in October, the following sequence\nhappens:\n\n - 01:00 EDT occurs\n - 1 hour later, instead of 2:00am the clock is turned back 1 hour\n and 01:00 happens again (this time 01:00 EST)\n\nIn fact, every instant between 01:00 and 02:00 occurs twice. This means\nthat if you try and create a time in the 'US/Eastern' timezone\nthe standard datetime syntax, there is no way to specify if you meant\nbefore of after the end-of-daylight-saving-time transition. Using the\npytz custom syntax, the best you can do is make an educated guess:\n\n>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 1, 30, 00))\n>>> loc_dt.strftime(fmt)\n'2002-10-27 01:30:00 EST-0500'\n\nAs you can see, the system has chosen one for you and there is a 50%\nchance of it being out by one hour. For some applications, this does\nnot matter. However, if you are trying to schedule meetings with people\nin different timezones or analyze log files it is not acceptable.\n\nThe best and simplest solution is to stick with using UTC. The pytz\npackage encourages using UTC for internal timezone representation by\nincluding a special UTC implementation based on the standard Python\nreference implementation in the Python documentation.\n\nThe UTC timezone unpickles to be the same instance, and pickles to a\nsmaller size than other pytz tzinfo instances. The UTC implementation\ncan be obtained as pytz.utc, pytz.UTC, or pytz.timezone('UTC').\n\n>>> import pickle, pytz\n>>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)\n>>> naive = dt.replace(tzinfo=None)\n>>> p = pickle.dumps(dt, 1)\n>>> naive_p = pickle.dumps(naive, 1)\n>>> len(p) - len(naive_p)\n17\n>>> new = pickle.loads(p)\n>>> new == dt\nTrue\n>>> new is dt\nFalse\n>>> new.tzinfo is dt.tzinfo\nTrue\n>>> pytz.utc is pytz.UTC is pytz.timezone('UTC')\nTrue\n\nNote that some other timezones are commonly thought of as the same (GMT,\nGreenwich, Universal, etc.). The definition of UTC is distinct from these\nother timezones, and they are not equivalent. For this reason, they will\nnot compare the same in Python.\n\n>>> utc == pytz.timezone('GMT')\nFalse\n\nSee the section `What is UTC`_, below.\n\nIf you insist on working with local times, this library provides a\nfacility for constructing them unambiguously:\n\n>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)\n>>> est_dt = eastern.localize(loc_dt, is_dst=True)\n>>> edt_dt = eastern.localize(loc_dt, is_dst=False)\n>>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt))\n2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500\n\nIf you pass None as the is_dst flag to localize(), pytz will refuse to\nguess and raise exceptions if you try to build ambiguous or non-existent\ntimes.\n\nFor example, 1:30am on 27th Oct 2002 happened twice in the US/Eastern\ntimezone when the clocks where put back at the end of Daylight Saving\nTime:\n\n>>> dt = datetime(2002, 10, 27, 1, 30, 00)\n>>> try:\n... eastern.localize(dt, is_dst=None)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % dt)\npytz.exceptions.AmbiguousTimeError: 2002-10-27 01:30:00\n\nSimilarly, 2:30am on 7th April 2002 never happened at all in the\nUS/Eastern timezone, as the clocks where put forward at 2:00am skipping\nthe entire hour:\n\n>>> dt = datetime(2002, 4, 7, 2, 30, 00)\n>>> try:\n... eastern.localize(dt, is_dst=None)\n... except pytz.exceptions.NonExistentTimeError:\n... print('pytz.exceptions.NonExistentTimeError: %s' % dt)\npytz.exceptions.NonExistentTimeError: 2002-04-07 02:30:00\n\nBoth of these exceptions share a common base class to make error handling\neasier:\n\n>>> isinstance(pytz.AmbiguousTimeError(), pytz.InvalidTimeError)\nTrue\n>>> isinstance(pytz.NonExistentTimeError(), pytz.InvalidTimeError)\nTrue\n\n\nA special case is where countries change their timezone definitions\nwith no daylight savings time switch. For example, in 1915 Warsaw\nswitched from Warsaw time to Central European time with no daylight savings\ntransition. So at the stroke of midnight on August 5th 1915 the clocks\nwere wound back 24 minutes creating an ambiguous time period that cannot\nbe specified without referring to the timezone abbreviation or the\nactual UTC offset. In this case midnight happened twice, neither time\nduring a daylight saving time period. pytz handles this transition by\ntreating the ambiguous period before the switch as daylight savings\ntime, and the ambiguous period after as standard time.\n\n\n>>> warsaw = pytz.timezone('Europe/Warsaw')\n>>> amb_dt1 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=True)\n>>> amb_dt1.strftime(fmt)\n'1915-08-04 23:59:59 WMT+0124'\n>>> amb_dt2 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=False)\n>>> amb_dt2.strftime(fmt)\n'1915-08-04 23:59:59 CET+0100'\n>>> switch_dt = warsaw.localize(datetime(1915, 8, 5, 00, 00, 00), is_dst=False)\n>>> switch_dt.strftime(fmt)\n'1915-08-05 00:00:00 CET+0100'\n>>> str(switch_dt - amb_dt1)\n'0:24:01'\n>>> str(switch_dt - amb_dt2)\n'0:00:01'\n\nThe best way of creating a time during an ambiguous time period is\nby converting from another timezone such as UTC:\n\n>>> utc_dt = datetime(1915, 8, 4, 22, 36, tzinfo=pytz.utc)\n>>> utc_dt.astimezone(warsaw).strftime(fmt)\n'1915-08-04 23:36:00 CET+0100'\n\nThe standard Python way of handling all these ambiguities is not to\nhandle them, such as demonstrated in this example using the US/Eastern\ntimezone definition from the Python documentation (Note that this\nimplementation only works for dates between 1987 and 2006 - it is\nincluded for tests only!):\n\n>>> from pytz.reference import Eastern # pytz.reference only for tests\n>>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern)\n>>> str(dt)\n'2002-10-27 00:30:00-04:00'\n>>> str(dt + timedelta(hours=1))\n'2002-10-27 01:30:00-05:00'\n>>> str(dt + timedelta(hours=2))\n'2002-10-27 02:30:00-05:00'\n>>> str(dt + timedelta(hours=3))\n'2002-10-27 03:30:00-05:00'\n\nNotice the first two results? At first glance you might think they are\ncorrect, but taking the UTC offset into account you find that they are\nactually two hours appart instead of the 1 hour we asked for.\n\n>>> from pytz.reference import UTC # pytz.reference only for tests\n>>> str(dt.astimezone(UTC))\n'2002-10-27 04:30:00+00:00'\n>>> str((dt + timedelta(hours=1)).astimezone(UTC))\n'2002-10-27 06:30:00+00:00'\n\n\nCountry Information\n~~~~~~~~~~~~~~~~~~~\n\nA mechanism is provided to access the timezones commonly in use\nfor a particular country, looked up using the ISO 3166 country code.\nIt returns a list of strings that can be used to retrieve the relevant\ntzinfo instance using ``pytz.timezone()``:\n\n>>> print(' '.join(pytz.country_timezones['nz']))\nPacific/Auckland Pacific/Chatham\n\nThe Olson database comes with a ISO 3166 country code to English country\nname mapping that pytz exposes as a dictionary:\n\n>>> print(pytz.country_names['nz'])\nNew Zealand\n\n\nWhat is UTC\n~~~~~~~~~~~\n\n'UTC' is `Coordinated Universal Time`_. It is a successor to, but distinct\nfrom, Greenwich Mean Time (GMT) and the various definitions of Universal\nTime. UTC is now the worldwide standard for regulating clocks and time\nmeasurement.\n\nAll other timezones are defined relative to UTC, and include offsets like\nUTC+0800 - hours to add or subtract from UTC to derive the local time. No\ndaylight saving time occurs in UTC, making it a useful timezone to perform\ndate arithmetic without worrying about the confusion and ambiguities caused\nby daylight saving time transitions, your country changing its timezone, or\nmobile computers that roam through multiple timezones.\n\n.. _Coordinated Universal Time: https://en.wikipedia.org/wiki/Coordinated_Universal_Time\n\n\nHelpers\n~~~~~~~\n\nThere are two lists of timezones provided.\n\n``all_timezones`` is the exhaustive list of the timezone names that can\nbe used.\n\n>>> from pytz import all_timezones\n>>> len(all_timezones) >= 500\nTrue\n>>> 'Etc/Greenwich' in all_timezones\nTrue\n\n``common_timezones`` is a list of useful, current timezones. It doesn't\ncontain deprecated zones or historical zones, except for a few I've\ndeemed in common usage, such as US/Eastern (open a bug report if you\nthink other timezones are deserving of being included here). It is also\na sequence of strings.\n\n>>> from pytz import common_timezones\n>>> len(common_timezones) < len(all_timezones)\nTrue\n>>> 'Etc/Greenwich' in common_timezones\nFalse\n>>> 'Australia/Melbourne' in common_timezones\nTrue\n>>> 'US/Eastern' in common_timezones\nTrue\n>>> 'Canada/Eastern' in common_timezones\nTrue\n>>> 'Australia/Yancowinna' in all_timezones\nTrue\n>>> 'Australia/Yancowinna' in common_timezones\nFalse\n\nBoth ``common_timezones`` and ``all_timezones`` are alphabetically\nsorted:\n\n>>> common_timezones_dupe = common_timezones[:]\n>>> common_timezones_dupe.sort()\n>>> common_timezones == common_timezones_dupe\nTrue\n>>> all_timezones_dupe = all_timezones[:]\n>>> all_timezones_dupe.sort()\n>>> all_timezones == all_timezones_dupe\nTrue\n\n``all_timezones`` and ``common_timezones`` are also available as sets.\n\n>>> from pytz import all_timezones_set, common_timezones_set\n>>> 'US/Eastern' in all_timezones_set\nTrue\n>>> 'US/Eastern' in common_timezones_set\nTrue\n>>> 'Australia/Victoria' in common_timezones_set\nFalse\n\nYou can also retrieve lists of timezones used by particular countries\nusing the ``country_timezones()`` function. It requires an ISO-3166\ntwo letter country code.\n\n>>> from pytz import country_timezones\n>>> print(' '.join(country_timezones('ch')))\nEurope/Zurich\n>>> print(' '.join(country_timezones('CH')))\nEurope/Zurich\n\n\nInternationalization - i18n/l10n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nPytz is an interface to the IANA database, which uses ASCII names. The `Unicode Consortium's Unicode Locales (CLDR) `_\nproject provides translations. Thomas Khyn's\n`l18n `_ package can be used to access\nthese translations from Python.\n\n\nLicense\n~~~~~~~\n\nMIT license.\n\nThis code is also available as part of Zope 3 under the Zope Public\nLicense, Version 2.1 (ZPL).\n\nI'm happy to relicense this code if necessary for inclusion in other\nopen source projects.\n\n\nLatest Versions\n~~~~~~~~~~~~~~~\n\nThis package will be updated after releases of the Olson timezone\ndatabase. The latest version can be downloaded from the `Python Package\nIndex `_. The code that is used\nto generate this distribution is hosted on launchpad.net and available\nusing git::\n\n git clone https://git.launchpad.net/pytz\n\nA mirror on github is also available at https://github.com/stub42/pytz\n\nAnnouncements of new releases are made on\n`Launchpad `_, and the\n`Atom feed `_\nhosted there.\n\n\nBugs, Feature Requests & Patches\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nBugs can be reported using `Launchpad Bugs `_.\n\n\nSecurity Issues\n~~~~~~~~~~~~~~~\n\nReports about security issues can be made via `Tidelift `_.\n\n\nIssues & Limitations\n~~~~~~~~~~~~~~~~~~~~\n\n- Offsets from UTC are rounded to the nearest whole minute, so timezones\n such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This\n is a limitation of the Python datetime library.\n\n- If you think a timezone definition is incorrect, I probably can't fix\n it. pytz is a direct translation of the Olson timezone database, and\n changes to the timezone definitions need to be made to this source.\n If you find errors they should be reported to the time zone mailing\n list, linked from http://www.iana.org/time-zones.\n\n\nFurther Reading\n~~~~~~~~~~~~~~~\n\nMore info than you want to know about timezones:\nhttps://data.iana.org/time-zones/tz-link.html\n\n\nContact\n~~~~~~~\n\nStuart Bishop \n\n\n\n\n", - "release_date": "2022-08-13T02:07:57", + "release_date": "2022-10-02T05:04:30", "parties": [ { "type": "person", @@ -5893,11 +5976,11 @@ ], "keywords": "timezone,tzinfo,datetime,olson,time", "homepage_url": "http://pythonhosted.org/pytz", - "download_url": "https://files.pythonhosted.org/packages/d5/50/54451e88e3da4616286029a3a17fc377de817f66a0f50e1faaee90161724/pytz-2022.2.1-py2.py3-none-any.whl", - "size": 500564, + "download_url": "https://files.pythonhosted.org/packages/d8/66/309545413162bc8271c73e622499a41cdc37217b499febe26155ff9f93ed/pytz-2022.4-py2.py3-none-any.whl", + "size": 500779, "sha1": null, - "md5": "8db17bd6a3c4dfb4df5424cdb8434e01", - "sha256": "220f481bdafa09c3955dfbdddb7b57780e9a94f5127e35456a48589b9e0c0197", + "md5": "24bcf3f123fd3538b25b96905fc44e00", + "sha256": "2c0784747071402c6e99f0bafdb7da0fa22645f06554c7ae06bf6358897e9c91", "sha512": null, "bug_tracking_url": null, "code_view_url": null, @@ -5912,20 +5995,20 @@ "dependencies": [], "repository_homepage_url": null, "repository_download_url": null, - "api_data_url": "https://pypi.org/pypi/pytz/2022.2.1/json", + "api_data_url": "https://pypi.org/pypi/pytz/2022.4/json", "datasource_id": null, - "purl": "pkg:pypi/pytz@2022.2.1" + "purl": "pkg:pypi/pytz@2022.4" }, { "type": "pypi", "namespace": null, "name": "pytz", - "version": "2022.2.1", + "version": "2022.4", "qualifiers": {}, "subpath": null, "primary_language": "Python", "description": "pytz - World Timezone Definitions for Python\n============================================\n\n:Author: Stuart Bishop \n\nIntroduction\n~~~~~~~~~~~~\n\npytz brings the Olson tz database into Python. This library allows\naccurate and cross platform timezone calculations using Python 2.4\nor higher. It also solves the issue of ambiguous times at the end\nof daylight saving time, which you can read more about in the Python\nLibrary Reference (``datetime.tzinfo``).\n\nAlmost all of the Olson timezones are supported.\n\n.. note::\n\n This library differs from the documented Python API for\n tzinfo implementations; if you want to create local wallclock\n times you need to use the ``localize()`` method documented in this\n document. In addition, if you perform date arithmetic on local\n times that cross DST boundaries, the result may be in an incorrect\n timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get\n 2002-10-27 0:59 EST instead of the correct 2002-10-27 1:59 EDT). A\n ``normalize()`` method is provided to correct this. Unfortunately these\n issues cannot be resolved without modifying the Python datetime\n implementation (see PEP-431).\n\n\nInstallation\n~~~~~~~~~~~~\n\nThis package can either be installed using ``pip`` or from a tarball using the\nstandard Python distutils.\n\nIf you are installing using ``pip``, you don't need to download anything as the\nlatest version will be downloaded for you from PyPI::\n\n pip install pytz\n\nIf you are installing from a tarball, run the following command as an\nadministrative user::\n\n python setup.py install\n\n\npytz for Enterprise\n~~~~~~~~~~~~~~~~~~~\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of pytz and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. `Learn more. `_.\n\n\nExample & Usage\n~~~~~~~~~~~~~~~\n\nLocalized times and date arithmetic\n-----------------------------------\n\n>>> from datetime import datetime, timedelta\n>>> from pytz import timezone\n>>> import pytz\n>>> utc = pytz.utc\n>>> utc.zone\n'UTC'\n>>> eastern = timezone('US/Eastern')\n>>> eastern.zone\n'US/Eastern'\n>>> amsterdam = timezone('Europe/Amsterdam')\n>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'\n\nThis library only supports two ways of building a localized time. The\nfirst is to use the ``localize()`` method provided by the pytz library.\nThis is used to localize a naive datetime (datetime with no timezone\ninformation):\n\n>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))\n>>> print(loc_dt.strftime(fmt))\n2002-10-27 06:00:00 EST-0500\n\nThe second way of building a localized time is by converting an existing\nlocalized time using the standard ``astimezone()`` method:\n\n>>> ams_dt = loc_dt.astimezone(amsterdam)\n>>> ams_dt.strftime(fmt)\n'2002-10-27 12:00:00 CET+0100'\n\nUnfortunately using the tzinfo argument of the standard datetime\nconstructors ''does not work'' with pytz for many timezones.\n\n>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt) # /!\\ Does not work this way!\n'2002-10-27 12:00:00 LMT+0018'\n\nIt is safe for timezones without daylight saving transitions though, such\nas UTC:\n\n>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt) # /!\\ Not recommended except for UTC\n'2002-10-27 12:00:00 UTC+0000'\n\nThe preferred way of dealing with times is to always work in UTC,\nconverting to localtime only when generating output to be read\nby humans.\n\n>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)\n>>> loc_dt = utc_dt.astimezone(eastern)\n>>> loc_dt.strftime(fmt)\n'2002-10-27 01:00:00 EST-0500'\n\nThis library also allows you to do date arithmetic using local\ntimes, although it is more complicated than working in UTC as you\nneed to use the ``normalize()`` method to handle daylight saving time\nand other timezone transitions. In this example, ``loc_dt`` is set\nto the instant when daylight saving time ends in the US/Eastern\ntimezone.\n\n>>> before = loc_dt - timedelta(minutes=10)\n>>> before.strftime(fmt)\n'2002-10-27 00:50:00 EST-0500'\n>>> eastern.normalize(before).strftime(fmt)\n'2002-10-27 01:50:00 EDT-0400'\n>>> after = eastern.normalize(before + timedelta(minutes=20))\n>>> after.strftime(fmt)\n'2002-10-27 01:10:00 EST-0500'\n\nCreating local times is also tricky, and the reason why working with\nlocal times is not recommended. Unfortunately, you cannot just pass\na ``tzinfo`` argument when constructing a datetime (see the next\nsection for more details)\n\n>>> dt = datetime(2002, 10, 27, 1, 30, 0)\n>>> dt1 = eastern.localize(dt, is_dst=True)\n>>> dt1.strftime(fmt)\n'2002-10-27 01:30:00 EDT-0400'\n>>> dt2 = eastern.localize(dt, is_dst=False)\n>>> dt2.strftime(fmt)\n'2002-10-27 01:30:00 EST-0500'\n\nConverting between timezones is more easily done, using the\nstandard astimezone method.\n\n>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))\n>>> utc_dt.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n>>> au_tz = timezone('Australia/Sydney')\n>>> au_dt = utc_dt.astimezone(au_tz)\n>>> au_dt.strftime(fmt)\n'2006-03-27 08:34:59 AEDT+1100'\n>>> utc_dt2 = au_dt.astimezone(utc)\n>>> utc_dt2.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n>>> utc_dt == utc_dt2\nTrue\n\nYou can take shortcuts when dealing with the UTC side of timezone\nconversions. ``normalize()`` and ``localize()`` are not really\nnecessary when there are no daylight saving time transitions to\ndeal with.\n\n>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)\n>>> utc_dt.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n>>> au_tz = timezone('Australia/Sydney')\n>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))\n>>> au_dt.strftime(fmt)\n'2006-03-27 08:34:59 AEDT+1100'\n>>> utc_dt2 = au_dt.astimezone(utc)\n>>> utc_dt2.strftime(fmt)\n'2006-03-26 21:34:59 UTC+0000'\n\n\n``tzinfo`` API\n--------------\n\nThe ``tzinfo`` instances returned by the ``timezone()`` function have\nbeen extended to cope with ambiguous times by adding an ``is_dst``\nparameter to the ``utcoffset()``, ``dst()`` && ``tzname()`` methods.\n\n>>> tz = timezone('America/St_Johns')\n\n>>> normal = datetime(2009, 9, 1)\n>>> ambiguous = datetime(2009, 10, 31, 23, 30)\n\nThe ``is_dst`` parameter is ignored for most timestamps. It is only used\nduring DST transition ambiguous periods to resolve that ambiguity.\n\n>>> print(tz.utcoffset(normal, is_dst=True))\n-1 day, 21:30:00\n>>> print(tz.dst(normal, is_dst=True))\n1:00:00\n>>> tz.tzname(normal, is_dst=True)\n'NDT'\n\n>>> print(tz.utcoffset(ambiguous, is_dst=True))\n-1 day, 21:30:00\n>>> print(tz.dst(ambiguous, is_dst=True))\n1:00:00\n>>> tz.tzname(ambiguous, is_dst=True)\n'NDT'\n\n>>> print(tz.utcoffset(normal, is_dst=False))\n-1 day, 21:30:00\n>>> tz.dst(normal, is_dst=False).seconds\n3600\n>>> tz.tzname(normal, is_dst=False)\n'NDT'\n\n>>> print(tz.utcoffset(ambiguous, is_dst=False))\n-1 day, 20:30:00\n>>> tz.dst(ambiguous, is_dst=False)\ndatetime.timedelta(0)\n>>> tz.tzname(ambiguous, is_dst=False)\n'NST'\n\nIf ``is_dst`` is not specified, ambiguous timestamps will raise\nan ``pytz.exceptions.AmbiguousTimeError`` exception.\n\n>>> print(tz.utcoffset(normal))\n-1 day, 21:30:00\n>>> print(tz.dst(normal))\n1:00:00\n>>> tz.tzname(normal)\n'NDT'\n\n>>> import pytz.exceptions\n>>> try:\n... tz.utcoffset(ambiguous)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)\npytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00\n>>> try:\n... tz.dst(ambiguous)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)\npytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00\n>>> try:\n... tz.tzname(ambiguous)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)\npytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00\n\n\nProblems with Localtime\n~~~~~~~~~~~~~~~~~~~~~~~\n\nThe major problem we have to deal with is that certain datetimes\nmay occur twice in a year. For example, in the US/Eastern timezone\non the last Sunday morning in October, the following sequence\nhappens:\n\n - 01:00 EDT occurs\n - 1 hour later, instead of 2:00am the clock is turned back 1 hour\n and 01:00 happens again (this time 01:00 EST)\n\nIn fact, every instant between 01:00 and 02:00 occurs twice. This means\nthat if you try and create a time in the 'US/Eastern' timezone\nthe standard datetime syntax, there is no way to specify if you meant\nbefore of after the end-of-daylight-saving-time transition. Using the\npytz custom syntax, the best you can do is make an educated guess:\n\n>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 1, 30, 00))\n>>> loc_dt.strftime(fmt)\n'2002-10-27 01:30:00 EST-0500'\n\nAs you can see, the system has chosen one for you and there is a 50%\nchance of it being out by one hour. For some applications, this does\nnot matter. However, if you are trying to schedule meetings with people\nin different timezones or analyze log files it is not acceptable.\n\nThe best and simplest solution is to stick with using UTC. The pytz\npackage encourages using UTC for internal timezone representation by\nincluding a special UTC implementation based on the standard Python\nreference implementation in the Python documentation.\n\nThe UTC timezone unpickles to be the same instance, and pickles to a\nsmaller size than other pytz tzinfo instances. The UTC implementation\ncan be obtained as pytz.utc, pytz.UTC, or pytz.timezone('UTC').\n\n>>> import pickle, pytz\n>>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)\n>>> naive = dt.replace(tzinfo=None)\n>>> p = pickle.dumps(dt, 1)\n>>> naive_p = pickle.dumps(naive, 1)\n>>> len(p) - len(naive_p)\n17\n>>> new = pickle.loads(p)\n>>> new == dt\nTrue\n>>> new is dt\nFalse\n>>> new.tzinfo is dt.tzinfo\nTrue\n>>> pytz.utc is pytz.UTC is pytz.timezone('UTC')\nTrue\n\nNote that some other timezones are commonly thought of as the same (GMT,\nGreenwich, Universal, etc.). The definition of UTC is distinct from these\nother timezones, and they are not equivalent. For this reason, they will\nnot compare the same in Python.\n\n>>> utc == pytz.timezone('GMT')\nFalse\n\nSee the section `What is UTC`_, below.\n\nIf you insist on working with local times, this library provides a\nfacility for constructing them unambiguously:\n\n>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)\n>>> est_dt = eastern.localize(loc_dt, is_dst=True)\n>>> edt_dt = eastern.localize(loc_dt, is_dst=False)\n>>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt))\n2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500\n\nIf you pass None as the is_dst flag to localize(), pytz will refuse to\nguess and raise exceptions if you try to build ambiguous or non-existent\ntimes.\n\nFor example, 1:30am on 27th Oct 2002 happened twice in the US/Eastern\ntimezone when the clocks where put back at the end of Daylight Saving\nTime:\n\n>>> dt = datetime(2002, 10, 27, 1, 30, 00)\n>>> try:\n... eastern.localize(dt, is_dst=None)\n... except pytz.exceptions.AmbiguousTimeError:\n... print('pytz.exceptions.AmbiguousTimeError: %s' % dt)\npytz.exceptions.AmbiguousTimeError: 2002-10-27 01:30:00\n\nSimilarly, 2:30am on 7th April 2002 never happened at all in the\nUS/Eastern timezone, as the clocks where put forward at 2:00am skipping\nthe entire hour:\n\n>>> dt = datetime(2002, 4, 7, 2, 30, 00)\n>>> try:\n... eastern.localize(dt, is_dst=None)\n... except pytz.exceptions.NonExistentTimeError:\n... print('pytz.exceptions.NonExistentTimeError: %s' % dt)\npytz.exceptions.NonExistentTimeError: 2002-04-07 02:30:00\n\nBoth of these exceptions share a common base class to make error handling\neasier:\n\n>>> isinstance(pytz.AmbiguousTimeError(), pytz.InvalidTimeError)\nTrue\n>>> isinstance(pytz.NonExistentTimeError(), pytz.InvalidTimeError)\nTrue\n\n\nA special case is where countries change their timezone definitions\nwith no daylight savings time switch. For example, in 1915 Warsaw\nswitched from Warsaw time to Central European time with no daylight savings\ntransition. So at the stroke of midnight on August 5th 1915 the clocks\nwere wound back 24 minutes creating an ambiguous time period that cannot\nbe specified without referring to the timezone abbreviation or the\nactual UTC offset. In this case midnight happened twice, neither time\nduring a daylight saving time period. pytz handles this transition by\ntreating the ambiguous period before the switch as daylight savings\ntime, and the ambiguous period after as standard time.\n\n\n>>> warsaw = pytz.timezone('Europe/Warsaw')\n>>> amb_dt1 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=True)\n>>> amb_dt1.strftime(fmt)\n'1915-08-04 23:59:59 WMT+0124'\n>>> amb_dt2 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=False)\n>>> amb_dt2.strftime(fmt)\n'1915-08-04 23:59:59 CET+0100'\n>>> switch_dt = warsaw.localize(datetime(1915, 8, 5, 00, 00, 00), is_dst=False)\n>>> switch_dt.strftime(fmt)\n'1915-08-05 00:00:00 CET+0100'\n>>> str(switch_dt - amb_dt1)\n'0:24:01'\n>>> str(switch_dt - amb_dt2)\n'0:00:01'\n\nThe best way of creating a time during an ambiguous time period is\nby converting from another timezone such as UTC:\n\n>>> utc_dt = datetime(1915, 8, 4, 22, 36, tzinfo=pytz.utc)\n>>> utc_dt.astimezone(warsaw).strftime(fmt)\n'1915-08-04 23:36:00 CET+0100'\n\nThe standard Python way of handling all these ambiguities is not to\nhandle them, such as demonstrated in this example using the US/Eastern\ntimezone definition from the Python documentation (Note that this\nimplementation only works for dates between 1987 and 2006 - it is\nincluded for tests only!):\n\n>>> from pytz.reference import Eastern # pytz.reference only for tests\n>>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern)\n>>> str(dt)\n'2002-10-27 00:30:00-04:00'\n>>> str(dt + timedelta(hours=1))\n'2002-10-27 01:30:00-05:00'\n>>> str(dt + timedelta(hours=2))\n'2002-10-27 02:30:00-05:00'\n>>> str(dt + timedelta(hours=3))\n'2002-10-27 03:30:00-05:00'\n\nNotice the first two results? At first glance you might think they are\ncorrect, but taking the UTC offset into account you find that they are\nactually two hours appart instead of the 1 hour we asked for.\n\n>>> from pytz.reference import UTC # pytz.reference only for tests\n>>> str(dt.astimezone(UTC))\n'2002-10-27 04:30:00+00:00'\n>>> str((dt + timedelta(hours=1)).astimezone(UTC))\n'2002-10-27 06:30:00+00:00'\n\n\nCountry Information\n~~~~~~~~~~~~~~~~~~~\n\nA mechanism is provided to access the timezones commonly in use\nfor a particular country, looked up using the ISO 3166 country code.\nIt returns a list of strings that can be used to retrieve the relevant\ntzinfo instance using ``pytz.timezone()``:\n\n>>> print(' '.join(pytz.country_timezones['nz']))\nPacific/Auckland Pacific/Chatham\n\nThe Olson database comes with a ISO 3166 country code to English country\nname mapping that pytz exposes as a dictionary:\n\n>>> print(pytz.country_names['nz'])\nNew Zealand\n\n\nWhat is UTC\n~~~~~~~~~~~\n\n'UTC' is `Coordinated Universal Time`_. It is a successor to, but distinct\nfrom, Greenwich Mean Time (GMT) and the various definitions of Universal\nTime. UTC is now the worldwide standard for regulating clocks and time\nmeasurement.\n\nAll other timezones are defined relative to UTC, and include offsets like\nUTC+0800 - hours to add or subtract from UTC to derive the local time. No\ndaylight saving time occurs in UTC, making it a useful timezone to perform\ndate arithmetic without worrying about the confusion and ambiguities caused\nby daylight saving time transitions, your country changing its timezone, or\nmobile computers that roam through multiple timezones.\n\n.. _Coordinated Universal Time: https://en.wikipedia.org/wiki/Coordinated_Universal_Time\n\n\nHelpers\n~~~~~~~\n\nThere are two lists of timezones provided.\n\n``all_timezones`` is the exhaustive list of the timezone names that can\nbe used.\n\n>>> from pytz import all_timezones\n>>> len(all_timezones) >= 500\nTrue\n>>> 'Etc/Greenwich' in all_timezones\nTrue\n\n``common_timezones`` is a list of useful, current timezones. It doesn't\ncontain deprecated zones or historical zones, except for a few I've\ndeemed in common usage, such as US/Eastern (open a bug report if you\nthink other timezones are deserving of being included here). It is also\na sequence of strings.\n\n>>> from pytz import common_timezones\n>>> len(common_timezones) < len(all_timezones)\nTrue\n>>> 'Etc/Greenwich' in common_timezones\nFalse\n>>> 'Australia/Melbourne' in common_timezones\nTrue\n>>> 'US/Eastern' in common_timezones\nTrue\n>>> 'Canada/Eastern' in common_timezones\nTrue\n>>> 'Australia/Yancowinna' in all_timezones\nTrue\n>>> 'Australia/Yancowinna' in common_timezones\nFalse\n\nBoth ``common_timezones`` and ``all_timezones`` are alphabetically\nsorted:\n\n>>> common_timezones_dupe = common_timezones[:]\n>>> common_timezones_dupe.sort()\n>>> common_timezones == common_timezones_dupe\nTrue\n>>> all_timezones_dupe = all_timezones[:]\n>>> all_timezones_dupe.sort()\n>>> all_timezones == all_timezones_dupe\nTrue\n\n``all_timezones`` and ``common_timezones`` are also available as sets.\n\n>>> from pytz import all_timezones_set, common_timezones_set\n>>> 'US/Eastern' in all_timezones_set\nTrue\n>>> 'US/Eastern' in common_timezones_set\nTrue\n>>> 'Australia/Victoria' in common_timezones_set\nFalse\n\nYou can also retrieve lists of timezones used by particular countries\nusing the ``country_timezones()`` function. It requires an ISO-3166\ntwo letter country code.\n\n>>> from pytz import country_timezones\n>>> print(' '.join(country_timezones('ch')))\nEurope/Zurich\n>>> print(' '.join(country_timezones('CH')))\nEurope/Zurich\n\n\nInternationalization - i18n/l10n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nPytz is an interface to the IANA database, which uses ASCII names. The `Unicode Consortium's Unicode Locales (CLDR) `_\nproject provides translations. Thomas Khyn's\n`l18n `_ package can be used to access\nthese translations from Python.\n\n\nLicense\n~~~~~~~\n\nMIT license.\n\nThis code is also available as part of Zope 3 under the Zope Public\nLicense, Version 2.1 (ZPL).\n\nI'm happy to relicense this code if necessary for inclusion in other\nopen source projects.\n\n\nLatest Versions\n~~~~~~~~~~~~~~~\n\nThis package will be updated after releases of the Olson timezone\ndatabase. The latest version can be downloaded from the `Python Package\nIndex `_. The code that is used\nto generate this distribution is hosted on launchpad.net and available\nusing git::\n\n git clone https://git.launchpad.net/pytz\n\nA mirror on github is also available at https://github.com/stub42/pytz\n\nAnnouncements of new releases are made on\n`Launchpad `_, and the\n`Atom feed `_\nhosted there.\n\n\nBugs, Feature Requests & Patches\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nBugs can be reported using `Launchpad Bugs `_.\n\n\nSecurity Issues\n~~~~~~~~~~~~~~~\n\nReports about security issues can be made via `Tidelift `_.\n\n\nIssues & Limitations\n~~~~~~~~~~~~~~~~~~~~\n\n- Offsets from UTC are rounded to the nearest whole minute, so timezones\n such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This\n is a limitation of the Python datetime library.\n\n- If you think a timezone definition is incorrect, I probably can't fix\n it. pytz is a direct translation of the Olson timezone database, and\n changes to the timezone definitions need to be made to this source.\n If you find errors they should be reported to the time zone mailing\n list, linked from http://www.iana.org/time-zones.\n\n\nFurther Reading\n~~~~~~~~~~~~~~~\n\nMore info than you want to know about timezones:\nhttps://data.iana.org/time-zones/tz-link.html\n\n\nContact\n~~~~~~~\n\nStuart Bishop \n\n\n\n\n", - "release_date": "2022-08-13T02:07:59", + "release_date": "2022-10-02T05:04:32", "parties": [ { "type": "person", @@ -5944,11 +6027,11 @@ ], "keywords": "timezone,tzinfo,datetime,olson,time", "homepage_url": "http://pythonhosted.org/pytz", - "download_url": "https://files.pythonhosted.org/packages/24/0c/401283bb1499768e33ddd2e1a35817c775405c1f047a9dc088a29ce2ea5d/pytz-2022.2.1.tar.gz", - "size": 316105, + "download_url": "https://files.pythonhosted.org/packages/31/da/2d48d3499b59c7f3c5d5e1c79fcee5537c320c8ab7b7a0cd2db578bc34b3/pytz-2022.4.tar.gz", + "size": 316055, "sha1": null, - "md5": "5c7aa995be1a0091df9774502f84be4b", - "sha256": "cea221417204f2d1a2aa03ddae3e867921971d0d76f14d87abb4414415bbdcf5", + "md5": "b1d2ed6592bbdf6002ef52b4ab8e2efe", + "sha256": "48ce799d83b6f8aab2020e369b627446696619e79645419610b9facd909b3174", "sha512": null, "bug_tracking_url": null, "code_view_url": null, @@ -5963,9 +6046,9 @@ "dependencies": [], "repository_homepage_url": null, "repository_download_url": null, - "api_data_url": "https://pypi.org/pypi/pytz/2022.2.1/json", + "api_data_url": "https://pypi.org/pypi/pytz/2022.4/json", "datasource_id": null, - "purl": "pkg:pypi/pytz@2022.2.1" + "purl": "pkg:pypi/pytz@2022.4" }, { "type": "pypi", diff --git a/tests/data/insecure-setup/setup.py-expected.json b/tests/data/insecure-setup/setup.py-expected.json index 70b7b456..4c3ef58a 100644 --- a/tests/data/insecure-setup/setup.py-expected.json +++ b/tests/data/insecure-setup/setup.py-expected.json @@ -2,50 +2,125 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--index-url https://pypi.org/simple", "--python-version 27", "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ + "files": [ { - "purl": "pkg:pypi/isodate", - "extracted_requirement": "isodate", - "scope": "install", - "is_runtime": false, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - }, - { - "purl": "pkg:pypi/pyparsing", - "extracted_requirement": "pyparsing", - "scope": "install", - "is_runtime": false, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - }, - { - "purl": "pkg:pypi/six", - "extracted_requirement": "six", - "scope": "install", - "is_runtime": false, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/insecure-setup/setup.py", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": "rdflib", + "version": "5.0.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": "RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Daniel 'eikeon' Krech", + "email": "eikeon@eikeon.com", + "url": null + }, + { + "type": "person", + "role": "maintainer", + "name": "RDFLib Team", + "email": "rdflib-dev@google.com", + "url": null + } + ], + "keywords": [ + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Topic :: Software Development :: Libraries :: Python Modules", + "Operating System :: OS Independent", + "Natural Language :: English" + ], + "homepage_url": "https://github.com/RDFLib/rdflib", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": { + "license": "BSD-3-Clause", + "classifiers": [ + "License :: OSI Approved :: BSD License" + ] + }, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/isodate", + "extracted_requirement": "isodate", + "scope": "install", + "is_runtime": false, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/pyparsing", + "extracted_requirement": "pyparsing", + "scope": "install", + "is_runtime": false, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/six", + "extracted_requirement": "six", + "scope": "install", + "is_runtime": false, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://pypi.org/project/rdflib", + "repository_download_url": "https://pypi.org/packages/source/r/rdflib/rdflib-5.0.0.tar.gz", + "api_data_url": "https://pypi.org/pypi/rdflib/5.0.0/json", + "datasource_id": "pypi_setup_py", + "purl": "pkg:pypi/rdflib@5.0.0" + } + ] } ], - "resolved_dependencies": [ + "resolved_dependencies_graph": [ { "package": "pkg:pypi/isodate@0.6.1", "dependencies": [ diff --git a/tests/data/pdt-requirements.txt-expected.json b/tests/data/pdt-requirements.txt-expected.json index 022c3090..80096a8f 100644 --- a/tests/data/pdt-requirements.txt-expected.json +++ b/tests/data/pdt-requirements.txt-expected.json @@ -1,5 +1,191 @@ { - "resolved_dependencies": [ + "headers": { + "tool_name": "python-inspector", + "tool_homepageurl": "https://github.com/nexB/python-inspector", + "tool_version": "0.7.2", + "options": [ + "--requirement /home/tg1999/Desktop/python-inspector-1/tests/data/pdt-requirements.txt", + "--index-url https://pypi.org/simple", + "--python-version 38", + "--operating-system linux", + "--json " + ], + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", + "warnings": [], + "errors": [] + }, + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/pdt-requirements.txt", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/click@6.7", + "extracted_requirement": "click==6.7", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/flask@1.0", + "extracted_requirement": "Flask==1.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/itsdangerous@0.24", + "extracted_requirement": "itsdangerous==0.24", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/jinja2@2.11.3", + "extracted_requirement": "Jinja2==2.11.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/markupsafe@1.0", + "extracted_requirement": "MarkupSafe==1.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/werkzeug@0.15.3", + "extracted_requirement": "Werkzeug==0.15.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "pip_requirements", + "purl": null + } + ] + } + ], + "resolved_dependencies_graph": [ { "key": "flask", "package_name": "flask", diff --git a/tests/data/pinned-pdt-requirements.txt-expected.json b/tests/data/pinned-pdt-requirements.txt-expected.json index 1b2b3cba..87ad4d7b 100644 --- a/tests/data/pinned-pdt-requirements.txt-expected.json +++ b/tests/data/pinned-pdt-requirements.txt-expected.json @@ -1,5 +1,674 @@ { - "resolved_dependencies": [ + "headers": { + "tool_name": "python-inspector", + "tool_homepageurl": "https://github.com/nexB/python-inspector", + "tool_version": "0.7.2", + "options": [ + "--requirement /home/tg1999/Desktop/python-inspector-1/tests/data/pinned-pdt-requirements.txt", + "--index-url https://pypi.org/simple", + "--python-version 38", + "--operating-system linux", + "--json " + ], + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", + "warnings": [], + "errors": [] + }, + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/pinned-pdt-requirements.txt", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/aboutcode-toolkit@7.0.2", + "extracted_requirement": "aboutcode-toolkit==7.0.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/attrs@21.4.0", + "extracted_requirement": "attrs==21.4.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/beautifulsoup4@4.11.1", + "extracted_requirement": "beautifulsoup4==4.11.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/certifi@2022.5.18.1", + "extracted_requirement": "certifi==2022.5.18.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/charset-normalizer@2.0.12", + "extracted_requirement": "charset-normalizer==2.0.12", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/click@8.0.4", + "extracted_requirement": "click==8.0.4", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/colorama@0.4.4", + "extracted_requirement": "colorama==0.4.4", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/commoncode@30.2.0", + "extracted_requirement": "commoncode==30.2.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/dparse2@0.6.1", + "extracted_requirement": "dparse2==0.6.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/idna@3.3", + "extracted_requirement": "idna==3.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/importlib-metadata@4.8.3", + "extracted_requirement": "importlib-metadata==4.8.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/intbitset@3.0.1", + "extracted_requirement": "intbitset==3.0.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/packageurl-python@0.9.9", + "extracted_requirement": "packageurl-python==0.9.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/packaging@21.3", + "extracted_requirement": "packaging==21.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/python-inspector", + "extracted_requirement": "--editable git+https://github.com/nexB/python-inspector@18baae17824d6bacb4b1d519b10a0d0e50775884#egg=python_inspector", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": { + "is_editable": true, + "link": "git+https://github.com/nexB/python-inspector@18baae17824d6bacb4b1d519b10a0d0e50775884#egg=python_inspector", + "hash_options": [], + "is_constraint": false, + "is_archive": false, + "is_wheel": false, + "is_url": true, + "is_vcs_url": true, + "is_name_at_url": false, + "is_local_path": true + } + }, + { + "purl": "pkg:pypi/pip-requirements-parser@31.2.0", + "extracted_requirement": "pip-requirements-parser==31.2.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pkginfo2@30.0.0", + "extracted_requirement": "pkginfo2==30.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pyparsing@3.0.9", + "extracted_requirement": "pyparsing==3.0.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pyyaml@6.0", + "extracted_requirement": "PyYAML==6.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/requests@2.27.1", + "extracted_requirement": "requests==2.27.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/resolvelib@0.8.1", + "extracted_requirement": "resolvelib==0.8.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/saneyaml@0.5.2", + "extracted_requirement": "saneyaml==0.5.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/soupsieve@2.3.2.post1", + "extracted_requirement": "soupsieve==2.3.2.post1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/text-unidecode@1.3", + "extracted_requirement": "text-unidecode==1.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/toml@0.10.2", + "extracted_requirement": "toml==0.10.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/typing@3.6.6", + "extracted_requirement": "typing==3.6.6", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/typing-extensions@4.1.1", + "extracted_requirement": "typing_extensions==4.1.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/urllib3@1.26.9", + "extracted_requirement": "urllib3==1.26.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/zipp@3.6.0", + "extracted_requirement": "zipp==3.6.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "pip_requirements", + "purl": null + } + ] + } + ], + "resolved_dependencies_graph": [ { "key": "aboutcode-toolkit", "package_name": "aboutcode-toolkit", diff --git a/tests/data/pinned-requirements.txt-expected.json b/tests/data/pinned-requirements.txt-expected.json index 6c5be1ce..ebfbcee6 100644 --- a/tests/data/pinned-requirements.txt-expected.json +++ b/tests/data/pinned-requirements.txt-expected.json @@ -2,629 +2,673 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ + "--requirement /home/tg1999/Desktop/python-inspector-1/tests/data/pinned-requirements.txt", "--index-url https://pypi.org/simple", "--python-version 38", "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ - { - "purl": "pkg:pypi/aboutcode-toolkit@7.0.2", - "extracted_requirement": "aboutcode-toolkit==7.0.2", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/attrs@21.4.0", - "extracted_requirement": "attrs==21.4.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/beautifulsoup4@4.11.1", - "extracted_requirement": "beautifulsoup4==4.11.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/certifi@2022.5.18.1", - "extracted_requirement": "certifi==2022.5.18.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/charset-normalizer@2.0.12", - "extracted_requirement": "charset-normalizer==2.0.12", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/click@8.0.4", - "extracted_requirement": "click==8.0.4", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/colorama@0.4.4", - "extracted_requirement": "colorama==0.4.4", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/commoncode@30.2.0", - "extracted_requirement": "commoncode==30.2.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/dparse2@0.6.1", - "extracted_requirement": "dparse2==0.6.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/idna@3.3", - "extracted_requirement": "idna==3.3", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/importlib-metadata@4.8.3", - "extracted_requirement": "importlib-metadata==4.8.3", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/intbitset@3.0.1", - "extracted_requirement": "intbitset==3.0.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/packageurl-python@0.9.9", - "extracted_requirement": "packageurl-python==0.9.9", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/packaging@21.3", - "extracted_requirement": "packaging==21.3", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/python-inspector", - "extracted_requirement": "--editable git+https://github.com/nexB/python-inspector@18baae17824d6bacb4b1d519b10a0d0e50775884#egg=python_inspector", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": { - "is_editable": true, - "link": "git+https://github.com/nexB/python-inspector@18baae17824d6bacb4b1d519b10a0d0e50775884#egg=python_inspector", - "hash_options": [], - "is_constraint": false, - "is_archive": false, - "is_wheel": false, - "is_url": true, - "is_vcs_url": true, - "is_name_at_url": false, - "is_local_path": true - } - }, - { - "purl": "pkg:pypi/pip-requirements-parser@31.2.0", - "extracted_requirement": "pip-requirements-parser==31.2.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/pkginfo2@30.0.0", - "extracted_requirement": "pkginfo2==30.0.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/pyparsing@3.0.9", - "extracted_requirement": "pyparsing==3.0.9", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/pyyaml@6.0", - "extracted_requirement": "PyYAML==6.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/requests@2.27.1", - "extracted_requirement": "requests==2.27.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/resolvelib@0.8.1", - "extracted_requirement": "resolvelib==0.8.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/saneyaml@0.5.2", - "extracted_requirement": "saneyaml==0.5.2", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/soupsieve@2.3.2.post1", - "extracted_requirement": "soupsieve==2.3.2.post1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/text-unidecode@1.3", - "extracted_requirement": "text-unidecode==1.3", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/toml@0.10.2", - "extracted_requirement": "toml==0.10.2", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/typing@3.6.6", - "extracted_requirement": "typing==3.6.6", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/typing-extensions@4.1.1", - "extracted_requirement": "typing_extensions==4.1.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/urllib3@1.26.9", - "extracted_requirement": "urllib3==1.26.9", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } - }, - { - "purl": "pkg:pypi/zipp@3.6.0", - "extracted_requirement": "zipp==3.6.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": { - "is_editable": false, - "link": null, - "hash_options": [], - "is_constraint": false, - "is_archive": null, - "is_wheel": false, - "is_url": null, - "is_vcs_url": null, - "is_name_at_url": false, - "is_local_path": null - } + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/pinned-requirements.txt", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": null, + "version": null, + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": null, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/aboutcode-toolkit@7.0.2", + "extracted_requirement": "aboutcode-toolkit==7.0.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/attrs@21.4.0", + "extracted_requirement": "attrs==21.4.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/beautifulsoup4@4.11.1", + "extracted_requirement": "beautifulsoup4==4.11.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/certifi@2022.5.18.1", + "extracted_requirement": "certifi==2022.5.18.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/charset-normalizer@2.0.12", + "extracted_requirement": "charset-normalizer==2.0.12", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/click@8.0.4", + "extracted_requirement": "click==8.0.4", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/colorama@0.4.4", + "extracted_requirement": "colorama==0.4.4", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/commoncode@30.2.0", + "extracted_requirement": "commoncode==30.2.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/dparse2@0.6.1", + "extracted_requirement": "dparse2==0.6.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/idna@3.3", + "extracted_requirement": "idna==3.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/importlib-metadata@4.8.3", + "extracted_requirement": "importlib-metadata==4.8.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/intbitset@3.0.1", + "extracted_requirement": "intbitset==3.0.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/packageurl-python@0.9.9", + "extracted_requirement": "packageurl-python==0.9.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/packaging@21.3", + "extracted_requirement": "packaging==21.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/python-inspector", + "extracted_requirement": "--editable git+https://github.com/nexB/python-inspector@18baae17824d6bacb4b1d519b10a0d0e50775884#egg=python_inspector", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": { + "is_editable": true, + "link": "git+https://github.com/nexB/python-inspector@18baae17824d6bacb4b1d519b10a0d0e50775884#egg=python_inspector", + "hash_options": [], + "is_constraint": false, + "is_archive": false, + "is_wheel": false, + "is_url": true, + "is_vcs_url": true, + "is_name_at_url": false, + "is_local_path": true + } + }, + { + "purl": "pkg:pypi/pip-requirements-parser@31.2.0", + "extracted_requirement": "pip-requirements-parser==31.2.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pkginfo2@30.0.0", + "extracted_requirement": "pkginfo2==30.0.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pyparsing@3.0.9", + "extracted_requirement": "pyparsing==3.0.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/pyyaml@6.0", + "extracted_requirement": "PyYAML==6.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/requests@2.27.1", + "extracted_requirement": "requests==2.27.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/resolvelib@0.8.1", + "extracted_requirement": "resolvelib==0.8.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/saneyaml@0.5.2", + "extracted_requirement": "saneyaml==0.5.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/soupsieve@2.3.2.post1", + "extracted_requirement": "soupsieve==2.3.2.post1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/text-unidecode@1.3", + "extracted_requirement": "text-unidecode==1.3", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/toml@0.10.2", + "extracted_requirement": "toml==0.10.2", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/typing@3.6.6", + "extracted_requirement": "typing==3.6.6", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/typing-extensions@4.1.1", + "extracted_requirement": "typing_extensions==4.1.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/urllib3@1.26.9", + "extracted_requirement": "urllib3==1.26.9", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + }, + { + "purl": "pkg:pypi/zipp@3.6.0", + "extracted_requirement": "zipp==3.6.0", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": true, + "resolved_package": {}, + "extra_data": { + "is_editable": false, + "link": null, + "hash_options": [], + "is_constraint": false, + "is_archive": null, + "is_wheel": false, + "is_url": null, + "is_vcs_url": null, + "is_name_at_url": false, + "is_local_path": null + } + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "pip_requirements", + "purl": null + } + ] } ], - "resolved_dependencies": [ + "resolved_dependencies_graph": [ { "package": "pkg:pypi/aboutcode-toolkit@7.0.2", "dependencies": [ diff --git a/tests/data/setup/simple-setup.py-expected.json b/tests/data/setup/simple-setup.py-expected.json index 78c86ba4..f96f648c 100644 --- a/tests/data/setup/simple-setup.py-expected.json +++ b/tests/data/setup/simple-setup.py-expected.json @@ -2,30 +2,82 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--index-url https://pypi.org/simple", "--python-version 27", "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ + "files": [ { - "purl": "pkg:pypi/license-expression", - "extracted_requirement": "license-expression<1.2,>=0.1", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/setup/simple-setup.py", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": "Example-App", + "version": "2.4.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": "A synthetic test case for OSS Review Toolkit", + "release_date": null, + "parties": [], + "keywords": [ + "Programming Language :: Python :: 2" + ], + "homepage_url": "https://example.org/app", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": { + "license": "MIT License", + "classifiers": [ + "License :: OSI Approved :: MIT License" + ] + }, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": { + "python_requires": ">2, <=3" + }, + "dependencies": [ + { + "purl": "pkg:pypi/license-expression", + "extracted_requirement": "license-expression<1.2,>=0.1", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://pypi.org/project/Example-App", + "repository_download_url": "https://pypi.org/packages/source/E/Example-App/Example-App-2.4.0.tar.gz", + "api_data_url": "https://pypi.org/pypi/Example-App/2.4.0/json", + "datasource_id": "pypi_setup_py", + "purl": "pkg:pypi/example-app@2.4.0" + } + ] } ], - "resolved_dependencies": [ + "resolved_dependencies_graph": [ { "package": "pkg:pypi/boolean-py@3.8", "dependencies": [] diff --git a/tests/data/setup/spdx-setup.py-expected.json b/tests/data/setup/spdx-setup.py-expected.json index bc929fac..03c258c5 100644 --- a/tests/data/setup/spdx-setup.py-expected.json +++ b/tests/data/setup/spdx-setup.py-expected.json @@ -1,5 +1,117 @@ { - "resolved_dependencies": [ + "headers": { + "tool_name": "python-inspector", + "tool_homepageurl": "https://github.com/nexB/python-inspector", + "tool_version": "0.7.2", + "options": [ + "--index-url https://pypi.org/simple", + "--python-version 27", + "--operating-system linux", + "--json " + ], + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", + "warnings": [], + "errors": [] + }, + "files": [ + { + "type": "file", + "path": "/home/tg1999/Desktop/python-inspector-1/tests/data/setup/spdx-setup.py", + "package_data": [ + { + "type": "pypi", + "namespace": null, + "name": "spdx-tools", + "version": "0.5.4", + "qualifiers": {}, + "subpath": null, + "primary_language": "Python", + "description": "SPDX parser and tools.", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Ahmed H. Ismail", + "email": "ahm3d.hisham@gmail.com", + "url": null + }, + { + "type": "person", + "role": "maintainer", + "name": "Philippe Ombredanne, SPDX group at the Linux Foundation and others", + "email": "pombredanne@gmail.com", + "url": null + } + ], + "keywords": [ + "Intended Audience :: Developers", + "Programming Language :: Python :: 2.7" + ], + "homepage_url": "https://github.com/spdx/tools-python", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "license_expression": null, + "declared_license": { + "license": "Apache-2.0", + "classifiers": [ + "License :: OSI Approved :: Apache Software License" + ] + }, + "notice_text": null, + "source_packages": [], + "file_references": [], + "extra_data": {}, + "dependencies": [ + { + "purl": "pkg:pypi/ply", + "extracted_requirement": "ply", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/rdflib", + "extracted_requirement": "rdflib", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + }, + { + "purl": "pkg:pypi/six", + "extracted_requirement": "six", + "scope": "install", + "is_runtime": true, + "is_optional": false, + "is_resolved": false, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": "https://pypi.org/project/spdx-tools", + "repository_download_url": "https://pypi.org/packages/source/s/spdx-tools/spdx-tools-0.5.4.tar.gz", + "api_data_url": "https://pypi.org/pypi/spdx-tools/0.5.4/json", + "datasource_id": "pypi_setup_py", + "purl": "pkg:pypi/spdx-tools@0.5.4" + } + ] + } + ], + "resolved_dependencies_graph": [ { "key": "ply", "package_name": "ply", diff --git a/tests/data/single-url-except-simple-expected.json b/tests/data/single-url-except-simple-expected.json index b63a3b88..a3ef5dd9 100644 --- a/tests/data/single-url-except-simple-expected.json +++ b/tests/data/single-url-except-simple-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--specifier flask", "--index-url https://pypi.org/simple", @@ -11,23 +11,12 @@ "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ - { - "purl": "pkg:pypi/flask", - "extracted_requirement": "flask", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - } - ], - "resolved_dependencies": [ + "files": [], + "resolved_dependencies_graph": [ { "package": "pkg:pypi/click@8.1.3", "dependencies": [] @@ -36,14 +25,14 @@ "package": "pkg:pypi/flask@2.2.2", "dependencies": [ "pkg:pypi/click@8.1.3", - "pkg:pypi/importlib-metadata@4.12.0", + "pkg:pypi/importlib-metadata@5.0.0", "pkg:pypi/itsdangerous@2.1.2", "pkg:pypi/jinja2@3.1.2", "pkg:pypi/werkzeug@2.2.2" ] }, { - "package": "pkg:pypi/importlib-metadata@4.12.0", + "package": "pkg:pypi/importlib-metadata@5.0.0", "dependencies": [ "pkg:pypi/zipp@3.8.1" ] @@ -282,12 +271,12 @@ "type": "pypi", "namespace": null, "name": "importlib-metadata", - "version": "4.12.0", + "version": "5.0.0", "qualifiers": {}, "subpath": null, "primary_language": "Python", - "description": ".. image:: https://img.shields.io/pypi/v/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. image:: https://img.shields.io/pypi/pyversions/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. _PyPI link: https://pypi.org/project/importlib_metadata\n\n.. image:: https://github.com/python/importlib_metadata/workflows/tests/badge.svg\n :target: https://github.com/python/importlib_metadata/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: Code style: Black\n\n.. image:: https://readthedocs.org/projects/importlib-metadata/badge/?version=latest\n :target: https://importlib-metadata.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://img.shields.io/badge/skeleton-2022-informational\n :target: https://blog.jaraco.com/skeleton\n\n\nLibrary to access the metadata for a Python package.\n\nThis package supplies third-party access to the functionality of\n`importlib.metadata `_\nincluding improvements added to subsequent Python versions.\n\n\nCompatibility\n=============\n\nNew features are introduced in this third-party library and later merged\ninto CPython. The following table indicates which versions of this library\nwere contributed to different versions in the standard library:\n\n.. list-table::\n :header-rows: 1\n\n * - importlib_metadata\n - stdlib\n * - 4.8\n - 3.11\n * - 4.4\n - 3.10\n * - 1.4\n - 3.8\n\n\nUsage\n=====\n\nSee the `online documentation `_\nfor usage details.\n\n`Finder authors\n`_ can\nalso add support for custom package installers. See the above documentation\nfor details.\n\n\nCaveats\n=======\n\nThis project primarily supports third-party packages installed by PyPA\ntools (or other conforming packages). It does not support:\n\n- Packages in the stdlib.\n- Packages installed without metadata.\n\nProject details\n===============\n\n * Project home: https://github.com/python/importlib_metadata\n * Report bugs at: https://github.com/python/importlib_metadata/issues\n * Code hosting: https://github.com/python/importlib_metadata\n * Documentation: https://importlib_metadata.readthedocs.io/\n", - "release_date": "2022-06-25T17:01:22", + "description": ".. image:: https://img.shields.io/pypi/v/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. image:: https://img.shields.io/pypi/pyversions/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. _PyPI link: https://pypi.org/project/importlib_metadata\n\n.. image:: https://github.com/python/importlib_metadata/workflows/tests/badge.svg\n :target: https://github.com/python/importlib_metadata/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: Code style: Black\n\n.. image:: https://readthedocs.org/projects/importlib-metadata/badge/?version=latest\n :target: https://importlib-metadata.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://img.shields.io/badge/skeleton-2022-informational\n :target: https://blog.jaraco.com/skeleton\n\n.. image:: https://tidelift.com/badges/package/pypi/importlib-metadata\n :target: https://tidelift.com/subscription/pkg/pypi-importlib-metadata?utm_source=pypi-importlib-metadata&utm_medium=readme\n\nLibrary to access the metadata for a Python package.\n\nThis package supplies third-party access to the functionality of\n`importlib.metadata `_\nincluding improvements added to subsequent Python versions.\n\n\nCompatibility\n=============\n\nNew features are introduced in this third-party library and later merged\ninto CPython. The following table indicates which versions of this library\nwere contributed to different versions in the standard library:\n\n.. list-table::\n :header-rows: 1\n\n * - importlib_metadata\n - stdlib\n * - 4.8\n - 3.11\n * - 4.4\n - 3.10\n * - 1.4\n - 3.8\n\n\nUsage\n=====\n\nSee the `online documentation `_\nfor usage details.\n\n`Finder authors\n`_ can\nalso add support for custom package installers. See the above documentation\nfor details.\n\n\nCaveats\n=======\n\nThis project primarily supports third-party packages installed by PyPA\ntools (or other conforming packages). It does not support:\n\n- Packages in the stdlib.\n- Packages installed without metadata.\n\nProject details\n===============\n\n * Project home: https://github.com/python/importlib_metadata\n * Report bugs at: https://github.com/python/importlib_metadata/issues\n * Code hosting: https://github.com/python/importlib_metadata\n * Documentation: https://importlib_metadata.readthedocs.io/\n\nFor Enterprise\n==============\n\nAvailable as part of the Tidelift Subscription.\n\nThis project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.\n\n`Learn more `_.\n\nSecurity Contact\n================\n\nTo report a security vulnerability, please use the\n`Tidelift security contact `_.\nTidelift will coordinate the fix and disclosure.\n", + "release_date": "2022-10-02T00:42:11", "parties": [ { "type": "person", @@ -306,11 +295,11 @@ ], "keywords": [], "homepage_url": "https://github.com/python/importlib_metadata", - "download_url": "https://files.pythonhosted.org/packages/d2/a2/8c239dc898138f208dd14b441b196e7b3032b94d3137d9d8453e186967fc/importlib_metadata-4.12.0-py3-none-any.whl", - "size": 21704, + "download_url": "https://files.pythonhosted.org/packages/b5/64/ef29a63cf08f047bb7fb22ab0f1f774b87eed0bb46d067a5a524798a4af8/importlib_metadata-5.0.0-py3-none-any.whl", + "size": 21811, "sha1": null, - "md5": "1e7ee4220dec07980ecb9acc7bd7bd5b", - "sha256": "7401a975809ea1fdc658c3aa4f78cc2195a0e019c5cbc4c06122884e9ae80c23", + "md5": "5b511c1cd69bbb1b933d6c4157c0e983", + "sha256": "ddb0e35065e8938f867ed4928d0ae5bf2a53b7773871bfe6bcc7e4fcdc7dea43", "sha512": null, "bug_tracking_url": null, "code_view_url": null, @@ -325,20 +314,20 @@ "dependencies": [], "repository_homepage_url": null, "repository_download_url": null, - "api_data_url": "https://pypi.org/pypi/importlib-metadata/4.12.0/json", + "api_data_url": "https://pypi.org/pypi/importlib-metadata/5.0.0/json", "datasource_id": null, - "purl": "pkg:pypi/importlib-metadata@4.12.0" + "purl": "pkg:pypi/importlib-metadata@5.0.0" }, { "type": "pypi", "namespace": null, "name": "importlib-metadata", - "version": "4.12.0", + "version": "5.0.0", "qualifiers": {}, "subpath": null, "primary_language": "Python", - "description": ".. image:: https://img.shields.io/pypi/v/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. image:: https://img.shields.io/pypi/pyversions/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. _PyPI link: https://pypi.org/project/importlib_metadata\n\n.. image:: https://github.com/python/importlib_metadata/workflows/tests/badge.svg\n :target: https://github.com/python/importlib_metadata/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: Code style: Black\n\n.. image:: https://readthedocs.org/projects/importlib-metadata/badge/?version=latest\n :target: https://importlib-metadata.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://img.shields.io/badge/skeleton-2022-informational\n :target: https://blog.jaraco.com/skeleton\n\n\nLibrary to access the metadata for a Python package.\n\nThis package supplies third-party access to the functionality of\n`importlib.metadata `_\nincluding improvements added to subsequent Python versions.\n\n\nCompatibility\n=============\n\nNew features are introduced in this third-party library and later merged\ninto CPython. The following table indicates which versions of this library\nwere contributed to different versions in the standard library:\n\n.. list-table::\n :header-rows: 1\n\n * - importlib_metadata\n - stdlib\n * - 4.8\n - 3.11\n * - 4.4\n - 3.10\n * - 1.4\n - 3.8\n\n\nUsage\n=====\n\nSee the `online documentation `_\nfor usage details.\n\n`Finder authors\n`_ can\nalso add support for custom package installers. See the above documentation\nfor details.\n\n\nCaveats\n=======\n\nThis project primarily supports third-party packages installed by PyPA\ntools (or other conforming packages). It does not support:\n\n- Packages in the stdlib.\n- Packages installed without metadata.\n\nProject details\n===============\n\n * Project home: https://github.com/python/importlib_metadata\n * Report bugs at: https://github.com/python/importlib_metadata/issues\n * Code hosting: https://github.com/python/importlib_metadata\n * Documentation: https://importlib_metadata.readthedocs.io/\n", - "release_date": "2022-06-25T17:01:24", + "description": ".. image:: https://img.shields.io/pypi/v/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. image:: https://img.shields.io/pypi/pyversions/importlib_metadata.svg\n :target: `PyPI link`_\n\n.. _PyPI link: https://pypi.org/project/importlib_metadata\n\n.. image:: https://github.com/python/importlib_metadata/workflows/tests/badge.svg\n :target: https://github.com/python/importlib_metadata/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: Code style: Black\n\n.. image:: https://readthedocs.org/projects/importlib-metadata/badge/?version=latest\n :target: https://importlib-metadata.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://img.shields.io/badge/skeleton-2022-informational\n :target: https://blog.jaraco.com/skeleton\n\n.. image:: https://tidelift.com/badges/package/pypi/importlib-metadata\n :target: https://tidelift.com/subscription/pkg/pypi-importlib-metadata?utm_source=pypi-importlib-metadata&utm_medium=readme\n\nLibrary to access the metadata for a Python package.\n\nThis package supplies third-party access to the functionality of\n`importlib.metadata `_\nincluding improvements added to subsequent Python versions.\n\n\nCompatibility\n=============\n\nNew features are introduced in this third-party library and later merged\ninto CPython. The following table indicates which versions of this library\nwere contributed to different versions in the standard library:\n\n.. list-table::\n :header-rows: 1\n\n * - importlib_metadata\n - stdlib\n * - 4.8\n - 3.11\n * - 4.4\n - 3.10\n * - 1.4\n - 3.8\n\n\nUsage\n=====\n\nSee the `online documentation `_\nfor usage details.\n\n`Finder authors\n`_ can\nalso add support for custom package installers. See the above documentation\nfor details.\n\n\nCaveats\n=======\n\nThis project primarily supports third-party packages installed by PyPA\ntools (or other conforming packages). It does not support:\n\n- Packages in the stdlib.\n- Packages installed without metadata.\n\nProject details\n===============\n\n * Project home: https://github.com/python/importlib_metadata\n * Report bugs at: https://github.com/python/importlib_metadata/issues\n * Code hosting: https://github.com/python/importlib_metadata\n * Documentation: https://importlib_metadata.readthedocs.io/\n\nFor Enterprise\n==============\n\nAvailable as part of the Tidelift Subscription.\n\nThis project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.\n\n`Learn more `_.\n\nSecurity Contact\n================\n\nTo report a security vulnerability, please use the\n`Tidelift security contact `_.\nTidelift will coordinate the fix and disclosure.\n", + "release_date": "2022-10-02T00:42:12", "parties": [ { "type": "person", @@ -357,11 +346,11 @@ ], "keywords": [], "homepage_url": "https://github.com/python/importlib_metadata", - "download_url": "https://files.pythonhosted.org/packages/1a/16/441080c907df829016729e71d8bdd42d99b9bdde48b01492ed08912c0aa9/importlib_metadata-4.12.0.tar.gz", - "size": 48153, + "download_url": "https://files.pythonhosted.org/packages/7e/ec/97f2ce958b62961fddd7258e0ceede844953606ad09b672fa03b86c453d3/importlib_metadata-5.0.0.tar.gz", + "size": 48756, "sha1": null, - "md5": "cfcf29185e13439c76d09c94bc8d81f4", - "sha256": "637245b8bab2b6502fcbc752cc4b7a6f6243bb02b31c5c26156ad103d3d45670", + "md5": "ccd58a387cc2bab6cf72fdf21e403749", + "sha256": "da31db32b304314d044d3c12c79bd59e307889b287ad12ff387b3500835fc2ab", "sha512": null, "bug_tracking_url": null, "code_view_url": null, @@ -376,9 +365,9 @@ "dependencies": [], "repository_homepage_url": null, "repository_download_url": null, - "api_data_url": "https://pypi.org/pypi/importlib-metadata/4.12.0/json", + "api_data_url": "https://pypi.org/pypi/importlib-metadata/5.0.0/json", "datasource_id": null, - "purl": "pkg:pypi/importlib-metadata@4.12.0" + "purl": "pkg:pypi/importlib-metadata@5.0.0" }, { "type": "pypi", diff --git a/tests/data/single-url-expected.json b/tests/data/single-url-expected.json index d6d04807..0c7b7f5a 100644 --- a/tests/data/single-url-expected.json +++ b/tests/data/single-url-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--specifier zipp==3.8.0", "--index-url https://pypi.org/simple", @@ -10,23 +10,12 @@ "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ - { - "purl": "pkg:pypi/zipp@3.8.0", - "extracted_requirement": "zipp==3.8.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": true, - "resolved_package": {}, - "extra_data": {} - } - ], - "resolved_dependencies": [ + "files": [], + "resolved_dependencies_graph": [ { "package": "pkg:pypi/zipp@3.8.0", "dependencies": [] diff --git a/tests/data/tilde_req-expected.json b/tests/data/tilde_req-expected.json index 05eabf44..7d5f6256 100644 --- a/tests/data/tilde_req-expected.json +++ b/tests/data/tilde_req-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.7.1", + "tool_version": "0.7.2", "options": [ "--specifier zipp~=3.8.0", "--index-url https://pypi.org/simple", @@ -11,23 +11,12 @@ "--operating-system linux", "--json " ], - "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", + "notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/nexB/python-inspector/ for support and download.", "warnings": [], "errors": [] }, - "requirements": [ - { - "purl": "pkg:pypi/zipp", - "extracted_requirement": "zipp~=3.8.0", - "scope": "install", - "is_runtime": true, - "is_optional": false, - "is_resolved": false, - "resolved_package": {}, - "extra_data": {} - } - ], - "resolved_dependencies": [ + "files": [], + "resolved_dependencies_graph": [ { "package": "pkg:pypi/zipp@3.8.1", "dependencies": [] diff --git a/tests/test_cli.py b/tests/test_cli.py index d71e13de..949fed68 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -304,7 +304,7 @@ def test_passing_of_json_pdt_and_json_flags(): def test_version_option(): options = ["--version"] result = run_cli(options=options) - assert "0.7.1" in result.output + assert "0.7.2" in result.output def test_passing_of_netrc_file_that_does_not_exist(): @@ -344,7 +344,7 @@ def check_requirements_resolution( options.extend(extra_options) run_cli(options=options) check_json_results( - result_file=result_file, expected_file=expected_file, regen=regen, clean=not pdt_output + result_file=result_file, expected_file=expected_file, regen=regen, clean=True ) @@ -368,7 +368,7 @@ def check_setup_py_resolution( assert message in result.output if expected_rc == 0: check_json_results( - result_file=result_file, expected_file=expected_file, regen=regen, clean=not pdt_output + result_file=result_file, expected_file=expected_file, regen=regen, clean=True ) @@ -386,10 +386,6 @@ def check_json_results(result_file, expected_file, clean=True, regen=REGEN_TEST_ """ with open(result_file) as res: results = json.load(res) - - if clean: - clean_results(results) - if regen: with open(expected_file, "w") as reg: json.dump(results, reg, indent=2, separators=(",", ": ")) @@ -400,7 +396,8 @@ def check_json_results(result_file, expected_file, clean=True, regen=REGEN_TEST_ if clean: clean_results(expected) - + if clean: + results = clean_results(results) assert results == expected @@ -409,6 +406,10 @@ def clean_results(results): Return cleaned results removing transient values that can change across test runs. """ + files = results.get("files", []) + for file in files: + path = os.path.split(file["path"])[-1] + file["path"] = path headers = results.get("headers", {}) options = headers.get("options", []) headers["options"] = [o for o in options if not o.startswith("--requirement")] diff --git a/tests/test_resolution.py b/tests/test_resolution.py index 743a8203..dde37a92 100644 --- a/tests/test_resolution.py +++ b/tests/test_resolution.py @@ -117,7 +117,7 @@ def test_get_resolved_dependencies_with_tilde_requirement_using_json_api(): assert plist == [ "pkg:pypi/click@8.1.3", "pkg:pypi/flask@2.1.3", - "pkg:pypi/importlib-metadata@4.12.0", + "pkg:pypi/importlib-metadata@5.0.0", "pkg:pypi/itsdangerous@2.1.2", "pkg:pypi/jinja2@3.1.2", "pkg:pypi/markupsafe@2.1.1", @@ -147,7 +147,7 @@ def test_without_supported_wheels(): "pkg:pypi/hyperlink@21.0.0", "pkg:pypi/idna@3.4", "pkg:pypi/pycparser@2.21", - "pkg:pypi/setuptools@65.4.0", + "pkg:pypi/setuptools@65.4.1", "pkg:pypi/txaio@22.2.1", ] diff --git a/tests/test_setup_py_live_eval_cli.py b/tests/test_setup_py_live_eval_cli.py deleted file mode 100644 index 77c0b15f..00000000 --- a/tests/test_setup_py_live_eval_cli.py +++ /dev/null @@ -1,490 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright (c) nexB Inc. and others. All rights reserved. -# ScanCode is a trademark of nexB Inc. -# SPDX-License-Identifier: Apache-2.0 -# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/python-inspector for support or download. -# See https://aboutcode.org for more information about nexB OSS projects. -# - -import json -import os - -import pytest -from click.testing import CliRunner -from commoncode.testcase import FileDrivenTesting - -from _packagedcode import models -from python_inspector.resolve_cli import get_requirements_from_direct_dependencies -from python_inspector.resolve_cli import resolve_dependencies - -# Used for tests to regenerate fixtures with regen=True -REGEN_TEST_FIXTURES = os.getenv("PYINSP_REGEN_TEST_FIXTURES", False) - -test_env = FileDrivenTesting() -test_env.test_data_dir = os.path.join(os.path.dirname(__file__), "data") -setup_test_env = FileDrivenTesting() -setup_test_env.test_data_dir = os.path.join(os.path.dirname(__file__), "data", "setup") - - -@pytest.mark.online -def test_cli_with_default_urls(): - expected_file = test_env.get_test_loc("default-url-expected.json", must_exist=False) - specifier = "zipp==3.8.0" - extra_options = [ - "--use-pypi-json-api", - ] - check_specs_resolution( - specifier=specifier, - expected_file=expected_file, - extra_options=extra_options, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_pdt_output(): - requirements_file = test_env.get_test_loc("pdt-requirements.txt") - expected_file = test_env.get_test_loc("pdt-requirements.txt-expected.json", must_exist=False) - extra_options = [] - check_requirements_resolution( - requirements_file=requirements_file, - expected_file=expected_file, - extra_options=extra_options, - pdt_output=True, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_pdt_output_with_pinned_requirements(): - requirements_file = test_env.get_test_loc("pinned-pdt-requirements.txt") - expected_file = test_env.get_test_loc( - "pinned-pdt-requirements.txt-expected.json", must_exist=False - ) - extra_options = [] - check_requirements_resolution( - requirements_file=requirements_file, - expected_file=expected_file, - extra_options=extra_options, - pdt_output=True, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_pdt_output_with_frozen_requirements(): - requirements_file = test_env.get_test_loc("frozen-requirements.txt") - expected_file = test_env.get_test_loc("frozen-requirements.txt-expected.json", must_exist=False) - extra_options = [] - check_requirements_resolution( - requirements_file=requirements_file, - expected_file=expected_file, - extra_options=extra_options, - pdt_output=True, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_single_index_url(): - expected_file = test_env.get_test_loc("single-url-expected.json", must_exist=False) - specifier = "zipp==3.8.0" - extra_options = [ - "--index-url", - "https://pypi.org/simple", - ] - check_specs_resolution( - specifier=specifier, - expected_file=expected_file, - extra_options=extra_options, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_single_index_url_except_pypi_simple(): - expected_file = test_env.get_test_loc( - "single-url-except-simple-expected.json", must_exist=False - ) - # using flask since it's not present in thirdparty - specifier = "flask" - extra_options = [ - "--index-url", - "https://thirdparty.aboutcode.org/pypi/simple/", - ] - check_specs_resolution( - specifier=specifier, - expected_file=expected_file, - extra_options=extra_options, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_multiple_index_url_and_tilde_req(): - expected_file = test_env.get_test_loc("tilde_req-expected.json", must_exist=False) - specifier = "zipp~=3.8.0" - extra_options = [ - "--index-url", - "https://pypi.org/simple", - "--index-url", - "https://thirdparty.aboutcode.org/pypi/simple/", - ] - check_specs_resolution( - specifier=specifier, - expected_file=expected_file, - extra_options=extra_options, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_environment_marker_and_complex_ranges(): - requirements_file = test_env.get_test_loc("environment-marker-test-requirements.txt") - expected_file = test_env.get_test_loc( - "environment-marker-test-requirements.txt-expected.json", must_exist=False - ) - extra_options = [ - "--operating-system", - "linux", - "--python-version", - "37", - ] - check_requirements_resolution( - requirements_file=requirements_file, - expected_file=expected_file, - extra_options=extra_options, - pdt_output=True, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_multiple_index_url_and_tilde_req_with_max_rounds(): - expected_file = test_env.get_test_loc("tilde_req-expected.json", must_exist=False) - specifier = "zipp~=3.8.0" - extra_options = [ - "--index-url", - "https://pypi.org/simple", - "--index-url", - "https://thirdparty.aboutcode.org/pypi/simple/", - "--max-rounds", - "100", - ] - check_specs_resolution( - specifier=specifier, - expected_file=expected_file, - extra_options=extra_options, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_multiple_index_url_and_tilde_req_and_netrc_file_without_matching_url(): - expected_file = test_env.get_test_loc("tilde_req-expected.json", must_exist=False) - netrc_file = test_env.get_test_loc("test.netrc", must_exist=False) - specifier = "zipp~=3.8.0" - extra_options = [ - "--index-url", - "https://pypi.org/simple", - "--index-url", - "https://thirdparty.aboutcode.org/pypi/simple/", - "--netrc", - netrc_file, - ] - check_specs_resolution( - specifier=specifier, - expected_file=expected_file, - extra_options=extra_options, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_pinned_requirements_file(): - requirements_file = test_env.get_test_loc("pinned-requirements.txt") - expected_file = test_env.get_test_loc("pinned-requirements.txt-expected.json", must_exist=False) - check_requirements_resolution( - requirements_file=requirements_file, - expected_file=expected_file, - regen=REGEN_TEST_FIXTURES, - ) - - -@pytest.mark.online -def test_cli_with_setup_py_failure(): - setup_py_file = setup_test_env.get_test_loc("simple-setup.py") - expected_file = setup_test_env.get_test_loc("simple-setup.py-expected.json", must_exist=False) - check_setup_py_resolution( - setup_py=setup_py_file, - expected_file=expected_file, - regen=REGEN_TEST_FIXTURES, - expected_rc=1, - message=f"Python version 3.8 is not compatible with setup.py {setup_py_file} python_requires >2, <=3", - ) - - -@pytest.mark.online -def test_cli_with_insecure_option(): - setup_py_file = setup_test_env.get_test_loc("spdx-setup.py") - expected_file = setup_test_env.get_test_loc("spdx-setup.py-expected.json", must_exist=False) - check_setup_py_resolution( - setup_py=setup_py_file, - expected_file=expected_file, - regen=REGEN_TEST_FIXTURES, - extra_options=["--python-version", "27", "--analyze-setup-py-insecurely"], - pdt_output=True, - ) - - -@pytest.mark.online -def test_cli_with_setup_py(): - setup_py_file = setup_test_env.get_test_loc("simple-setup.py") - expected_file = setup_test_env.get_test_loc("simple-setup.py-expected.json", must_exist=False) - check_setup_py_resolution( - setup_py=setup_py_file, - expected_file=expected_file, - regen=REGEN_TEST_FIXTURES, - extra_options=["--python-version", "27"], - ) - - -def check_specs_resolution( - specifier, - expected_file, - extra_options=tuple(), - regen=REGEN_TEST_FIXTURES, -): - result_file = test_env.get_temp_file("json") - options = ["--specifier", specifier, "--json", result_file] - options.extend(extra_options) - run_cli(options=options) - check_json_results( - result_file=result_file, - expected_file=expected_file, - regen=regen, - ) - - -def test_passing_of_json_pdt_and_json_flags(): - result_file = test_env.get_temp_file("json") - options = ["--specifier", "foo", "--json", result_file, "--json-pdt", result_file] - run_cli(options=options, expected_rc=1) - - -def test_version_option(): - options = ["--version"] - result = run_cli(options=options) - assert "0.7.1" in result.output - - -def test_passing_of_netrc_file_that_does_not_exist(): - options = ["--specifier", "foo", "--netrc", "bar.txt", "--json", "-"] - run_cli(options=options, expected_rc=2) - - -def test_passing_of_wrong_requirements_file(): - test_file = test_env.get_temp_file(file_name="pdt.txt", extension="") - with open(test_file, "w") as f: - f.write("") - test_file_2 = test_env.get_temp_file(file_name="setup.py", extension="") - with open(test_file_2, "w") as f: - f.write("") - options = ["--requirement", test_file, "--json", "-", "--requirement", test_file_2] - result = run_cli(options=options, expected_rc=1) - assert "Error: no requirements requested" in result.output - - -def test_passing_of_no_json_output_flag(): - options = ["--specifier", "foo"] - run_cli(options=options, expected_rc=1) - - -def check_requirements_resolution( - requirements_file, - expected_file, - extra_options=tuple(), - regen=REGEN_TEST_FIXTURES, - pdt_output=False, -): - result_file = test_env.get_temp_file("json") - if pdt_output: - options = ["--requirement", requirements_file, "--json-pdt", result_file] - else: - options = ["--requirement", requirements_file, "--json", result_file] - options.extend(extra_options) - run_cli(options=options) - check_json_results( - result_file=result_file, expected_file=expected_file, regen=regen, clean=not pdt_output - ) - - -def check_setup_py_resolution( - setup_py, - expected_file, - extra_options=tuple(), - regen=REGEN_TEST_FIXTURES, - pdt_output=False, - expected_rc=0, - message="", -): - result_file = setup_test_env.get_temp_file(file_name="json") - if pdt_output: - options = ["--setup-py", setup_py, "--json-pdt", result_file] - else: - options = ["--setup-py", setup_py, "--json", result_file] - options.extend(extra_options) - result = run_cli(options=options, expected_rc=expected_rc) - if message: - assert message in result.output - if expected_rc == 0: - check_json_results( - result_file=result_file, expected_file=expected_file, regen=regen, clean=not pdt_output - ) - - -def check_json_results(result_file, expected_file, clean=True, regen=REGEN_TEST_FIXTURES): - """ - Check the ``result_file`` JSON results against the ``expected_file`` - expected JSON results. - - If ``clean`` is True, remove headers data that can change across runs to - provide stable test resultys. - - If ``regen`` is True the expected_file WILL BE overwritten with the new - results from ``results_file``. This is convenient for updating tests - expectations. - """ - with open(result_file) as res: - results = json.load(res) - - if clean: - clean_results(results) - - if regen: - with open(expected_file, "w") as reg: - json.dump(results, reg, indent=2, separators=(",", ": ")) - expected = results - else: - with open(expected_file) as res: - expected = json.load(res) - - if clean: - clean_results(expected) - - assert results == expected - - -def clean_results(results): - """ - Return cleaned results removing transient values that can change across test - runs. - """ - headers = results.get("headers", {}) - options = headers.get("options", []) - headers["options"] = [o for o in options if not o.startswith("--requirement")] - return results - - -def run_cli(options, cli=resolve_dependencies, expected_rc=0, env=None): - """ - Run a command line resolution. Return a click.testing.Result object. - """ - - if not env: - env = dict(os.environ) - - runner = CliRunner() - result = runner.invoke(cli, options, catch_exceptions=False, env=env) - - if result.exit_code != expected_rc: - output = result.output - error = f""" -Failure to run: -rc: {result.exit_code} -python-inspector {options} -output: -{output} -""" - assert result.exit_code == expected_rc, error - return result - - -def test_get_requirements_from_direct_dependencies(): - direct_dependencies = [ - models.DependentPackage( - purl="pkg:pypi/django", - scope="install", - is_runtime=True, - is_optional=False, - is_resolved=False, - extracted_requirement="django>=1.11.11", - extra_data=dict( - is_editable=False, - link=None, - hash_options=[], - is_constraint=False, - is_archive=False, - is_wheel=False, - is_url=False, - is_vcs_url=False, - is_name_at_url=False, - is_local_path=False, - ), - ) - ] - - requirements = [ - str(r) - for r in get_requirements_from_direct_dependencies( - direct_dependencies=direct_dependencies, environment_marker={} - ) - ] - - assert requirements == ["django>=1.11.11"] - - -def test_get_requirements_from_direct_dependencies_with_empty_list(): - assert ( - list( - get_requirements_from_direct_dependencies(direct_dependencies=[], environment_marker={}) - ) - == [] - ) - - -def test_get_requirements_from_direct_dependencies_with_editable_requirements(): - direct_dependencies = [ - models.DependentPackage( - purl="pkg:pypi/django", - scope="install", - is_runtime=True, - is_optional=False, - is_resolved=False, - extracted_requirement="django>=1.11.11", - extra_data=dict( - is_editable=True, - link=None, - hash_options=[], - is_constraint=False, - is_archive=False, - is_wheel=False, - is_url=False, - is_vcs_url=False, - is_name_at_url=False, - is_local_path=False, - ), - ) - ] - - requirements = [ - str(r) - for r in get_requirements_from_direct_dependencies( - direct_dependencies=direct_dependencies, environment_marker={} - ) - ] - - assert requirements == []