pip-tools
pip-tools copied to clipboard
pre-commit is in another folder than the project
I receive a FileNotFoundError: [Errno 2] No such file or directory: 'myproject/_version.py'
, because I have this structure:
git root
├── .pre-commit-config.yaml
├── README.md
└── web
├── myproject
│ ├── app.py
│ ├── __init__.py
│ ├── _version.py
│ └── wsgi.py
├── setup.py
├── tests
└── tox.ini
Environment Versions
- OS Type: Ubuntu 20.04
- Python version: Python 3.8.3
- pip version: pip 20.2.2 from /home/moose/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pip (python 3.8)
- pip-tools version: pip-compile, version 5.2.1
Steps to replicate
Having the above folder structure and this .pre-commit-config.yaml:
repos:
- repo: https://github.com/jazzband/pip-tools
rev: 5.0.0
hooks:
- id: pip-compile
files: ^web/setup\.py$
Expected result
A requirements.txt
within the web
directory
Actual result
Weird ... now I get:
pip-compile..............................................................Failed
- hook id: pip-compile
- exit code: 2
Usage: pip-compile [OPTIONS] [SRC_FILES]...
Error: Invalid value: If you do not specify an input file, the default is requirements.in or setup.py
I'm not sure what changed. Anyway, it is not working :-/
Hello @MartinThoma,
This should work:
repos:
- repo: https://github.com/jazzband/pip-tools
rev: 5.0.0
hooks:
- id: pip-compile
files: ^web/setup\.py$
args: [web/setup.py]
With "args", I get the FileNotFoundError again.
Please note that I get this error also with
pip-compile web/setup.py
but this works:
cd web
pip-compile setup.py
@MartinThoma
Can you share a setup.py
to reproduce this with?