Skip to content

Make git-version-info.py compatiable with worktree#214

Merged
Luthaf merged 1 commit intomainfrom
git-script
May 1, 2026
Merged

Make git-version-info.py compatiable with worktree#214
Luthaf merged 1 commit intomainfrom
git-script

Conversation

@GardevoirX
Copy link
Copy Markdown
Contributor

@GardevoirX GardevoirX commented Apr 30, 2026

When working with git worktree and running tox tests, one would encounter with the following error. This PR aims at passing a correct directory for running git update-index -q --really-refresh

(tox) qxu@cosmopc3:~/repos/metatomic-heat-flux$ tox -e torch-tests
torch-tests: commands[0] /home/qxu/repos/metatomic-heat-flux/python/metatomic_torch> pip install --no-deps --no-build-isolation --check-build-dependencies .
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu
Processing ./.
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [50 lines of output]
      Traceback (most recent call last):
        File "/home/qxu/repos/metatomic-heat-flux/.tox/torch-tests/lib/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
          ~~~~^^
        File "/home/qxu/repos/metatomic-heat-flux/.tox/torch-tests/lib/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/qxu/repos/metatomic-heat-flux/.tox/torch-tests/lib/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 175, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/home/qxu/repos/metatomic-heat-flux/.tox/torch-tests/lib/python3.14/site-packages/setuptools/build_meta.py", line 380, in prepare_metadata_for_build_wheel
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/home/qxu/repos/metatomic-heat-flux/.tox/torch-tests/lib/python3.14/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 336, in <module>
        File "<string>", line 220, in create_version_number
        File "<string>", line 200, in git_version_info
      Exception: failed to get git version info.
      stdout: 44

      stderr: Traceback (most recent call last):
        File "/home/qxu/repos/metatomic-heat-flux/python/metatomic_torch/../../scripts/git-version-info.py", line 201, in <module>
          print(git_hash_all_code())
                ~~~~~~~~~~~~~~~~~^^
        File "/home/qxu/repos/metatomic-heat-flux/python/metatomic_torch/../../scripts/git-version-info.py", line 138, in git_hash_all_code
          update_git_index()
          ~~~~~~~~~~~~~~~~^^
        File "/home/qxu/repos/metatomic-heat-flux/python/metatomic_torch/../../scripts/git-version-info.py", line 109, in update_git_index
          run_subprocess(
          ~~~~~~~~~~~~~~^
              ["git", "update-index", "-q", "--really-refresh"],
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              env=env,
              ^^^^^^^^
              cwd=gitdir.parent.absolute(),
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/home/qxu/repos/metatomic-heat-flux/python/metatomic_torch/../../scripts/git-version-info.py", line 37, in run_subprocess
          raise Exception(
          ...<3 lines>...
          )
      Exception: failed to run 'git update-index -q --really-refresh' (exit code 128)
      stdout:
      stderr: fatal: this operation must be run in a work tree




      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> from file:///home/qxu/repos/metatomic-heat-flux/python/metatomic_torch

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
torch-tests: exit 1 (1.43 seconds) /home/qxu/repos/metatomic-heat-flux/python/metatomic_torch> pip install --no-deps --no-build-isolation --check-build-dependencies . pid=3652321
  torch-tests: FAIL code 1 (1.46=setup[0.03]+cmd[1.43] seconds)
  evaluation failed :( (1.49 seconds)
(tox) qxu@cosmopc3:~/repos/metatomic-heat-flux$

Contributor (creator of pull-request) checklist

  • Tests updated (for new features and bugfixes)?
  • Documentation updated (for new features)?
  • Issue referenced (for PRs that solve an issue)?

Reviewer checklist

  • CHANGELOG updated with public API or any other important changes?

📚 Download documentation for this pull-request

@GardevoirX GardevoirX requested a review from Luthaf April 30, 2026 14:09
Comment thread scripts/git-version-info.py
@Luthaf Luthaf merged commit 1733271 into main May 1, 2026
10 of 11 checks passed
@Luthaf Luthaf deleted the git-script branch May 1, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants