pip-tools icon indicating copy to clipboard operation
pip-tools copied to clipboard

pre-commit is in another folder than the project

Open MartinThoma opened this issue 3 years ago • 3 comments

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

  1. OS Type: Ubuntu 20.04
  2. Python version: Python 3.8.3
  3. pip version: pip 20.2.2 from /home/moose/.pyenv/versions/3.8.3/lib/python3.8/site-packages/pip (python 3.8)
  4. 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 :-/

MartinThoma avatar Sep 02 '20 07:09 MartinThoma

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]

atugushev avatar Sep 02 '20 07:09 atugushev

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 avatar Sep 02 '20 07:09 MartinThoma

@MartinThoma

Can you share a setup.py to reproduce this with?

AndydeCleyre avatar Aug 13 '21 06:08 AndydeCleyre