rye: Hatchling 1.19 breaks `rye sync`

Steps to Reproduce

See

https://github.com/pypa/hatch/issues/1113

❯ rye sync --no-lock
Reusing already existing virtualenv
Installing dependencies
Looking in indexes: https://pypi.org/simple/, https://pypi.org/simple/
Obtaining file:///. (from -r /tmp/tmpo2k2iiit (line 1))
  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
  ╰─> [31 lines of output]
      Traceback (most recent call last):
        File "/tmp/.tmpy1qEr0/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'

Expected Result

rye sync should succeed

Actual Result

❯ rye sync --no-lock
Reusing already existing virtualenv
Installing dependencies
Looking in indexes: https://pypi.org/simple/, https://pypi.org/simple/
Obtaining file:///. (from -r /tmp/tmpo2k2iiit (line 1))
  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
  ╰─> [31 lines of output]
      Traceback (most recent call last):
        File "/tmp/.tmpy1qEr0/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'

Version Info

❯ rye --version rye 0.15.2 commit: 0.15.2 (2023-10-04) platform: macos (aarch64) self-python: cpython@3.11 symlink support: true

Stacktrace

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 4
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

For anyone who runs into this on an existing project, add this to your pyproject.toml:

[tool.hatch.build.targets.wheel]
packages = ["src/YOUR_PACKAGE_NAME"]

Workaround is

[build-system]
requires = ["hatchling<=1.18.0"]
build-backend = "hatchling.build"

For a project without a package, hatch worked in 1.18 fine, in 1.19 you kinda need to add a dummy (see pyproject.toml in this repo)

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

Maybe using tool.hatch.build.targets.wheel.bypass-selection is better.

FYI https://github.com/pypa/hatch/pull/1135