python-poetry / python-poetry/poetry

Poetry mangles `GIT_TRACE` information on `'python', '-mpip', 'install', '.'` installation via pre-commit

Open
#7,555 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • Poetry version:
  • Python version:
  • OS version and name:
  • pyproject.toml:
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Using pre-commit to install isort (5.12.0), while also having set:

  GIT_TRACE: 2
  GIT_TRACE_PACKET: 1
  GIT_CURL_VERBOSE: 1

leads to:

[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/other_root/.cache/pre-commit/repo6q5zpyem/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /other_root/.cache/pre-commit/repo6q5zpyem
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    Building wheels for collected packages: isort
      Building wheel for isort (pyproject.toml): started
      Building wheel for isort (pyproject.toml): finished with status 'error'
    Failed to build isort
stderr:
      error: subprocess-exited-with-error
      
      × Building wheel for isort (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [30 lines of output]
          Traceback (most recent call last):
            File "/other_root/.cache/pre-commit/repo6q5zpyem/py_env-python3/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/other_root/.cache/pre-commit/repo6q5zpyem/py_env-python3/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/other_root/.cache/pre-commit/repo6q5zpyem/py_env-python3/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
              return _build_backend().build_wheel(wheel_directory, config_settings,
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/api.py", line 56, in build_wheel
              return WheelBuilder.make_in(
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 85, in make_in
              wb.build(target_dir=directory)
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 121, in build
              self._copy_module(zip_file)
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 232, in _copy_module
              to_add = self.find_files_to_add()
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/builder.py", line 198, in find_files_to_add
              if self.is_excluded(
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/builder.py", line 144, in is_excluded
              if exclude_path.as_posix() in self.find_excluded_files(fmt=self.format):
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/builder.py", line 112, in find_excluded_files
              vcs_ignored_files = set(vcs.get_ignored_files())
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/vcs/git.py", line 340, in get_ignored_files
              output = self.run(*args)
            File "/tmp/pip-build-env-pcn6g6fq/overlay/lib/python3.9/site-packages/poetry/core/vcs/git.py", line 372, in run
              subprocess.check_output(
            File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
              return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
            File "/usr/lib/python3.9/subprocess.py", line 528, in run
              raise CalledProcessError(retcode, process.args,
          subprocess.CalledProcessError: Command '['git', '--git-dir', '16:25:51.242690 git.c:444               trace: built-in: git rev-parse --show-toplevel\n/other_root/.cache/pre-commit/repo6q5zpyem/.git', '--work-tree', '16:25:51.242690 git.c:444               trace: built-in: git rev-parse --show-toplevel\n/other_root/.cache/pre-commit/repo6q5zpyem', 'ls-files', '--others', '-i', '--exclude-standard']' returned non-zero exit status 128.
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for isort
    ERROR: Could not build wheels for isort, which is required to install pyproject.toml-based projects
Check the log at /other_root/.cache/pre-commit/pre-commit.log
Error occurred ($?:3):

(Sounds like pip's https://github.com/pypa/pip/issues/7545 et al.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in poetry/core/vcs/git.py, especially get_ignored_files() and run(), using the traceback as the entry point. Reproduce the pre-commit installation with GIT_TRACE, GIT_TRACE_PACKET, and GIT_CURL_VERBOSE enabled. Done means Git trace output is not inserted into the git path arguments and the installation completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.