Only install relevant virtual env when specific hook is invoked
See original GitHub issuesearch tried in the issue tracker
unnecessary, install, virtual, virtual-env
describe your issue
I am working with a python monorepo. Inside this monorepo, there are N hooks for N packages. When I invoke one hook, like so:
pre-commit run <hook_id> --all
I expected pre-commit
to only build the virtual env for that hook and run it.
However, from the logs I see it also builds the env for other hooks.
This makes running pre-commit very slow in CI in a monorepo.
Is there a way to deal with this?
pre-commit --version
pre-commit 2.19.0
.pre-commit-config.yaml
repos:
- hooks:
- additional_dependencies:
- regex==2021.9.30
- click==8.0.3
args:
- --line-length=120
id: black
language_version: python3
repo: https://github.com/psf/black
rev: 22.3.0
- hooks:
- args:
- --line-length=120
- --profile=black
id: isort
repo: https://github.com/PyCQA/isort
rev: 5.10.1
- hooks:
- additional_dependencies:
- flake8-bugbear
- flake8-mutable
args:
- --ignore=E501,W503
id: flake8
- id: end-of-file-fixer
- id: trailing-whitespace
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
- hooks:
- additional_dependencies:
- pyspark-stubs==2.4.0.post10
- types-PyYAML==5.4.10
args:
- --ignore-missing-imports
files: ^lib/foo
id: mypy
name: mypy lib foo
- additional_dependencies:
- pyspark-stubs==2.4.0.post10
- types-requests==2.25.6
args:
- --ignore-missing-imports
files: ^lib/bar
id: mypy
name: mypy lib bar
- additional_dependencies:
- pyspark-stubs==2.4.0.post10
args:
- --ignore-missing-imports
files: ^lib/baz
id: mypy
name: mypy lib baz
repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
~/.cache/pre-commit/pre-commit.log (if present)
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Activate virtualenv in hook template · Issue #1522 · pre-commit ...
Currently, if pre-commit is installed in a virtualenv, git hooks invoke pre-commit without activating the virtualenv.
Read more >venv — Creation of virtual environments — Python 3.11.1 ...
A virtual environment is created on top of an existing Python installation, known as the virtual environment's “base” Python, and may optionally be...
Read more >Getting a python virtual env error after installing Lion
hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly. Any tips on how to fix this?
Read more >A Guide to Python's Virtual Environments |
In this guide we'll cover the basics of virtual environments and how to use them. Then we'll peek under the hood and take...
Read more >Python Tools for Managing Virtual Environments
This article describes and demonstrates a few. How to use this guide; venv. Activate the virtual environment; Execute Python scripts ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the only builds that occurred were mypy environments
Ok, clear. I was just wondering if that building of the other env can be disabled. Thanks for the clarification.