Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
- run: uv sync
- uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # v3.0.0
- run: uv run prek run --all-files
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.4
3.13.16
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Co-Authored-By: <agent and model> <email>
- Set up: `uv sync`
- Test: `uv run pytest tests/`
- Test with coverage, as CI runs it: `uv run coverage erase && uv run coverage run -m pytest && uv run coverage report`
- Lint, format, and type-check (ruff, mypy, shellcheck): `uv run pre-commit run --all-files`
- Lint, format, and type-check (ruff, mypy, shellcheck): `uv run prek run --all-files`
- Run your checkout against another repo: `uv run --project ~/code/devenv devenv sync` from that repo's root
- Run the `bootstrap` workflow locally with `gh act`: `make test`

## Invariants

- Python is pinned to 3.11.4 (`requires-python` in `pyproject.toml`, `.python-version`).
- Python is pinned to 3.13.16 (`requires-python` in `pyproject.toml`, `.python-version`).
- Use `constants.DARWIN` and `constants.LINUX` for platform checks.
- macOS gets the global tools (brew, docker CLI, colima, lima). Linux means apt-based (`dpkg` on PATH). On Linux, devenv installs no global tools, and `devenv bootstrap` exits if docker engine is missing.

Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ PATH_add "${PWD}/.venv/bin"
```py
from devenv.lib import proc


def main(context: dict[str, str]) -> int:
# reporoot/.venv is the default venv location
print(f"syncing .venv ...")
Expand All @@ -180,7 +181,7 @@ def main(context: dict[str, str]) -> int:

Use `[reporoot]/.python-version` to pin a python version for uv:
```
3.13.3
3.13.16
```

### node
Expand All @@ -197,6 +198,7 @@ PATH_add "${PWD}/node_modules/.bin"
from devenv import constants
from devenv.lib import config, node, proc


def main(context: dict[str, str]) -> int:
reporoot = context["reporoot"]
cfg = config.get_repo(reporoot)
Expand All @@ -217,7 +219,7 @@ def main(context: dict[str, str]) -> int:
"install",
"--frozen-lockfile",
"--reporter=append-only",
),
)
)

return 0
Expand Down Expand Up @@ -246,15 +248,13 @@ version = v20.13.1
from devenv import constants
from devenv.lib import brew, proc


def main(context: dict[str, str]) -> int:
reporoot = context["reporoot"]

brew.install()

proc.run(
(f"{constants.homebrew_bin}/brew", "bundle"),
cwd=reporoot,
)
proc.run((f"{constants.homebrew_bin}/brew", "bundle"), cwd=reporoot)

return 0
```
Expand All @@ -277,6 +277,7 @@ On macOS, `devenv bootstrap` installs colima and the docker CLI globally. If you
from devenv import constants
from devenv.lib import config, gcloud


def main(context: dict[str, str]) -> int:
reporoot = context["reporoot"]
cfg = config.get_repo(reporoot)
Expand All @@ -292,10 +293,11 @@ def main(context: dict[str, str]) -> int:
```

`[reporoot]/devenv/config.ini`
The SDK uses devenv's internal Python 3.13 because custom Python versions
aren't supported yet.

```ini
[gcloud]
# custom python version not supported yet, it just uses
# devenv's internal python 3.11
darwin_x86_64 = https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-490.0.0-darwin-x86_64.tar.gz
darwin_x86_64_sha256 = fa396909acc763cf831dd5d89e778999debf37ceadccb3c1bdec606e59ba2694
darwin_arm64 = https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-490.0.0-darwin-arm.tar.gz
Expand All @@ -317,6 +319,7 @@ Define `[reporoot]/.terraform-version`, and optionally `[reporoot]/.terragrunt-v
from devenv import constants
from devenv.lib import config, tenv


def main(context: dict[str, str]) -> int:
reporoot = context["reporoot"]
cfg = config.get_repo(reporoot)
Expand Down
20 changes: 10 additions & 10 deletions ci/integration/repo/devenv/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ linux_x86_64 = https://github.com/tofuutils/tenv/releases/download/v1.3.0/tenv_v
linux_x86_64_sha256 = aa85779eed7aaf05232b07df67815914a2eeef250989c1ae2946bd9194f7b791

[venv.foo]
python = 3.11.6
python = 3.13.16
requirements = requirements.txt

[python3.11.6]
darwin_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-x86_64-apple-darwin-install_only.tar.gz
darwin_x86_64_sha256 = 178cb1716c2abc25cb56ae915096c1a083e60abeba57af001996e8bc6ce1a371
darwin_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-aarch64-apple-darwin-install_only.tar.gz
darwin_arm64_sha256 = 916c35125b5d8323a21526d7a9154ca626453f63d0878e95b9f613a95006c990
linux_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz
linux_x86_64_sha256 = ee37a7eae6e80148c7e3abc56e48a397c1664f044920463ad0df0fc706eacea8
linux_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz
linux_arm64_sha256 = 3e26a672df17708c4dc928475a5974c3fb3a34a9b45c65fb4bd1e50504cc84ec
[python3.13.16]
darwin_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-x86_64-apple-darwin-install_only.tar.gz
darwin_x86_64_sha256 = d1f2e7b5f0cfa25fc856fea819890bbe722f47a692e5ce2552636b5240930b38
darwin_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-aarch64-apple-darwin-install_only.tar.gz
darwin_arm64_sha256 = ca0e6a70fb75a0984751bd75493e3de77680aef7fbd0fea9b903c299537b3423
linux_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-x86_64-unknown-linux-gnu-install_only.tar.gz
linux_x86_64_sha256 = e588e50db882fa6a89f926d9a9ad64e445183af0eda5bda226a2c151b17db8a6
linux_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-aarch64-unknown-linux-gnu-install_only.tar.gz
linux_arm64_sha256 = 0fce0605da7b6532d5bdaec185336ffaaddd02ec04e27382014952ca4857ed6d
12 changes: 6 additions & 6 deletions install-devenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ parseopt() { # argument (and environment-var) processing

SNTY_DEVENV_HOME="${SNTY_DEVENV_HOME:-$XDG_DATA_HOME/$appname}"
SNTY_DEVENV_CACHE="${SNTY_DEVENV_CACHE:-$XDG_CACHE_HOME/$appname}"
SNTY_DEVENV_PY_RELEASE="${SNTY_DEVENV_PY_RELEASE:-20230726}"
SNTY_DEVENV_PY_VERSION="${SNTY_DEVENV_PY_VERSION:-3.11.4}"
SNTY_DEVENV_PY_RELEASE="${SNTY_DEVENV_PY_RELEASE:-20261013}"
SNTY_DEVENV_PY_VERSION="${SNTY_DEVENV_PY_VERSION:-3.13.16}"
}

# translate from uname output to astral release tags:
Expand Down Expand Up @@ -144,10 +144,10 @@ install_python() {
astral_platform="$(astral_cpu)-$(astral_os)"

case "$astral_platform" in
aarch64-apple-darwin) sha256=cb6d2948384a857321f2aa40fa67744cd9676a330f08b6dad7070bda0b6120a4;;
x86_64-apple-darwin) sha256=47e1557d93a42585972772e82661047ca5f608293158acb2778dccf120eabb00;;
x86_64-unknown-linux-gnu) sha256=e26247302bc8e9083a43ce9e8dd94905b40d464745b1603041f7bc9a93c65d05;;
aarch64-unknown-linux-gnu) sha256=2e84fc53f4e90e11963281c5c871f593abcb24fc796a50337fa516be99af02fb;;
aarch64-apple-darwin) sha256=ca0e6a70fb75a0984751bd75493e3de77680aef7fbd0fea9b903c299537b3423;;
x86_64-apple-darwin) sha256=d1f2e7b5f0cfa25fc856fea819890bbe722f47a692e5ce2552636b5240930b38;;
x86_64-unknown-linux-gnu) sha256=e588e50db882fa6a89f926d9a9ad64e445183af0eda5bda226a2c151b17db8a6;;
aarch64-unknown-linux-gnu) sha256=0fce0605da7b6532d5bdaec185336ffaaddd02ec04e27382014952ca4857ed6d;;
*)
error "Unexpected platform; please ask in #discuss-dev-infra or contact <team-devenv@sentry.io>: ($platform -> $astral_platform)"
;;
Expand Down
2 changes: 1 addition & 1 deletion lib/gh-act/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
github_arch="$(./github-arch.sh)"
python_version="$(
./github-python-versions.sh "$github_arch" |
grep -m1 -E '^3.11\b'
grep -m1 -E '^3.13\b'
)"
tag="localhost/devenv-gh-act:python$(
sed '
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
]
description = "Utilities for setting up a Sentry development environment"
readme = "README.md"
requires-python = "==3.11.4"
requires-python = "==3.13.16"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand All @@ -30,7 +30,7 @@ dependencies = [
find = {}

[tool.ruff]
target-version = "py311"
target-version = "py313"
line-length = 80

[tool.ruff.lint]
Expand All @@ -49,7 +49,7 @@ skip-magic-trailing-comma = true
devenv = "devenv.main:main"

[tool.mypy]
python_version = "3.11"
python_version = "3.13"
strict = true

# disallow Any typing:
Expand All @@ -68,7 +68,7 @@ allow_redefinition = true

[tool.pyright]
include = ["."]
pythonVersion = "3.11"
pythonVersion = "3.13"

typeCheckingMode = "strict"

Expand All @@ -92,7 +92,7 @@ dev = [
"coverage",
"covdefaults",
"mypy",
"pre-commit",
"prek",
"pytest",
"re-assert",
"ruff",
Expand Down
40 changes: 20 additions & 20 deletions tests/lib/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@

mock_config = """
[venv.sentry-kube]
python = 3.11.6
python = 3.13.16
requirements = k8s/cli/requirements.txt
editable =
k8s/cli
k8s/cli/libsentrykube
bins =
pre-commit
prek
pyupgrade
sentry-kube
sentry-kube-pop

[python3.11.6]
darwin_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-x86_64-apple-darwin-install_only.tar.gz
darwin_x86_64_sha256 = 178cb1716c2abc25cb56ae915096c1a083e60abeba57af001996e8bc6ce1a371
darwin_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-aarch64-apple-darwin-install_only.tar.gz
darwin_arm64_sha256 = 916c35125b5d8323a21526d7a9154ca626453f63d0878e95b9f613a95006c990
linux_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz
linux_x86_64_sha256 = ee37a7eae6e80148c7e3abc56e48a397c1664f044920463ad0df0fc706eacea8
linux_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20231002/cpython-3.11.6+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz
linux_arm64_sha256 = 3e26a672df17708c4dc928475a5974c3fb3a34a9b45c65fb4bd1e50504cc84ec
[python3.13.16]
darwin_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-x86_64-apple-darwin-install_only.tar.gz
darwin_x86_64_sha256 = d1f2e7b5f0cfa25fc856fea819890bbe722f47a692e5ce2552636b5240930b38
darwin_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-aarch64-apple-darwin-install_only.tar.gz
darwin_arm64_sha256 = ca0e6a70fb75a0984751bd75493e3de77680aef7fbd0fea9b903c299537b3423
linux_x86_64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-x86_64-unknown-linux-gnu-install_only.tar.gz
linux_x86_64_sha256 = e588e50db882fa6a89f926d9a9ad64e445183af0eda5bda226a2c151b17db8a6
linux_arm64 = https://github.com/astral-sh/python-build-standalone/releases/download/20261013/cpython-3.13.16+20261013-aarch64-unknown-linux-gnu-install_only.tar.gz
linux_arm64_sha256 = 0fce0605da7b6532d5bdaec185336ffaaddd02ec04e27382014952ca4857ed6d
"""


Expand All @@ -50,10 +50,10 @@ def test_get_ensure(tmp_path: pathlib.Path) -> None:

assert (venv_dir, python_version, requirements, editable_paths, bins) == (
f"{repo.path}/.venv-sentry-kube",
"3.11.6",
"3.13.16",
f"{repo.path}/k8s/cli/requirements.txt",
(f"{repo.path}/k8s/cli", f"{repo.path}/k8s/cli/libsentrykube"),
("pre-commit", "pyupgrade", "sentry-kube", "sentry-kube-pop"),
("prek", "pyupgrade", "sentry-kube", "sentry-kube-pop"),
)

url, sha256 = config.get_python(repo.path, python_version)
Expand Down Expand Up @@ -125,10 +125,10 @@ def test_sync_uses_uv(tmp_path: pathlib.Path) -> None:
@pytest.mark.parametrize(
"pyvenv_cfg",
(
"home = /x\nversion = 3.11.6\n",
"home = /x\nuv = 0.13.1\nversion_info = 3.11.6\n",
"home = /x\nversion_info = 3.11.6.final.0\n",
"version = 3.11.6\nversion_info = 3.11.6.final.0\n",
"home = /x\nversion = 3.13.16\n",
"home = /x\nuv = 0.13.1\nversion_info = 3.13.16\n",
"home = /x\nversion_info = 3.13.16.final.0\n",
"version = 3.13.16\nversion_info = 3.13.16.final.0\n",
),
)
def test_check_ok(tmp_path: pathlib.Path, pyvenv_cfg: str) -> None:
Expand All @@ -137,11 +137,11 @@ def test_check_ok(tmp_path: pathlib.Path, pyvenv_cfg: str) -> None:
with open(f"{tmp_path}/pyvenv.cfg", "w") as f:
f.write(pyvenv_cfg)

assert venv.check(str(tmp_path), "3.11.6") == venv.VenvStatus.OK
assert venv.check(str(tmp_path), "3.13.16") == venv.VenvStatus.OK


@pytest.mark.parametrize(
"pyvenv_cfg", ("version = 3.11.4\n", "version_info = 3.11.4.final.0\n")
"pyvenv_cfg", ("version = 3.13.15\n", "version_info = 3.13.15.final.0\n")
)
def test_check_mismatch(tmp_path: pathlib.Path, pyvenv_cfg: str) -> None:
os.makedirs(f"{tmp_path}/bin")
Expand All @@ -150,5 +150,5 @@ def test_check_mismatch(tmp_path: pathlib.Path, pyvenv_cfg: str) -> None:
f.write(pyvenv_cfg)

assert (
venv.check(str(tmp_path), "3.11.6") == venv.VenvStatus.VERSION_MISMATCH
venv.check(str(tmp_path), "3.13.16") == venv.VenvStatus.VERSION_MISMATCH
)
Loading
Loading