I am trying to send a Pull Request to an opensource library.
But I keep getting ModuleNotFoundError: No module named 'coverage'
This is the log in Github CI
Run tox -e lint,py310-dj40
lint: freeze> python -m pip freeze --all
lint: pip==23.0.1,setuptools==67.4.0,wheel==0.38.4
lint: commands[0]> poetry install --no-root -v
Using virtualenv: /home/runner/work/django-pattern-library/django-pattern-library/.tox/lint
Updating dependencies
Resolving dependencies...
Writing lock file
Finding the necessary packages for the current system
Package operations: 39 installs, 0 updates, 0 removals
• Installing six (1.16.0)
• Installing markupsafe (2.1.2)
• Installing python-dateutil (2.8.2)
• Installing pyyaml (6.0)
• Installing smmap (5.0.0)
• Installing click (8.1.3)
• Installing ghp-import (2.1.0)
• Installing jinja2 (3.1.2)
• Installing gitdb (4.0.10)
• Installing markdown (3.3.7)
• Installing mergedeep (1.3.4)
• Installing packaging (23.0)
• Installing pyyaml-env-tag (0.1)
• Installing watchdog (3.0.0)
• Installing asgiref (3.6.0)
• Installing gitpython (3.1.31)
• Installing mccabe (0.6.1)
• Installing mypy-extensions (1.0.0)
• Installing mkdocs (1.4.2)
• Installing mkdocs-material-extensions (1.1.1)
• Installing pathspec (0.11.1)
• Installing platformdirs (3.2.0)
• Installing pycodestyle (2.7.0)
• Installing pyflakes (2.3.1)
• Installing pygments (2.14.0)
• Installing pymdown-extensions (8.2)
• Installing pytz (2023.3)
• Installing soupsieve (2.4)
• Installing sqlparse (0.4.3)
• Installing tomli (2.0.1)
• Installing beautifulsoup4 (4.12.0)
• Installing black (22.12.0)
• Installing coverage (6.5.0)
• Installing django (3.2.18)
• Installing flake8 (3.9.2)
• Installing isort (5.11.5)
• Installing mkdocs-git-revision-date-plugin (0.3.2)
• Installing mkdocs-material (5.5.14)
• Installing mkdocs-redirects (1.2.0)
lint: commands[1]> poetry run flake8
lint: commands[2]> poetry run isort --check --diff .
Skipped 2 files
lint: commands[3]> poetry run black --check --diff .
All done! ✨ ✨
34 files would be left unchanged.
lint: OK ✔ in 1 minute 2.2 seconds
py310-dj40: install_deps> python -I -m pip install 'Django<4.1,>=4.0'
py310-dj40: freeze> python -m pip freeze --all
py310-dj40: asgiref==3.6.0,Django==4.0.10,pip==23.0.1,setuptools==67.4.0,sqlparse==0.4.3,wheel==0.38.4
py310-dj40: commands[0]> poetry run python -X dev -W error runtests.py
Traceback (most recent call last):
File "/home/runner/work/django-pattern-library/django-pattern-library/runtests.py", line 10, in <module>
import coverage
ModuleNotFoundError: No module named 'coverage'
py310-dj40: exit 1 (1.10 seconds) /home/runner/work/django-pattern-library/django-pattern-library> poetry run python -X dev -W error runtests.py pid=2239
lint: OK (62.20=setup[1.42]+cmd[57.42,1.26,0.86,1.25] seconds)
py310-dj40: FAIL code 1 (5.90=setup[4.80]+cmd[1.10] seconds)
evaluation failed :( (68.80 seconds)
I repeated the log here as it will be removed over time.
What I have tried:
- add
coverage
inenvlist
see https://github.com/torchbox/django-pattern-library/pull/213/commits/1d91a71eb13c7e3463524ed512352640f7008cba - switch to
poetry install --no-root -v
see https://github.com/torchbox/django-pattern-library/pull/213/commits/2ee1b0c31a1e7f1154e127eeacf741e73a80f12a - install coverage as part of tool.poetry.dependencies in pyproject.toml see https://github.com/torchbox/django-pattern-library/pull/213/commits/eb0c83eaafc43d7aaed9d6b9bcd3cfd6acc56e91
- switch to isolated_build=True in tox.ini https://github.com/torchbox/django-pattern-library/pull/213/commits/d3fc32ea5398219c05278fe46dacdbc26b1b905f
- add coverage to
deps
in tox.ini and this error is overcome see https://github.com/torchbox/django-pattern-library/pull/213/commits/332524c63c6ee94d7a009d5a90aed957c7d264b1 => which begs the question. Given that in pyproject.toml I already stated coverage and other test related dependencies, why wasn't this installed? - i added
poetry install -q
in the testenv's commands see https://github.com/torchbox/django-pattern-library/pull/213/commits/18608a1138b1005e0450e25f61b5532f826e08ec this solution appears the same as ensuring tool.poetry.dev-dependencies are all installed, but now i get a failed test at py311-dj41 which I have traced to a python deprecation warning about 3.13. And it appears that Django 4.1 wasn't actuallt installed in the env py311-dj41 see https://github.com/torchbox/django-pattern-library/actions/runs/4587113230/jobs/8100417144?pr=213
File "/home/runner/work/django-pattern-library/django-pattern-library/.tox/py311-dj41/lib/python3.11/site-packages/django/http/__init__.py", line 2, in <module>
from django.http.request import (
File "/home/runner/work/django-pattern-library/django-pattern-library/.tox/py311-dj41/lib/python3.11/site-packages/django/http/request.py", line 1, in <module>
import cgi
File "/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/cgi.py", line 57, in <module>
warnings._deprecated(__name__, remove=(3,13))
File "/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/warnings.py", line 514, in _deprecated
warn(msg, DeprecationWarning, stacklevel=3)
DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
py311-dj41: exit 1 (0.81 seconds) /home/runner/work/django-pattern-library/django-pa
None of them work. What should i do?