You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error raised here appears to be out of date. I couldn't find any documentation or issues about this change to the build config, so I might be mistaken, but I felt like it was worth reaching out since hatch seems like it's not behaving as expected.
When a project name does not match the (snake_cased) module name hatch shell will throw this error recommend adding this kind of config to your pyproject.toml:
This appears to be incorrect and the correct recommendation seems to be:
[tool.hatch.build]
packages = ["src/foo"]
Looking through the issues I did see #1245 on improving documentation, so maybe this issue is already known. Or maybe I'm configuring hatch incorrectly..
Steps to reproduce issue
I'm using the latest version of hatch.
hatch --version
# Hatch, version 1.13.0
First, create a fresh hatch project called exampleprefix-foo with one module foo.
hatch new exampleprefix-foo
cd exampleprefix-foo
mv src/exampleprefix_foo src/foo
Then adjust the pyproject.toml to reflect the new module name foo removing unnecessary configs along the way.
hatch shell with the project in this state will throw the error mentioned above, as expected.
Next, inject the recommended TOML into pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "exampleprefix-foo"dynamic = ["version"]
description = ''readme = "README.md"requires-python = ">=3.8"license = "MIT"keywords = []
authors = []
dependencies = []
[tool.hatch.version]
path = "src/foo/__about__.py"# Since we have a module named `foo` in this example we can copy/paste verbatim
[tool.hatch.build.targets.wheel]
packages = ["src/foo"]
This will setup the default env successfully, but the foo package is not installed.
hatch shell
python -c 'import foo'# Traceback (most recent call last):# File "<string>", line 1, in <module># import foo# ModuleNotFoundError: No module named 'foo'
How to resolve
Swap [tool.hatch.build.targets.wheel] for [tool.hatch.build]
The error raised here appears to be out of date. I couldn't find any documentation or issues about this change to the build config, so I might be mistaken, but I felt like it was worth reaching out since
hatch
seems like it's not behaving as expected.When a project name does not match the (snake_cased) module name
hatch shell
will throw this error recommend adding this kind of config to yourpyproject.toml
:This appears to be incorrect and the correct recommendation seems to be:
Looking through the issues I did see #1245 on improving documentation, so maybe this issue is already known. Or maybe I'm configuring hatch incorrectly..
Steps to reproduce issue
I'm using the latest version of hatch.
hatch --version # Hatch, version 1.13.0
First, create a fresh hatch project called
exampleprefix-foo
with one modulefoo
.hatch new exampleprefix-foo cd exampleprefix-foo mv src/exampleprefix_foo src/foo
Then adjust the
pyproject.toml
to reflect the new module namefoo
removing unnecessary configs along the way.hatch shell
with the project in this state will throw the error mentioned above, as expected.Next, inject the recommended TOML into
pyproject.toml
This will setup the default env successfully, but the
foo
package is not installed.How to resolve
Swap
[tool.hatch.build.targets.wheel]
for[tool.hatch.build]
Then rebuild the hatch shell environment and try again.
hatch env remove hatch shell python -c 'import foo'
This works!
The text was updated successfully, but these errors were encountered: