Skip to content

dev: add devenv and frozen requirements #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
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
20 changes: 11 additions & 9 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ if [[ -f .env ]]; then
dotenv .env
fi

if [ ! -d .venv ]; then
echo "warning: creating virtualenv for the first time"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
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"

export VIRTUAL_ENV="${PWD}/.venv"

PATH_add "${PWD}/.venv/bin"
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -r requirements-dev-frozen.txt
pip install -e .
- name: Run tests
run: pytest --cov --junitxml=junit.xml -o junit_family=legacy
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: requirements-frozen.txt requirements-dev-frozen.txt

requirements-frozen.txt: requirements.txt
.venv/bin/pip-compile --allow-unsafe --no-annotate --quiet --strip-extras requirements.txt -o requirements-frozen.txt

requirements-dev-frozen.txt: requirements.txt requirements-dev.txt
.venv/bin/pip-compile --allow-unsafe --no-annotate --quiet --strip-extras requirements.txt requirements-dev.txt -o requirements-dev-frozen.txt
19 changes: 19 additions & 0 deletions devenv/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[devenv]
minimum_version = 1.15.0

[venv.venv]
python = 3.12.6
path = .venv
requirements = requirements-dev-frozen.txt
editable =
.

[python3.12.6]
darwin_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240909/cpython-3.12.6+20240909-x86_64-apple-darwin-install_only.tar.gz
darwin_x86_64_sha256 = 8c56da91436bee158b0d592aed3393c1fe3da3694ca35950ee1c52935ba8bfd5
darwin_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240909/cpython-3.12.6+20240909-aarch64-apple-darwin-install_only.tar.gz
darwin_arm64_sha256 = 899f46eb592fcac4e834c064e4c901e8a4a6b5864e80b18efd2f0b7c3c050584
linux_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240909/cpython-3.12.6+20240909-x86_64-unknown-linux-gnu-install_only.tar.gz
linux_x86_64_sha256 = 68ff386c923c59a33a272bd984b8a33fe8117c56ad7f7552e0c2b21937ee3c0b
linux_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240909/cpython-3.12.6+20240909-aarch64-unknown-linux-gnu-install_only.tar.gz
linux_arm64_sha256 = caac1033f68f69d8978dc8c6b6964cfb9d8a111abc55c03403bd4ece63f331f3
24 changes: 24 additions & 0 deletions devenv/sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import annotations

from devenv.lib import config
from devenv.lib import proc
from devenv.lib import venv


def main(context: dict[str, str]) -> int:
reporoot = context["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)

proc.run(("pre-commit", "install", "--install-hooks", "-f"))

return 0
2 changes: 1 addition & 1 deletion pyoxidizer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def make_exe():

# Invoke `pip install` using a requirements file and add the collected resources
# to our binary.
exe.add_python_resources(exe.pip_install(["-r", "requirements.txt"]))
exe.add_python_resources(exe.pip_install(["-r", "requirements-frozen.txt"]))

# Read Python files from a local directory and add them to our embedded
# context, taking just the resources belonging to the `foo` and `bar`
Expand Down
46 changes: 46 additions & 0 deletions requirements-dev-frozen.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate --output-file=requirements-dev-frozen.txt --strip-extras requirements-dev.txt requirements.txt
#
--index-url https://pypi.devinfra.sentry.io/simple

black==24.4.2
build==0.8.0
certifi==2025.1.31
cfgv==3.4.0
click==8.1.8
coverage==7.6.4
distlib==0.3.9
filelock==3.18.0
freezegun==1.2.2
identify==2.6.9
iniconfig==2.0.0
mypy==1.11.2
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging==24.0
pathspec==0.12.1
pep517==0.13.0
pip-tools==7.3.0
platformdirs==4.3.6
pluggy==1.5.0
pre-commit==3.6.0
pytest==8.1.1
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
pyyaml==6.0.1
sentry-devenv==1.8.0
sentry-sdk==2.20.0
six==1.17.0
supervisor==4.2.5
types-pyyaml==6.0.11
typing-extensions==4.13.0
urllib3==2.3.0
virtualenv==20.29.3
wheel==0.42.0

# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
setuptools==70.0.0
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ setuptools==70.0.0
build==0.8.0
wheel==0.42.0
freezegun==1.2.2
pip-tools
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should version be pinned here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version is pinned in the frozen requirements, so not the biggest deal

19 changes: 19 additions & 0 deletions requirements-frozen.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate --output-file=requirements-frozen.txt --strip-extras requirements.txt
#
--index-url https://pypi.devinfra.sentry.io/simple

certifi==2025.1.31
packaging==24.0
pyyaml==6.0.1
sentry-devenv==1.8.0
sentry-sdk==2.20.0
supervisor==4.2.5
typing-extensions==4.13.0
urllib3==2.3.0

# The following packages are considered to be unsafe in a requirements file:
setuptools==78.1.0
Loading