diff --git a/.envrc b/.envrc index e8f40bf43f..d65d8e83f9 100644 --- a/.envrc +++ b/.envrc @@ -1,24 +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 - 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 +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" + +if [ ! -d .venv ]; then + devenv sync fi -export PATH="$PWD/snuba/admin/node_modules/.bin/:$PATH" +export VIRTUAL_ENV="${PWD}/.venv" +PATH_add "${PWD}/.venv/bin" . scripts/rust-envvars diff --git a/Brewfile b/Brewfile index f396bebe58..c4aed919e8 100644 --- a/Brewfile +++ b/Brewfile @@ -1,2 +1,3 @@ brew 'cmake' # for rust-snuba brew 'protobuf' # for rust-snuba > sentry_protos +brew 'rustup' diff --git a/devenv/config.ini b/devenv/config.ini new file mode 100644 index 0000000000..8bc38fe4af --- /dev/null +++ b/devenv/config.ini @@ -0,0 +1,16 @@ +[devenv] +minimum_version = 1.16.0 + +[venv.venv] +python = 3.11.11 +path = .venv +# TODO: need to combine requirements files into one +requirements = requirements.txt +editable = + . + +[python3.11.11] +darwin_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20250212/cpython-3.11.11+20250212-x86_64-apple-darwin-install_only.tar.gz +darwin_x86_64_sha256 = 1f1afc064b523b67c06e6d4b024a8dbb8df5fa12f0f0018b218c855491833451 +darwin_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20250212/cpython-3.11.11+20250212-aarch64-apple-darwin-install_only.tar.gz +darwin_arm64_sha256 = 6dd5603e5570b8c4e1abf1ef2a329f195dd052890b1fa3b01b7406552a4f45a1 diff --git a/devenv/sync.py b/devenv/sync.py new file mode 100644 index 0000000000..a0c8ba992d --- /dev/null +++ b/devenv/sync.py @@ -0,0 +1,33 @@ +import os + +from devenv import constants +from devenv.lib import brew, colima, config, proc, venv + + +def main(context: dict[str, str]) -> int: + reporoot = context["reporoot"] + + brew.install() + + proc.run( + (f"{constants.homebrew_bin}/brew", "bundle"), + cwd=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) + + print("running make develop...") + os.system("make develop") + + # start colima if it's not already running + colima.start(reporoot) + + return 0