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

Add tool.hatch.build.targets.wheel to fix pip install . with Hatchling 1.19 #106

Merged
merged 3 commits into from
Dec 12, 2023

Conversation

hugovk
Copy link
Collaborator

@hugovk hugovk commented Dec 11, 2023

With Hatchling 1.19:

❯ git clone https://github.com/sphinx-contrib/sphinx-lint && cd sphinx-lint
...
❯ pip install -e .
Obtaining file:///private/tmp/sphinx-lint
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [39 lines of output]
      Traceback (most recent call last):
        File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 167, in prepare_metadata_for_build_editable
          hook = backend.prepare_metadata_for_build_editable
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 176, in prepare_metadata_for_build_editable
          whl_basename = build_hook(metadata_directory, config_settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/build.py", line 82, in build_editable
          return os.path.basename(next(builder.build(directory=wheel_directory, versions=['editable'])))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build
          artifact = version_api[version](directory, **build_data)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 423, in build_editable
          return self.build_editable_detection(directory, **build_data)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 434, in build_editable_detection
          for included_file in self.recurse_selected_project_files():
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 180, in recurse_selected_project_files
          if self.config.only_include:
             ^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/config.py", line 774, in only_include
          only_include = only_include_config.get('only-include', self.default_only_include()) or self.packages
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 231, in default_only_include
          self.set_default_file_selection()
        File "/private/var/folders/p6/lf2s1s5d4kb335g2n1td8z8c0000gn/T/pip-build-env-z5yx9mlz/overlay/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 209, in set_default_file_selection
          raise ValueError(message)
      ValueError: At least one file selection option must be defined, see: https://hatch.pypa.io/latest/config/build/
      [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.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

PyPI install still work, but this does affect pre-commit installs, which uses pip install . from a Git clone.

CI build of current main: https://github.com/sphinx-contrib/sphinx-lint/actions/runs/7171471394

This is pypa/hatch#1113, and adding this fixes it:

[tool.hatch.build.targets.wheel]
packages = ["sphinxlint"]

Copy link
Collaborator

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@hugovk hugovk merged commit ce6d7ae into sphinx-contrib:main Dec 12, 2023
21 checks passed
@hugovk hugovk deleted the fix-hatchling branch December 12, 2023 16:14
@hugovk
Copy link
Collaborator Author

hugovk commented Dec 12, 2023

Thanks both! I'll release this right away so we can update pre-commit in various repos.

euri10 added a commit to euri10/litestar that referenced this pull request Dec 13, 2023
cofin pushed a commit to litestar-org/litestar that referenced this pull request Dec 13, 2023
lengau referenced this pull request in canonical/craftcraft Dec 15, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [docs/sphinx-lint](https://togithub.com/sphinx-contrib/sphinx-lint)
([changelog](https://togithub.com/sphinx-contrib/sphinx-lint/releases))
| `==0.8.2` -> `==0.9.1` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/docs%2fsphinx-lint/0.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/docs%2fsphinx-lint/0.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/docs%2fsphinx-lint/0.8.2/0.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/docs%2fsphinx-lint/0.8.2/0.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>sphinx-contrib/sphinx-lint (docs/sphinx-lint)</summary>

###
[`v0.9.1`](https://togithub.com/sphinx-contrib/sphinx-lint/releases/tag/v0.9.1)

[Compare
Source](https://togithub.com/sphinx-contrib/sphinx-lint/compare/v0.9.0...v0.9.1)

#### What's Changed

- Add `tool.hatch.build.targets.wheel` to fix `pip install .` with
Hatchling 1.19 by [@&#8203;hugovk](https://togithub.com/hugovk) in
[https://github.com/sphinx-contrib/sphinx-lint/pull/106](https://togithub.com/sphinx-contrib/sphinx-lint/pull/106)
This fixes `ValueError: Unable to determine which files to ship inside
the wheel using the following heuristics: [...]` when trying to `pip
install .`, including via pre-commit.
- Add tox for easy testing of multiple Python versions by
[@&#8203;hugovk](https://togithub.com/hugovk) in
[https://github.com/sphinx-contrib/sphinx-lint/pull/100](https://togithub.com/sphinx-contrib/sphinx-lint/pull/100)
- Lint on GitHub Actions via pre-commit by
[@&#8203;hugovk](https://togithub.com/hugovk) in
[https://github.com/sphinx-contrib/sphinx-lint/pull/104](https://togithub.com/sphinx-contrib/sphinx-lint/pull/104)

**Full Changelog**:
sphinx-contrib/sphinx-lint@v0.9.0...v0.9.1

###
[`v0.9.0`](https://togithub.com/sphinx-contrib/sphinx-lint/releases/tag/v0.9.0)

[Compare
Source](https://togithub.com/sphinx-contrib/sphinx-lint/compare/v0.8.2...v0.9.0)

#### What's Changed

- Print error messages to stderr by
[@&#8203;rffontenelle](https://togithub.com/rffontenelle) in
[https://github.com/sphinx-contrib/sphinx-lint/pull/102](https://togithub.com/sphinx-contrib/sphinx-lint/pull/102)

#### New Contributors

- [@&#8203;rffontenelle](https://togithub.com/rffontenelle) made their
first contribution in
[https://github.com/sphinx-contrib/sphinx-lint/pull/102](https://togithub.com/sphinx-contrib/sphinx-lint/pull/102)

**Full Changelog**:
sphinx-contrib/sphinx-lint@v0.8.2...v0.9.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "every weekend" in timezone Etc/UTC,
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/canonical/craftcraft).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuOTMuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

3 participants