diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eb4efb07..1ba93356a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11"] steps: - name: Checkout code diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f3ae1b897..01cd6e171 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,9 +1,12 @@ Changelog ========= -v32.8.0 (unreleased) +v33.0.0 (unreleased) -------------------- +- Upgrade Django to version 5.0 and drop support for Python 3.8 and 3.9 + https://github.com/nexB/scancode.io/issues/1020 + - Refactor run_scancode to not fail on scan errors happening at the resource level, such as a timeout. Project error message are created instead. https://github.com/nexB/scancode.io/issues/1018 diff --git a/docs/custom-pipelines.rst b/docs/custom-pipelines.rst index 15cd871b6..752aa6cb4 100644 --- a/docs/custom-pipelines.rst +++ b/docs/custom-pipelines.rst @@ -240,7 +240,7 @@ the entry point to the pipeline under the ``[options.entry_points]`` section. packages=find: include_package_data = true zip_safe = false - python_requires = >=3.8 + python_requires = >=3.10 setup_requires = setuptools_scm[toml] >= 4 [options.packages.find] diff --git a/docs/installation.rst b/docs/installation.rst index 053bdc378..c01539495 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -224,7 +224,7 @@ Pre-installation Checklist Before you install ScanCode.io, make sure you have the following prerequisites: - * **Python: versions 3.8 to 3.11** found at https://www.python.org/downloads/ + * **Python: versions 3.10 to 3.11** found at https://www.python.org/downloads/ * **Git**: most recent release available at https://git-scm.com/ * **PostgreSQL**: release 11 or later found at https://www.postgresql.org/ or https://postgresapp.com/ on macOS diff --git a/etc/thirdparty/virtualenv.pyz b/etc/thirdparty/virtualenv.pyz index 867f72082..6ce8c1116 100644 Binary files a/etc/thirdparty/virtualenv.pyz and b/etc/thirdparty/virtualenv.pyz differ diff --git a/etc/thirdparty/virtualenv.pyz.ABOUT b/etc/thirdparty/virtualenv.pyz.ABOUT index 34c3cb3e7..616520c99 100644 --- a/etc/thirdparty/virtualenv.pyz.ABOUT +++ b/etc/thirdparty/virtualenv.pyz.ABOUT @@ -1,7 +1,7 @@ about_resource: virtualenv.pyz name: get-virtualenv -version: 20.24.6 -download_url: https://github.com/pypa/get-virtualenv/raw/20.24.6/public/virtualenv.pyz +version: 20.25.0 +download_url: https://github.com/pypa/get-virtualenv/raw/20.25.0/public/virtualenv.pyz description: virtualenv is a tool to create isolated Python environments. homepage_url: https://github.com/pypa/virtualenv license_expression: lgpl-2.1-plus AND (bsd-new OR apache-2.0) AND mit AND python AND bsd-new @@ -10,4 +10,4 @@ copyright: Copyright (c) The Python Software Foundation and others redistribute: yes attribute: yes track_changes: yes -package_url: pkg:github/pypa/get-virtualenv@20.24.6#public/virtualenv.pyz \ No newline at end of file +package_url: pkg:github/pypa/get-virtualenv@20.25.0#public/virtualenv.pyz \ No newline at end of file diff --git a/scanpipe/apps.py b/scanpipe/apps.py index 100f3d628..c92ab5227 100644 --- a/scanpipe/apps.py +++ b/scanpipe/apps.py @@ -23,6 +23,7 @@ import inspect import logging import sys +import warnings from importlib.machinery import SourceFileLoader from pathlib import Path @@ -74,6 +75,12 @@ def ready(self): # before its running process death. # In ASYNC mode, the cleanup is handled by the "ScanCodeIOWorker" worker. if not settings.SCANCODEIO_ASYNC and "runserver" in sys.argv: + warnings.filterwarnings( + "ignore", + message="Accessing the database during app initialization", + category=RuntimeWarning, + module="django", + ) self.sync_runs_and_jobs() def load_pipelines(self): @@ -82,9 +89,7 @@ def load_pipelines(self): pipelines Python files found at `SCANCODEIO_PIPELINES_DIRS` locations. """ entry_points = importlib_metadata.entry_points() - - # Ignore duplicated entries caused by duplicated paths in `sys.path`. - pipeline_entry_points = set(entry_points.get("scancodeio_pipelines")) + pipeline_entry_points = set(entry_points.select(group="scancodeio_pipelines")) for entry_point in sorted(pipeline_entry_points): self.register_pipeline(name=entry_point.name, cls=entry_point.load()) diff --git a/scanpipe/pipes/__init__.py b/scanpipe/pipes/__init__.py index 5a189379a..bbd85e3ee 100644 --- a/scanpipe/pipes/__init__.py +++ b/scanpipe/pipes/__init__.py @@ -302,19 +302,6 @@ def get_bin_executable(filename): return str(Path(sys.executable).parent / filename) -def remove_prefix(text, prefix): - """ - Remove the `prefix` from `text`. - Note that build-in `removeprefix` was added in Python3.9 but we need to keep - this one for Python3.8 support. - https://docs.python.org/3.9/library/stdtypes.html#str.removeprefix - """ - if text.startswith(prefix): - prefix_len = len(prefix) - return text[prefix_len:] - return text - - class LoopProgress: """ A context manager for logging progress in loops. diff --git a/scanpipe/pipes/d2d.py b/scanpipe/pipes/d2d.py index aad1c6daa..aebfd1c11 100644 --- a/scanpipe/pipes/d2d.py +++ b/scanpipe/pipes/d2d.py @@ -1402,7 +1402,8 @@ def flag_whitespace_files(project): whitespace_set = set(b" \n\r\t\f\b") for resource in resources: - binary_data = open(resource.location, "rb").read() + with open(resource.location, "rb") as f: + binary_data = f.read() binary_set = set(binary_data) non_whitespace_bytes = binary_set - whitespace_set diff --git a/scanpipe/pipes/resolve.py b/scanpipe/pipes/resolve.py index 519757377..25b343d9b 100644 --- a/scanpipe/pipes/resolve.py +++ b/scanpipe/pipes/resolve.py @@ -30,7 +30,7 @@ from packagedcode import APPLICATION_PACKAGE_DATAFILE_HANDLERS from packagedcode.licensing import get_license_detections_and_expression from packageurl import PackageURL -from python_inspector.resolve_cli import resolver_api +from python_inspector.api import resolve_dependencies from scancode.api import get_package_data from scanpipe.models import DiscoveredPackage @@ -64,7 +64,7 @@ def resolve_pypi_packages(input_location): python_version = f"{sys.version_info.major}{sys.version_info.minor}" operating_system = "linux" - inspector_output = resolver_api( + inspector_output = resolve_dependencies( requirement_files=[input_location], python_version=python_version, operating_system=operating_system, diff --git a/scanpipe/templates/scanpipe/base.html b/scanpipe/templates/scanpipe/base.html index 26614aac3..0ed429d92 100644 --- a/scanpipe/templates/scanpipe/base.html +++ b/scanpipe/templates/scanpipe/base.html @@ -39,6 +39,7 @@ .is-black-link {color: #363636;} .is-grey-link {color: #7a7a7a;} .is-black-link:hover, .is-grey-link:hover {color: #3273dc; text-decoration: underline;} + .navbar button.navbar-item {font-size: 1em;} #inputs-panel .panel-block.dropdown:hover {background-color: #f5f5f5;} #inputs-panel .dropdown-menu {width: 85%;} a.panel-block {word-break: break-all;} diff --git a/scanpipe/templates/scanpipe/includes/navbar_header.html b/scanpipe/templates/scanpipe/includes/navbar_header.html index 37315f80d..39d4d14a5 100644 --- a/scanpipe/templates/scanpipe/includes/navbar_header.html +++ b/scanpipe/templates/scanpipe/includes/navbar_header.html @@ -27,9 +27,12 @@ Profile settings - - Sign out - +
+ {% csrf_token %} + +