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

ModuleNotFoundError: No module named 'hatchling.dep' with hatchling 1.26.0 #1793

Closed
jdicioccio opened this issue Nov 10, 2024 · 14 comments · Fixed by #1795
Closed

ModuleNotFoundError: No module named 'hatchling.dep' with hatchling 1.26.0 #1793

jdicioccio opened this issue Nov 10, 2024 · 14 comments · Fixed by #1795

Comments

@jdicioccio
Copy link

jdicioccio commented Nov 10, 2024

With the just-released 1.26.0, I'm getting the following error when using 'hatch run'

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/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                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/core.py:1157 in __call__                           │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/core.py:1078 in main                               │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/core.py:1688 in invoke                             │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/core.py:1434 in invoke                             │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/core.py:783 in invoke                              │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/decorators.py:33 in new_func                       │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/cli/run/__init__.py:147 in run                     │
│                                                                                                  │
│   144 │   elif not env_name:                                                                     │
│   145 │   │   env_name = 'system'                                                                │
│   146 │                                                                                          │
│ ❱ 147 │   ctx.invoke(                                                                            │
│   148 │   │   run_command,                                                                       │
│   149 │   │   args=[command, *final_args],                                                       │
│   150 │   │   env_names=[env_name],                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/core.py:783 in invoke                              │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/click/decorators.py:45 in new_func                       │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/cli/env/run.py:134 in run                          │
│                                                                                                  │
│   131 │   elif not matrix_selected and (included_variables or excluded_variables):               │
│   132 │   │   app.abort(f'Variable selection is unsupported for non-matrix environments: {", "   │
│   133 │                                                                                          │
│ ❱ 134 │   for context in app.runner_context(                                                     │
│   135 │   │   environments,                                                                      │
│   136 │   │   ignore_compat=ignore_compat or matrix_selected,                                    │
│   137 │   │   display_header=matrix_selected,                                                    │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/cli/application.py:224 in runner_context           │
│                                                                                                  │
│   221 │   │   │   │   context = ExecutionContext(environment)                                    │
│   222 │   │   │   │   yield context                                                              │
│   223 │   │   │   │                                                                              │
│ ❱ 224 │   │   │   │   self.prepare_environment(environment)                                      │
│   225 │   │   │   │   with EnvVars(context.env_vars):                                            │
│   226 │   │   │   │   │   self.run_shell_commands(context)                                       │
│   227                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/cli/application.py:143 in prepare_environment      │
│                                                                                                  │
│   140 │   │   │   │   │   │   )                                                                  │
│   141 │   │                                                                                      │
│   142 │   │   with environment.app_status_dependency_state_check():                              │
│ ❱ 143 │   │   │   new_dep_hash = environment.dependency_hash()                                   │
│   144 │   │                                                                                      │
│   145 │   │   current_dep_hash = self.env_metadata.dependency_hash(environment)                  │
│   146 │   │   if new_dep_hash != current_dep_hash:                                               │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/env/plugin/interface.py:667 in dependency_hash     │
│                                                                                                  │
│    664 │   │   """                                                                               │
│    665 │   │   from hatch.utils.dep import hash_dependencies                                     │
│    666 │   │                                                                                     │
│ ❱  667 │   │   return hash_dependencies(self.dependencies_complex)                               │
│    668 │                                                                                         │
│    669 │   @contextmanager                                                                       │
│    670 │   def app_status_creation(self):                                                        │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/env/plugin/interface.py:316 in                     │
│ dependencies_complex                                                                             │
│                                                                                                  │
│    313 │   │   │   if (not self.skip_install and self.dev_mode) or self.features:                │
│    314 │   │   │   │   from hatch.utils.dep import get_project_dependencies_complex              │
│    315 │   │   │   │                                                                             │
│ ❱  316 │   │   │   │   dependencies_complex, optional_dependencies_complex = get_project_depend  │
│    317 │   │   │   │                                                                             │
│    318 │   │   │   │   if not self.skip_install and self.dev_mode:                               │
│    319 │   │   │   │   │   all_dependencies_complex.extend(dependencies_complex.values())        │
│                                                                                                  │
│ /usr/local/lib/python3.13/site-packages/hatch/utils/dep.py:40 in                                 │
│ get_project_dependencies_complex                                                                 │
│                                                                                                  │
│   37 def get_project_dependencies_complex(                                                       │
│   38 │   environment: EnvironmentInterface,                                                      │
│   39 ) -> tuple[dict[str, Requirement], dict[str, dict[str, Requirement]]]:                      │
│ ❱ 40 │   from hatchling.dep.core import dependencies_in_sync                                     │
│   41 │                                                                                           │
│   42 │   dependencies_complex = {}                                                               │
│   43 │   optional_dependencies_complex = {}                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ModuleNotFoundError: No module named 'hatchling.dep'
@afourney
Copy link

afourney commented Nov 10, 2024

Yes. Me too for hatch test , hatch run types:check, and hatch build as well.

@juntyr
Copy link

juntyr commented Nov 10, 2024

+1

1 similar comment
@dycw
Copy link

dycw commented Nov 10, 2024

+1

@inimaz
Copy link

inimaz commented Nov 10, 2024

Same here!
If it helps, as a workaround I fixed the version to the previous hatchling pip install hatch==1.13.0 hatchling==1.25.0 and everything back to normal.

@potiuk
Copy link
Contributor

potiuk commented Nov 10, 2024

Same with airflow. Pinning to hatchling 1.25.0 fixes the issue

@juntyr
Copy link

juntyr commented Nov 10, 2024

Unfortunately in my case I don't control the dependency on hatchlings so I can't pin it directly. Is there something akin to a global constraints file for pip?

Ideally, 1.26.0 would be yanked or a patch for hatch released asap.

@DimitriPapadopoulos
Copy link
Contributor

The hatch-v1.13.0 tag still contains the following code:

def get_project_dependencies_complex(
environment: EnvironmentInterface,
) -> tuple[dict[str, Requirement], dict[str, dict[str, Requirement]]]:
from hatchling.dep.core import dependencies_in_sync

@DimitriPapadopoulos
Copy link
Contributor

DimitriPapadopoulos commented Nov 10, 2024

#1582 / adba003 removed the above code and predates 28bfe35. Yet, it didn't make it into hatch-v1.13.0. What happened?

@DimitriPapadopoulos
Copy link
Contributor

DimitriPapadopoulos commented Nov 10, 2024

The hatch-v1.13.x branch was forked from the master branch too early as far as I can see, and misses most recent changes that are necessary to hatchling 1.26.0, including #1582 / adba003.

I think the hatch-v1.13.0 tag should have been applied to the master branch on 28bfe35, instead it has been applied to the spurious hatch-v1.13.x branch on 4e3c515.

The solution is indeed to:

dave-shawley added a commit to dave-shawley/pymdown-ietf that referenced this issue Nov 10, 2024
dave-shawley added a commit to dave-shawley/pymdown-ietf that referenced this issue Nov 10, 2024
dave-shawley added a commit to dave-shawley/ietfparse that referenced this issue Nov 10, 2024
dave-shawley added a commit to dave-shawley/ietfparse that referenced this issue Nov 10, 2024
@ofek
Copy link
Collaborator

ofek commented Nov 10, 2024

Sorry about that everybody!

#1582 / adba003 removed the above code and predates 28bfe35. Yet, it didn't make it into hatch-v1.13.0. What happened?

I have a branch for that minor release because there was a bunch of stuff on master that was not yet ready to be released and it was important to ship support for Python 3.13.

@potiuk
Copy link
Contributor

potiuk commented Nov 10, 2024

Thanks for a quick fix @ofek . How about yanking 1.26.0 ? I think it's generally broken, so might be good to yank it

@ofek
Copy link
Collaborator

ofek commented Nov 11, 2024

It's broken in relation to Hatch only, no?

@potiuk
Copy link
Contributor

potiuk commented Nov 11, 2024

Yes. That's what we saw - it broke whe we installed hatch, but our packages seemeed to be build correctly. So yes - there is no "strong" need to yank it, but I guess it's no harm either.

@ofek
Copy link
Collaborator

ofek commented Nov 11, 2024

True, yanked! https://pypi.org/project/hatchling/1.26.0/

franzinc pushed a commit to franzinc/agraph-python that referenced this issue Nov 24, 2024
This version, unlike `hatch` 1.9.3, has an upper limit on the version
of the `hatchling` dependency, which should prevent problems like this
one:

    pypa/hatch#1793

when the new release of `hatchling` (1.26.0) was automatically picked
up by `hatch` 1.9.3 and broke stuff.

Change-Id: I4238087b80175e5ae732d44f95274bcf3ea2fdef
Reviewed-on: https://gerrit.franz.com:9080/c/agraph-python/+/26469
Reviewed-by: Tianyu Gu <gty@franz.com>
Tested-by: John Foderaro <jkf@franz.com>
Reviewed-by: John Foderaro <jkf@franz.com>
Ptest: John Foderaro <jkf@franz.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 a pull request may close this issue.

8 participants