Comments (8)
Hi @keiranmraine, thank you very much for reporting this.
Let me see if I understood the problem correctly. Is it the case that you:
- Were trying to add the pre-commit hook in one of your own projects (that is not setuptools)
- Saw this error when you were running
pre-commit run
(or after agit commit
)
?
By any chance is the project that you are working with public/opensource so I also can have a look?
from validate-pyproject.
I am trying the following:
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
mkdir testpkg
cd testpkg
mkdir -p src/testpkg
touch src/testpkg/__init__.py
@"
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "setuptools_scm[toml]"]
[project]
name = "myproj"
dynamic = ["version"]
[tool.setuptools_scm]
"@ | out-file pyproject.toml -encoding utf8
@"
---
repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.9
hooks:
- id: validate-pyproject
"@ | out-file .pre-commit-config.yaml -encoding utf8
@"
.venv
*~
*.py[cod]
*.egg-info
__pycache__/*
"@ | out-file .gitignore -encoding utf8
git init .
git add .
python3.10 -m virtualenv .venv
.venv/Scripts/python -m pip install pre-commit
.venv/Scripts/pre-commit install
.venv/Scripts/pre-commit run --all-files
The output was:
Validate pyproject.toml..................................................Passed
(If you are trying to replicate the experiment you might have to create the files in a graphic editor instead of using out-file
, I had a hard time trying to make the UTF-8 encoding right...)
.venv/Scripts/python -V
Python 3.10.5
from validate-pyproject.
The build I'm doing is very trivial, but I worry it's a Windows issue as the problem has reoccurred.
System:
- Windows 10
- Python 3.10.5
- pre-commit installed system-wide
- so can be reused for all repos and not pollute freeze for projects
- I've repeated with a venv , same issue occurs
Project setup:
mkdir test
cd test
touch README.md
.pre-commit-config.yaml
:
repos:
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.14
hooks:
- id: mdformat
# in test
git init
pre-commit run --all
Output:
[INFO] Initializing environment for https://github.com/executablebooks/mdformat.
[INFO] Installing environment for https://github.com/executablebooks/mdformat.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\XXXX\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-mvirtualenv', 'C:\\Users\\XXXX\\.cache\\pre-commit\\repoy5fmp1t6\\py_env-python3')
return code: 1
expected return code: 0
stdout:
RuntimeError: failed to build image setuptools because:
Traceback (most recent call last):
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 57, in _install
installer.install(creator.interpreter.version_info)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 39, in install
self._sync(filename, into)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\pip_install\copy.py", line 13, in _sync
copy(src, dst)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\util\path\_sync.py", line 52, in copy
method(norm(src), norm(dest))
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\util\path\_sync.py", line 63, in copytree shutil.copy(src_f, dest_f)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 417, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 254, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\XXXX\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\pypa\\virtualenv\\wheel\\3.10\\image\\1\\CopyPipInstall\\setuptools-62.2.0-py3-none-any\\setuptools\\config\\_validate_pyproject\\extra_validations.py'
stderr: (none)
Check the log at C:\Users\XXXX\.cache\pre-commit\pre-commit.log
C:\Users\XXXX\.cache\pre-commit\pre-commit.log
:
version information
pre-commit version: 2.19.0
git --version: git version 2.35.1.windows.2
sys.version:
3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]
sys.executable: C:\Users\XXXX\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe
os.name: nt
sys.platform: win32
error information
An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\XXXX\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-mvirtualenv', 'C:\\Users\\XXXX\\.cache\\pre-commit\\repoy5fmp1t6\\py_env-python3')
return code: 1
expected return code: 0
stdout:
RuntimeError: failed to build image setuptools because:
Traceback (most recent call last):
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 57, in _install
installer.install(creator.interpreter.version_info)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 39, in install
self._sync(filename, into)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\pip_install\copy.py", line 13, in _sync
copy(src, dst)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\util\path\_sync.py", line 52, in copy
method(norm(src), norm(dest))
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\util\path\_sync.py", line 63, in copytree
shutil.copy(src_f, dest_f)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 417, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 254, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\XXXX\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\pypa\\virtualenv\\wheel\\3.10\\image\\1\\CopyPipInstall\\setuptools-62.2.0-py3-none-any\\setuptools\\config\\_validate_pyproject\\extra_validations.py'
stderr: (none)
Traceback (most recent call last):
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\error_handler.py", line 73, in error_handler
yield
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\main.py", line 389, in main
return run(args.config, store, args)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\commands\run.py", line 414, in run
install_hook_envs(to_install, store)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\repository.py", line 223, in install_hook_envs
_hook_install(hook)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\repository.py", line 79, in _hook_install
lang.install_environment(
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\languages\python.py", line 219, in install_environment
cmd_output_b(*venv_cmd, cwd='/')
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pre_commit\util.py", line 146, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Users\\XXXX\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-mvirtualenv', 'C:\\Users\\XXXX\\.cache\\pre-commit\\repoy5fmp1t6\\py_env-python3')
return code: 1
expected return code: 0
stdout:
RuntimeError: failed to build image setuptools because:
Traceback (most recent call last):
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 57, in _install
installer.install(creator.interpreter.version_info)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 39, in install
self._sync(filename, into)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\seed\embed\via_app_data\pip_install\copy.py", line 13, in _sync
copy(src, dst)
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\util\path\_sync.py", line 52, in copy
method(norm(src), norm(dest))
File "C:\Users\XXXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\virtualenv\util\path\_sync.py", line 63, in copytree
shutil.copy(src_f, dest_f)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 417, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 254, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\XXXX\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\pypa\\virtualenv\\wheel\\3.10\\image\\1\\CopyPipInstall\\setuptools-62.2.0-py3-none-any\\setuptools\\config\\_validate_pyproject\\extra_validations.py'
stderr: (none)
END OF C:\Users\XXXX.cache\pre-commit\pre-commit.log
from validate-pyproject.
Interesting:
[test]$ python3.10 -m venv .venv
[test]$ echo $?
0
$ python3.10 -m virtualenv .venv
RuntimeError: failed to build image setuptools because:
Traceback (most recent call last):
...
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\XXXX\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\pypa\\virtualenv\\wheel\\3.10\\image\\1\\CopyPipInstall\\setuptools-62.2.0-py3-none-any\\setuptools\\config\\_validate_pyproject\\extra_validations.py'
from validate-pyproject.
Hi @keiranmraine, I am still not able to reproduce this in my test machine (also Windows 10). Maybe this is something specific to your machine/Python installation? Maybe something got corrupted?
I tried again with the workflow you proposed:
- Prepare the environment
python3.10 -V # => Python 3.10.5
python3.10 -m pip install pre-commit # Global installation
mkdir test
cd test
touch README.md
-
Add the
.pre-commit-config.yaml
as described in
#46 (comment) -
Run pre-commit
git init
python3.10 -m pre_commit run --all
# Here I run `python3.10 -m` because I don't have my PATH configured properly
This is the output
> python3.10 -m pre_commit run --all
[INFO] Initializing environment for https://github.com/executablebooks/mdformat.
[INFO] Installing environment for https://github.com/executablebooks/mdformat.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
mdformat.............................................(no files to check)Skipped
If I do the extra step:
git add .
git commit -m "Add files"
python3.10 -m pre_commit run --all
I can see pre-commit running successfully:
> python3.10 -m pre_commit run --all
mdformat.................................................................Passed
After doing that I also tried running:
python3.10 -m pip uninstall pre-commit
rm -R -force '~/.cache/pre-commit'
python3.10 -m pip install -U pip setuptools # the error message mentions setuptools
python3.10 -m pip install pre-commit
and then repeating the procedure again, but it still passes:
> python3.10 -m pre_commit run --all
mdformat.................................................................Passed
As a last attempt, I tried to configure the path properly and try running the pre-commit
executable directly:
> $env:Path += ";$env:LOCALAPPDATA\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts"
> pre-commit run --all
mdformat.................................................................Passed
In all the attempts pre-commit seems to be running fine.
from validate-pyproject.
Do you mind telling me the version of virtualenv you have on your base system? I normally use -m venv
for my environment and as indicated just creating a venv with -m virtualenv
is failing for me:
Interesting:
[test]$ python3.10 -m venv .venv [test]$ echo $? 0
$ python3.10 -m virtualenv .venv RuntimeError: failed to build image setuptools because: Traceback (most recent call last): ... FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\XXXX\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\pypa\\virtualenv\\wheel\\3.10\\image\\1\\CopyPipInstall\\setuptools-62.2.0-py3-none-any\\setuptools\\config\\_validate_pyproject\\extra_validations.py'
from validate-pyproject.
Here it goes:
Python 3.10.5
virtualenv 20.14.1
pre-commit 2.19.0
pip 22.1.2 # After the update I did in the previous experiment
setuptools 62.3.3 # After the update I did in the previous experiment
>>> sys.version
'3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]'
>>> pathlib.Path(sys.executable).relative_to(os.getenv("LOCALAPPDATA"))
WindowsPath('Microsoft/WindowsApps/PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0/python.exe')
>>> sys.platform
'win32'
>>> os.name
'nt'
Maybe uninstalling and re-installing virtualenv will help?
from validate-pyproject.
Okay, thanks. I've the same version of everything so I can't be your tool. Thanks for having a look.
from validate-pyproject.
Related Issues (20)
- Support for SchemaStore HOT 21
- JSON Schema string is inconsistent (no trailing #) HOT 3
- Speed up `--store` support HOT 11
- [FR] Add the ability to load schemas that can be referenced in other schemas HOT 3
- [FR] Relax validation of `py-modules`
- schema-store: Failing on valid hatch toml HOT 5
- [FR] Allow `--tool` to overwrite? OR option to disable all plugins loaded by entry-points?
- Bug? `tool.poetry.packages[0]` must not contain {'to'} properties HOT 4
- feature request: strict pep440 check
- Request: traversing into `enum` for failure message
- Comment for formats.py in the wrong place
- tool ruff can't validate lint subsection HOT 1
- Please install `tomli` (TOML parser) HOT 7
- CI failing for `freebsd`
- Report likely mistakes as warnings HOT 3
- vendoring of fastjsonschema HOT 2
- `tool.setuptools.packages` should allow `*-stub` name.
- Validate fields pointing to paths HOT 5
- CLI hangs when no arguments provided HOT 1
- Crash on first commit when adding a pre-commit hook HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validate-pyproject.