[`1.16.0`] `hatch version` fails with "No module named hatchling"
CI broke yesterday with the above error when running hatch version.
Pinning hatch<1.16 fixed the problem for us.
Please provide more information about where this is being run, what OS? What Python version? How hatch is being installed in your CI?
Linux container in CI Python version 3.10. Hatch is being installed from PyPI using pixi.
The output from CI is:
++ hatch version
Creating environment: hatch-build
Checking dependencies
Syncing dependencies
Inspecting build dependencies
/home/runner/.local/share/hatch/env/virtual/mypkg/dkW19B8f/hatch-build/bin/python: No module named hatchling
+ version=
Error: Process completed with exit code 1.
Just tested with 1.16.1:
Same error unfortunately.
Edit: hatchling is actually installed.
I can't repro locally unfortunately
❯ hatch --version
Hatch, version 1.16.1
❯ hatch version
0.47.2.post.dev001+dirty
So, it's something specific to the CI, even though I'm installing the same environment locally as in CI :/
Are you putting the output of version into GITHUB_OUTPUT? Wondering if it is the same issue as https://github.com/pypa/hatch/issues/2107#event-21232683998 Which there has been a fix that has been merged, expecting to release next week for this.
~~Nope - literally just running version=$(hatch version)~~
Actually it's running:
version=$(hatch version)
echo "path=${BUCKET}/${repo#*/}/${folder}/${version}" >> "$GITHUB_OUTPUT"
So yeah - it looks like it's putting the output into GITHUB_OUTPUT (though it doesn't seem to ever get to that line)
Edit: Also, I'm not setting HATCH_VERBOSE
I mapped my local checkout into a container, installed the env and hatch version works there.
It's just in my CI container where it fails... which is very odd, and very hard to debug :pensive:
Can you share what your CI setup looks like for steps that install hatch before calling hatch version? I think I have an idea what is causing this but I need to try to reproduce this in a local container.
The GitHub Actions code is:
- id: install_deps
name: Install doc dependencies
shell: bash --noprofile --norc -euxo pipefail {0}
run: python -m pip install -v --no-compile --prefer-binary .[docs] fsspec s3fs
<snip>
# ... docs build correctly here ... #
</snip>
- id: publish_dir
name: Determine publish directory
shell: bash --noprofile --norc -euxo pipefail {0}
env:
BUCKET: "<BUCKET>/docs"
run: |
# determine the folder to publish to based on the event type
repo="${{ github.repository }}"
if [[ ${{ github.event_name }} == "pull_request" ]]; then
folder="pr/${{ github.event.number }}"
elif [[ ${{ github.event_name }} == "push" ]]; then
folder="dev"
elif [[ ${{ github.event_name }} == "release" ]]; then
folder="stable"
else
echo "Unknown event ${{ github.event_name }}!"
exit 1
fi
version=$(hatch version) # <--- BOOM!!!
echo "path=${BUCKET}/${repo#*/}/${folder}/${version}" >> "$GITHUB_OUTPUT"
The docs deps are:
docs = [
"black>=25.1.0", # for formatting signatures
"hatch>=1.14.0", # for determining the version
"hatch-vcs>=0.4.0",
"hatchling>=1.27.0",
"hippogriffe>=0.2.0",
"ipykernel>=6.29.5,<7",
"mkdocs>=1.6.1",
"mkdocs-autorefs>=1.4.1",
"mkdocs-gen-files>=0.5.0",
"mkdocs-jupyter>=0.25.1",
"mkdocs-literate-nav>=0.6.2",
"mkdocs-material>=9.6.10",
"mkdocs-material-extensions>=1.3.1",
"mkdocs-section-index>=0.3.9",
"mkdocstrings>=0.29.1",
"mkdocstrings-python>=1.16.8",
"nbconvert>=7.16.5", # https://github.com/jupyter/nbconvert/releases/tag/v7.16.5
"numpydoc>=1.8.0",
]