Installation reference
The hegel-core server uses Hypothesis as the underlying library providing data generation, shrinking, and so on. Every Hegel library, regardless of language, therefore has an implicit dependency on Python.
At runtime, the first time a Hegel test is run in a test suite, each Hegel library spawns the hegel-core server as a subprocess. It does so by invoking the executable entrypoint provided by the hegel-core Python package.
Each Hegel library uses the following steps to resolve the hegel-core path:
- If the
HEGEL_SERVER_COMMANDenvironment variable is set, use that path. - Otherwise, the library expects
uvto be on the PATH.- If
uvis not on the PATH, the library errors with a message about possible next steps, including how to installuvand directing you to this page. - If
uvis on the PATH, the library usesuvto installhegel-core==$VERSIONinto a virtual environment located in.hegel/venv.$VERSIONis determined by the version of the Hegel library you have installed, as each Hegel library pins to an exacthegel-coreversion in its source1. It also writes.hegel/venv/hegel-version, a text file containing$VERSIONas ASCII text. - If
.hegel/venvalready exists, the Hegel library checks.hegel/venv/hegel-version. If that version is different than its pinned$VERSION, it re-creates.hegel/venvwithhegel-core==$VERSION.
- If
Some practical implications of this:
- The installation through the
uvpath happens at runtime. If your tests must run in a sandboxed environment without network access, consider usingHEGEL_SERVER_COMMAND. - If you upgrade your Hegel library, and the Hegel library happened to bump its
hegel-coreversion, your first test run afterwards will be slow as it upgrades the localhegel-corelibrary.
Hegel libraries log the installation of the venv and hegel-core to .hegel/venv/install.log, which might help you narrow down any issues.
Installing hegel-core manually
Section titled “Installing hegel-core manually”If you require greater control over how and when hegel-core is installed, use the HEGEL_SERVER_COMMAND environment variable.
Where the hegel-core binary gets placed depends on how you install hegel-core. For example, when using pip, the binary is placed into bin/hegel, where the bin/ directory is located inside the corresponding Python environment. You might then set HEGEL_SERVER_COMMAND=/path/to/.../bin/hegel.
For knowledgeable Python users, it may be useful to know that Hegel defines its entrypoint as:
[project.scripts]hegel = "hegel.__main__:main"Note that if you set HEGEL_SERVER_COMMAND, you are responsible for ensuring that your Hegel library version is compatible with that hegel-core version.
Troubleshooting
Section titled “Troubleshooting”If you run into installation issues, for example a version mismatch on disk, you can delete .hegel/venv to force a fresh install.
Footnotes
Section titled “Footnotes”-
Note that there is no correspondence between
hegel-coreversion numbers and Hegel library version numbers. ↩