diff --git a/.envrc b/.envrc index 4ad28e85c3..d65d8e83f9 100644 --- a/.envrc +++ b/.envrc @@ -1,22 +1,24 @@ #!/bin/bash # shellcheck disable=SC1091 -if [ ! -d .venv ]; then - echo "warning: creating virtualenv for the first time" - if which pyenv > /dev/null; then - eval "$(pyenv init -)" - pyenv install -s - else - echo "warning: pyenv not installed, using python3 and hoping for the best" - fi +if [[ -f "${PWD}/.env" ]]; then + dotenv +fi + +PATH_add "${HOME}/.local/share/sentry-devenv/bin" + +if ! command -v devenv >/dev/null; then + echo "install devenv: https://github.com/getsentry/devenv#install" + return 1 +fi + +PATH_add "${PWD}/.devenv/bin" - python3 -m venv .venv - source .venv/bin/activate - pip install $(grep ^-- requirements.txt) --upgrade pip==22.2.2 wheel==0.37.1 - make develop -else - source .venv/bin/activate - unset PS1 +if [ ! -d .venv ]; then + devenv sync fi +export VIRTUAL_ENV="${PWD}/.venv" +PATH_add "${PWD}/.venv/bin" + . scripts/rust-envvars diff --git a/Brewfile b/Brewfile index c35e195944..17707b5139 100644 --- a/Brewfile +++ b/Brewfile @@ -1,2 +1,5 @@ +# this is docker cli (not desktop) which is needed for interacting with colima +brew 'docker' + # necessary for rust-snuba brew 'cmake' diff --git a/devenv/config.ini b/devenv/config.ini new file mode 100644 index 0000000000..19b2ab73a8 --- /dev/null +++ b/devenv/config.ini @@ -0,0 +1,42 @@ +[venv.venv] +# TODO: need 3.11.8 +python = 3.12.3 +path = .venv +# TODO: need to combine requirements files into one +requirements = requirements.txt +editable = + . + +[python3.12.3] +darwin_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64-apple-darwin-install_only.tar.gz +darwin_x86_64_sha256 = c37a22fca8f57d4471e3708de6d13097668c5f160067f264bb2b18f524c890c8 +darwin_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-aarch64-apple-darwin-install_only.tar.gz +darwin_arm64_sha256 = ccc40e5af329ef2af81350db2a88bbd6c17b56676e82d62048c15d548401519e +linux_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64-unknown-linux-gnu-install_only.tar.gz +linux_x86_64_sha256 = a73ba777b5d55ca89edef709e6b8521e3f3d4289581f174c8699adfb608d09d6 +linux_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-aarch64-unknown-linux-gnu-install_only.tar.gz +linux_arm64_sha256 = ec8126de97945e629cca9aedc80a29c4ae2992c9d69f2655e27ae73906ba187d + +[colima] +darwin_x86_64 = https://github.com/abiosoft/colima/releases/download/v0.7.5/colima-Darwin-x86_64 +darwin_x86_64_sha256 = 53f78b4aaef5fb5dab65cae19fba4504047de1fdafa152fba90435d8a7569c2b +darwin_arm64 = https://github.com/abiosoft/colima/releases/download/v0.7.5/colima-Darwin-arm64 +darwin_arm64_sha256 = 267696d6cb28eaf6daa3ea9622c626697b4baeb847b882d15b26c732e841913c +linux_x86_64 = https://github.com/abiosoft/colima/releases/download/v0.7.5/colima-Linux-x86_64 +linux_x86_64_sha256 = a3d440033776b2fb0cdd6139a2dbebf6764aabf78a671d4aa13b45c26df21a8a +linux_arm64 = https://github.com/abiosoft/colima/releases/download/v0.7.5/colima-Linux-aarch64 +linux_arm64_sha256 = 330e11a4b2e5ce69ee6253635308c9f0f49195f236da01718ede35cdb2729901 +# used for autoupdate +version = v0.7.5 + +[lima] +# upstream github releases aren't built for macOS 14, so we use homebrew binaries +# from https://formulae.brew.sh/api/formula/lima.json +darwin_x86_64 = https://ghcr.io/v2/homebrew/core/lima/blobs/sha256:c2e69a572afa3a3cf895643ede988c87dc0622dae4aebc539d5564d820845841 +darwin_x86_64_sha256 = c2e69a572afa3a3cf895643ede988c87dc0622dae4aebc539d5564d820845841 +darwin_arm64 = https://ghcr.io/v2/homebrew/core/lima/blobs/sha256:be8e2b92961eca2f862f1a994dbef367e86d36705a705ebfa16d21c7f1366c35 +darwin_arm64_sha256 = be8e2b92961eca2f862f1a994dbef367e86d36705a705ebfa16d21c7f1366c35 +linux_x86_64 = https://ghcr.io/v2/homebrew/core/lima/blobs/sha256:741e9c7345e15f04b8feaf5034868f00fc3ff792226c485ab2e7679803411e0c +linux_x86_64_sha256 = 741e9c7345e15f04b8feaf5034868f00fc3ff792226c485ab2e7679803411e0c +# used for autoupdate +version = 0.23.2 diff --git a/devenv/sync.py b/devenv/sync.py new file mode 100644 index 0000000000..12d071705f --- /dev/null +++ b/devenv/sync.py @@ -0,0 +1,41 @@ +from devenv import constants +from devenv.lib import brew, config, colima, limactl, proc, venv + +def main(context: dict[str, str]) -> int: + reporoot = context["reporoot"] + cfg = config.get_repo(reporoot) + + brew.install() + + proc.run( + (f"{constants.homebrew_bin}/brew", "bundle"), + cwd=reporoot, + ) + + colima.install( + cfg["colima"]["version"], + cfg["colima"][constants.SYSTEM_MACHINE], + cfg["colima"][f"{constants.SYSTEM_MACHINE}_sha256"], + reporoot, + ) + limactl.install( + cfg["lima"]["version"], + cfg["lima"][constants.SYSTEM_MACHINE], + cfg["lima"][f"{constants.SYSTEM_MACHINE}_sha256"], + reporoot, + ) + + venv_dir, python_version, requirements, editable_paths, bins = venv.get(reporoot, "venv") + url, sha256 = config.get_python(reporoot, python_version) + print(f"ensuring venv at {venv_dir}...") + venv.ensure(venv_dir, python_version, url, sha256) + + print(f"syncing venv with {requirements}...") + venv.sync(reporoot, venv_dir, requirements, editable_paths, bins) + + # TODO: make install-python-dependencies install-rs-dev setup-git + + # start colima if it's not already running + colima.start(reporoot) + + return 0