pythonpytestpython-wheelhatch

How to make hatch test install the whl instead of directly using project dir?


With the AI answers, I was recommended to do:

[tool.hatch.envs.hatch-test]
dev-mode = false # This is the line recommended by AI to have it installed instead of having it editable/local use mode
dependencies = [
    "pytest"
]

But when I try hatch test I still get:

=========================================== FAILURES ===========================================
_________________________________________ test_binary __________________________________________

    def test_binary() -> str | None:
        if True:
            root = files('del3')
            children = [f for f in get_files_recursively(root)]
>           raise AssertionError(f"{children}")
E           AssertionError: [WindowsPath('E:/SourceCode/AndroidStudioProjects/Base/del3/src/del3/__about__.py'), WindowsPath('E:/SourceCode/AndroidStudioProjects/Base/del3/src/del3/__init__.py'), WindowsPath('E:/SourceCode/AndroidStudioProjects/Base/del3/src/del3/__pycache__/__init__.cpython-312.pyc')]  

As you can see, it's still using the local files instead of installing the whl then use from env.

  1. What's the correct way to install my package as whl, not directly use it?
  2. Is hatch really the best tool? Or do other better/easier build systems exist?

My goal is to bundle a binary and then on test install the whl to confirm its working. I like the hatch build hook, but the test is unsatisfactory as it tries to use the files directly instead of installing the whl then using it.


Solution

  • dev-mode = false
    

    Is the correct answer!
    The latest version 1.16.2 is buggy,
    downgrade to 1.15.1, and it'll work as expected.

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