hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Hatch not installing py.typed file for dependency in environment

Open lorenzo-arena opened this issue 1 month ago • 2 comments

Hi, I have a strange behavior with how environments are managed in one of my projects.

In my pyproject.toml configuration I have, as dependencies for my module, a couple of modules set like

"module_1 @ {root:uri}/subprojects/module-1",
"module_2 @ {root:uri}/subprojects/module-2",

Which are clone as git submodules in the main module repository. Now, those modules are in turn projects managed by hatch and didn't initially include a py.typed project. However, after I added it (as well as the configuration necessary to always install it alongside the module sources for module_1 and module_2 I'm still not getting the py.typed file installed in the module directory. I can check it for example by doing

ls $(dirname $(hatch run python -c "import importlib.util, module_1; print(importlib.util.find_spec('module_1').origin)"))

and it's missing. Now, the issue is that in my CI, which runs in a docker image with a fresh clone of the repository, it's present. I also tried to clone the repository under a new path in my local machine and by running hatch shell and checking with the previous command I can see that there the py.typed file for "module_1" is installed.

However if I fully remove and then clone the repository at the same path I can see that the environment gets recreated with the same ID (@ $HOME/.local/share/hatch/env/virtual/myproject/2BSC15rG/) and the issue persists (I obviously tried to remove that folder by hand, remove the environments, and so on).

Is it due to some internal caching mechanism of hatch? How can I "force" a reinstall of those modules?

lorenzo-arena avatar Nov 06 '25 09:11 lorenzo-arena

How did you try to remove the environments? Was it through hatch env prune or hatch env remove {env_name}? Or did you just delete the file location?

cjames23 avatar Nov 07 '25 23:11 cjames23

I tried them all, recreating the environment after with hatch shell. Pretty much the issue persists if I don't change the project path (which in turn changes the path of the environment)

lorenzo-arena avatar Nov 08 '25 08:11 lorenzo-arena