pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.06k stars 306 forks source link

Creating new project fails with No module named 'hatchling.licenses' #1797

Closed dxie117 closed 1 day ago

dxie117 commented 2 days ago

Description Trying to set up hatch on a fresh machine with the latest Python version (3.13) and following example guide.

Expected behavior `hatch new "MyProject" to succeed

Actual Behavior


╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/<username>/.local/lib/python3.13/site-packages/hatch/cli/__init__.py:221 in main                │
│                                                                                                  │
│   218                                                                                            │
│   219 def main():  # no cov                                                                      │
│   220 │   try:                                                                                   │
│ ❱ 221 │   │   hatch(prog_name='hatch', windows_expand_args=False)                                │
│   222 │   except Exception:  # noqa: BLE001                                                      │
│   223 │   │   import sys                                                                         │
│   224                                                                                            │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/click/core.py:1157 in __call__                   │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/click/core.py:1078 in main                       │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/click/core.py:1688 in invoke                     │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/click/core.py:1434 in invoke                     │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/click/core.py:783 in invoke                      │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/click/decorators.py:45 in new_func               │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/hatch/cli/new/__init__.py:116 in new             │
│                                                                                                  │
│   113 │   │   app.abort(f'Some of the defined plugins were not found: {", ".join(sorted(plugin   │
│   114 │                                                                                          │
│   115 │   for template in templates:                                                             │
│ ❱ 116 │   │   template.initialize_config(template_config)                                        │
│   117 │                                                                                          │
│   118 │   template_files = []                                                                    │
│   119                                                                                            │
│                                                                                                  │
│ /home/<username>/.local/lib/python3.13/site-packages/hatch/template/default.py:41 in                  │
│ initialize_config                                                                                │
│                                                                                                  │
│    38 │   │   │   license_file_name = f'{license_id}.txt'                                        │
│    39 │   │   │   cached_license_path = cached_licenses_dir / license_file_name                  │
│    40 │   │   │   if not cached_license_path.is_file():                                          │
│ ❱  41 │   │   │   │   from hatchling.licenses.supported import VERSION                           │
│    42 │   │   │   │                                                                              │
│    43 │   │   │   │   url = f'https://raw.githubusercontent.com/spdx/license-list-data/v{VERSI   │
│    44 │   │   │   │   for _ in range(5):                                                         │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ModuleNotFoundError: No module named 'hatchling.licenses'

pip version pip 24.3.1 from /home//.local/lib/python3.13/site-packages/pip (python 3.13)

Python version Python 3.13

OS Ubuntu 22.04.3 LTS

How to Reproduce hatch new "MyProject"

Additional Notes:

Results of pip freeze show that I was using hatchling==1.26.1 . When I forced pip install hatchling==1.25.0, and tried repro-ing, project creation succeeded. After going back to 1.26.1, behavior does not repro. seems like a missing initialization in 1.26.X?

ofek commented 2 days ago

The version 1.26.0 was broken in relation to Hatch so it was yanked, sorry for the temporary error! I'm not sure why it happened in your exact case, perhaps cached .pyc files.

Clockwork-Muse commented 2 days ago

I'm hitting this in a brand-new devcontainer (so brand-new filesystem), getting hatchling version 1.26.1

jngbng commented 1 day ago

It seems hatchling 1.26.1 still has the problem. 1.25.0 works well.