tools icon indicating copy to clipboard operation
tools copied to clipboard

Lint linter config for Python < 3.6 and issue warning if Actions are using Python 3.6 and older

Open apeltzer opened this issue 3 years ago • 4 comments

Description of the bug

Run nf-core -l lint_log.txt lint --dir ${GITHUB_WORKSPACE} --markdown lint_results.md
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.6.15/x64/bin/nf-core", line 5, in <module>
    from nf_core.__main__ import run_nf_core
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/nf_core/__main__.py", line 19, in <module>
    import nf_core.lint
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/nf_core/lint/__init__.py", line 23, in <module>
    import nf_core.modules.lint
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/nf_core/modules/__init__.py", line 1, in <module>
    from .bump_versions import ModuleVersionBumper
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/nf_core/modules/bump_versions.py", line 24, in <module>
    from .modules_command import ModuleCommand
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/nf_core/modules/modules_command.py", line [11](https://github.com/nf-core/scrnaseq/actions/runs/3188310073/jobs/5200822519#step:6:12), in <module>
    from .modules_json import ModulesJson
  File "/opt/hostedtoolcache/Python/3.6.[15](https://github.com/nf-core/scrnaseq/actions/runs/3188310073/jobs/5200822519#step:6:16)/x64/lib/python3.6/site-packages/nf_core/modules/modules_json.py", line 15, in <module>
    import nf_core.modules.modules_repo
  File "/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/nf_core/modules/modules_repo.py", line 5, in <module>
    from importlib.resources import path
ModuleNotFoundError: No module named 'importlib.resources'
Error: Process completed with exit code 1.

Command used and terminal output

https://github.com/nf-core/scrnaseq/actions/runs/3188310073/jobs/5200822519

System information

GHA

apeltzer avatar Oct 05 '22 08:10 apeltzer

On Python 3.6, importlib.resources is not part of the standard library. 3.6 reached end of life a long time ago 😱

Midnighter avatar Oct 05 '22 08:10 Midnighter

Basically, to solve this you would need to add

importlib_resources; python_version <'3.7'

and then create imports like

try:
    from importlib.resources import ...
except ImportError:
    from importlib_resources import ...

Or decide to not support 3.6 😛

Midnighter avatar Oct 05 '22 08:10 Midnighter

We already dropped support for 3.6 elsewhere, so just drop it here I think. Should be sufficient to remove it from the CI actions matrix.

ewels avatar Oct 05 '22 09:10 ewels

I changed the title accordingly...

image

apeltzer avatar Oct 05 '22 11:10 apeltzer

I've been checking, we dropped 3.6 everywhere, and we also don't use importlib.resources anymore. I am closing the issue :)

mirpedrol avatar Nov 30 '22 10:11 mirpedrol

Yeah, looks like it is there in master: https://github.com/nf-core/tools/blob/dec66abe1c36a8975a952e1f80f045cab65bbf72/nf_core/modules/modules_repo.py#L5

But it's been removed in dev.

However, I think that we should either:

  1. Support Python 3.6 and add it back to the CI tests
  2. Prevent people from installing with Python 3.6 by adding a restriction in setup.py

ewels avatar Nov 30 '22 10:11 ewels

When we removed support for 3.6 we started using features specific for 3.7 (Actually, the features were used and then the support for Python 3.6 was dropped because we wanted to use these features. Besides, Python3.6 is officially deprecated.) - I'd advise against trying to support Python 3.6 again.

fabianegli avatar Nov 30 '22 11:11 fabianegli

Clear vote for 2.

Midnighter avatar Nov 30 '22 11:11 Midnighter

Done.

fabianegli avatar Nov 30 '22 11:11 fabianegli