diff options
-rw-r--r-- | .github/workflows/release-tests.yml | 33 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | astroid/interpreter/_import/spec.py | 17 | ||||
-rw-r--r-- | doc/release.md | 2 |
4 files changed, 56 insertions, 0 deletions
diff --git a/.github/workflows/release-tests.yml b/.github/workflows/release-tests.yml new file mode 100644 index 00000000..dc228ac7 --- /dev/null +++ b/.github/workflows/release-tests.yml @@ -0,0 +1,33 @@ +name: Release tests + +on: workflow_dispatch + +env: + DEFAULT_PYTHON: 3.8 + +jobs: + virtualenv-15-windows-test: + # Regression test added in https://github.com/PyCQA/astroid/pull/1386 + name: Regression test for virtualenv==15.1.0 on Windows + runs-on: windows-latest + timeout-minutes: 5 + steps: + - name: Check out code from GitHub + uses: actions/checkout@v2.3.4 + - name: Set up Python + id: python + uses: actions/setup-python@v2.2.1 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Create Python virtual environment with virtualenv==15.1.0 + run: | + python -m pip install virtualenv==15.1.0 + python -m virtualenv venv2 + . venv2\scripts\activate + python -m pip install pylint + python -m pip install -e . + - name: Test no import-error from distutils.util + run: | + . venv2\scripts\activate + echo "import distutils.util # pylint: disable=unused-import" > test.py + pylint test.py @@ -110,6 +110,10 @@ Release date: 2021-12-31 Ref #1321 +* Restore custom ``distutils`` handling for resolving paths to submodules. + + Closes PyCQA/pylint#5645 + * Fix ``deque.insert()`` signature in ``collections`` brain. Closes #1260 diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py index 57bab9f4..53228bd8 100644 --- a/astroid/interpreter/_import/spec.py +++ b/astroid/interpreter/_import/spec.py @@ -19,10 +19,12 @@ import abc import collections import enum import importlib.machinery +import importlib.util import os import sys import zipimport from functools import lru_cache +from pathlib import Path from . import util @@ -160,6 +162,21 @@ class ImportlibFinder(Finder): for p in sys.path if os.path.isdir(os.path.join(p, *processed)) ] + elif spec.name == "distutils": + # virtualenv below 20.0 patches distutils in an unexpected way + # so we just find the location of distutils that will be + # imported to avoid spurious import-error messages + # https://github.com/PyCQA/pylint/issues/5645 + # A regression test to create this scenario exists in release-tests.yml + # and can be triggered manually from GitHub Actions + distutils_spec = importlib.util.find_spec("distutils") + if distutils_spec and distutils_spec.origin: + origin_path = Path( + distutils_spec.origin + ) # e.g. .../distutils/__init__.py + path = [str(origin_path.parent)] # e.g. .../distutils + else: + path = [spec.location] else: path = [spec.location] return path diff --git a/doc/release.md b/doc/release.md index 96855ef3..1646e42f 100644 --- a/doc/release.md +++ b/doc/release.md @@ -4,6 +4,8 @@ So, you want to release the `X.Y.Z` version of astroid ? ## Process +(Consider triggering the "release tests" workflow in GitHub Actions first.) + 1. Check if the dependencies of the package are correct 2. Check the result (Do `git diff vX.Y.Z-1 ChangeLog` in particular). 3. Install the release dependencies `pip3 install pre-commit tbump` |