Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit is in another folder than the project #1207

Open
MartinThoma opened this issue Sep 2, 2020 · 3 comments
Open

pre-commit is in another folder than the project #1207

MartinThoma opened this issue Sep 2, 2020 · 3 comments
Labels
pre-commit Related to pre-commit hook

Comments

@MartinThoma
Copy link

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 :-/

@atugushev
Copy link
Member

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]

@MartinThoma
Copy link
Author

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

@atugushev atugushev added the pre-commit Related to pre-commit hook label Jan 5, 2021
@AndydeCleyre
Copy link
Contributor

@MartinThoma

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pre-commit Related to pre-commit hook
Projects
None yet
Development

No branches or pull requests

3 participants