-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d119a5e
commit 2b68913
Showing
11 changed files
with
141 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,50 +8,81 @@ Join the [Halmos Telegram Group][chat] for any inquiries or further discussions. | |
|
||
## Development Setup | ||
|
||
If you want to submit a pull request, fork the repository: | ||
Clone or fork the repository: | ||
|
||
```sh | ||
# if you want to submit a pull request, fork the repository: | ||
gh repo fork a16z/halmos | ||
``` | ||
|
||
Or, if you just want to develop locally, clone it: | ||
|
||
```sh | ||
# Or, if you just want to develop locally, clone it: | ||
git clone [email protected]:a16z/halmos.git | ||
|
||
# navigate to the project directory | ||
cd halmos | ||
``` | ||
|
||
Create and activate a virtual environment: | ||
**Recommended**: set up the development environment using [uv](https://docs.astral.sh/uv/): | ||
|
||
```sh | ||
python3.12 -m venv .venv && source .venv/bin/activate | ||
``` | ||
# install uv | ||
curl -LsSf https://astral.sh/uv/install.sh | sh | ||
|
||
Install the dependencies: | ||
# this does a lot of things: | ||
# - install a suitable python version if one is not found | ||
# - create a virtual environment in `.venv` | ||
# - install the main dependencies | ||
# - install the development dependencies | ||
# - generates a `uv.lock` file | ||
uv sync --extra dev | ||
|
||
```sh | ||
# install halmos and its runtime dependencies | ||
python -m pip install -e . | ||
# install and run the pre-commit hooks | ||
uv run pre-commit install | ||
uv run pre-commit run --all-files | ||
|
||
# make changes to halmos, then run it with: | ||
uv run halmos | ||
|
||
# install the dev dependencies | ||
python -m pip install -r requirements-dev.txt | ||
# run the tests with: | ||
uv run pytest | ||
|
||
# add a dependency to the project: | ||
uv add <dependency> | ||
|
||
# remove a dependency from the project: | ||
uv remove <dependency> | ||
|
||
# update a dependency to the latest version: | ||
uv lock --upgrade-package <dependency> | ||
|
||
# to manually update the environment and activate it: | ||
uv sync | ||
source .venv/bin/activate | ||
``` | ||
|
||
Install and run the git hook scripts (this is optional but will make sure that your PR will follow the style convention): | ||
Alternatively, you can manage the python version and the virtual environment manually using `pip` (not recommended for most users): | ||
|
||
```sh | ||
# create and activate a virtual environment with a suitable python version | ||
python3.12 -m venv .venv && source .venv/bin/activate | ||
|
||
# install halmos and its runtime dependencies in editable mode | ||
python -m pip install -e ".[dev]" | ||
|
||
# install and run the pre-commit hooks | ||
pre-commit install | ||
pre-commit run --all-files | ||
``` | ||
|
||
|
||
## Coding Style | ||
|
||
We recommend enabling the [black] formatter in your editor, but you can run it manually if needed: | ||
We recommend enabling the [ruff] formatter in your editor, but you can run it manually if needed: | ||
|
||
```sh | ||
python -m black src/ | ||
python -m ruff check src/ | ||
``` | ||
|
||
[black]: <https://black.readthedocs.io/en/stable/> | ||
[ruff]: <https://docs.astral.sh/ruff/> | ||
|
||
## GitHub Codespace | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
FROM ghcr.io/a16z/halmos-builder:latest | ||
|
||
# Enable the virtual environment | ||
ENV PATH="/halmos/.venv/bin:$PATH" | ||
ENV VIRTUAL_ENV='/halmos/.venv' | ||
# inspired by https://hynek.me/articles/docker-uv/ | ||
|
||
# Install halmos, assuming it is checked out in the context directory | ||
WORKDIR /halmos | ||
# - enable the virtual environment | ||
# - install halmos and its dependencies in UV_PROJECT_ENVIRONMENT | ||
# - enable bytecode compilation for faster startup | ||
# - disable downloading any additional packages | ||
# - use copy mode for linking instead of symlinking (because we mount to /src temporarily) | ||
ENV PATH="/halmos/bin:$PATH" \ | ||
VIRTUAL_ENV='/halmos' \ | ||
UV_PROJECT_ENVIRONMENT='/halmos' \ | ||
UV_COMPILE_BYTECODE=1 \ | ||
UV_PYTHON=python3.13 \ | ||
UV_PYTHON_DOWNLOADS=never \ | ||
UV_LINK_MODE=copy | ||
|
||
# Install halmos, assuming it is checked out in the current host directory | ||
# we don't specify --frozen or --locked because we don't check in uv.lock | ||
RUN --mount=type=bind,source=../..,target=/src,readonly=false \ | ||
uv venv && \ | ||
uv pip install --no-cache /src && \ | ||
uv pip install --no-cache -r /src/requirements-dev.txt | ||
cd /src && \ | ||
uv sync --extra dev --no-editable | ||
|
||
# Set a nicer prompt | ||
ENV IMAGE_NAME=halmos | ||
RUN echo 'PS1="($IMAGE_NAME) \[\033[1;32m\]\u@\h \[\033[1;35m\]\w \$\[\033[0m\] "' >> /root/.bashrc | ||
|
||
# optional: print python version, site packages, and check that halmos can be imported | ||
RUN <<EOT | ||
python -V | ||
python -Im site | ||
python -Ic 'import halmos' | ||
EOT | ||
|
||
WORKDIR /workspace | ||
CMD ["halmos"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.