pre-commit: Getting ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found even if setup.py file available
I tried to run my unit testcases through pre-commit (pre-push stage). But I’m not able to install local directory in virtualenv. Getting an error like “Directory ‘.’ is not installable. Neither ‘setup.py’ nor ‘pyproject.toml’ found” even if setup.py file available.
Here is my .pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.6
stages: [commit]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8
stages: [commit]
- repo: local
hooks:
- id: unittests
name: unittests
entry: python -m tests.initiate
language: python
language_version: python3.6
additional_dependencies: ['--trusted-host' ,'pypi.org' ,'--trusted-host' ,'files.pythonhosted.org']
stages: [commit]
And finally, here’s the error I’m getting from pre-commit:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks commit -q -F C:\Users\xxxxx\AppData\Local\Temp\1t5bmasv.vpz
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('C:\\Users\\xxxxx\\.cache\\pre-commit\\reposrc_pe7u\\py_env-python3.6\\Scripts\\pip.exe', 'install', '.', '--trusted-host', 'pypi.org', '--trusted-host', 'files.pythonhosted.org')
Return code: 1
Expected return code: 0
Output: (none)
Errors:
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Check the log at C:\Users\xxxxx/.cache\pre-commit\pre-commit.log
I have debugged the pre-commit code and changed pre_commit/languages/python.py#L171 for verification.
prefix, ('pip', 'install', Path.cwd())+ additional_dependencies
After this change, again I ran pre-push then the code in local directory installed in C:\Users\xxxxx\.cache\pre-commit\reposrc_pe7u\py_env-python3.6\lib\python3.6\site-packages
Can anyone please guide me on this. Please provide a solution
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (10 by maintainers)
probably because setup.* was unstaged (and never checked in)