Browse Source

devenv: move install-py-dev to sync (#73992)

This moves `install-py-dev` over to devenv sync.
joshuarli 7 months ago
parent
commit
f54bf2b72e
3 changed files with 59 additions and 46 deletions
  1. 4 8
      Makefile
  2. 55 2
      devenv/sync.py
  3. 0 36
      scripts/lib.sh

+ 4 - 8
Makefile

@@ -13,6 +13,7 @@ bootstrap:
 	@echo "you probably want to run devenv sync to bring the"
 	@echo "sentry dev environment up to date!"
 
+build-platform-assets \
 clean \
 init-config \
 run-dependent-services \
@@ -21,11 +22,11 @@ create-db \
 apply-migrations \
 reset-db \
 node-version-check \
-install-js-dev \
-install-py-dev :
+install-js-dev :
 	@./scripts/do.sh $@
 
-develop:
+develop \
+install-py-dev :
 	@make devenv-sync
 
 # This is to ensure devenv sync's only called once if the above
@@ -34,11 +35,6 @@ develop:
 devenv-sync:
 	devenv sync
 
-build-platform-assets \
-direnv-help \
-upgrade-pip :
-	@SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh $@
-
 build-js-po: node-version-check
 	mkdir -p build
 	rm -rf node_modules/.cache/babel-loader

+ 55 - 2
devenv/sync.py

@@ -111,6 +111,46 @@ def main(context: dict[str, str]) -> int:
             # this is needed for devenv <=1.4.0,>1.2.3 to finish syncing and therefore update itself
             limactl.install()
 
+    if not run_procs(
+        repo,
+        reporoot,
+        venv_dir,
+        (
+            # TODO: devenv should provide a job runner (jobs run in parallel, tasks run sequentially)
+            (
+                "python dependencies (1/4)",
+                (
+                    # upgrading pip first
+                    "pip",
+                    "install",
+                    "--constraint",
+                    "requirements-dev-frozen.txt",
+                    "pip",
+                ),
+            ),
+        ),
+    ):
+        return 1
+
+    if not run_procs(
+        repo,
+        reporoot,
+        venv_dir,
+        (
+            (
+                "python dependencies (2/4)",
+                (
+                    "pip",
+                    "uninstall",
+                    "-qqy",
+                    "djangorestframework-stubs",
+                    "django-stubs",
+                ),
+            ),
+        ),
+    ):
+        return 1
+
     if not run_procs(
         repo,
         reporoot,
@@ -119,7 +159,17 @@ def main(context: dict[str, str]) -> int:
             ("javascript dependencies", ("make", "install-js-dev")),
             # could opt out of syncing python if FRONTEND_ONLY but only if repo-local devenv
             # and pre-commit were moved to inside devenv and not the sentry venv
-            ("python dependencies", ("make", "install-py-dev")),
+            (
+                "python dependencies (3/4)",
+                (
+                    "pip",
+                    "install",
+                    "--constraint",
+                    "requirements-dev-frozen.txt",
+                    "-r",
+                    "requirements-dev-frozen.txt",
+                ),
+            ),
         ),
     ):
         return 1
@@ -128,7 +178,10 @@ def main(context: dict[str, str]) -> int:
         repo,
         reporoot,
         venv_dir,
-        (("pre-commit dependencies", ("pre-commit", "install", "--install-hooks", "-f")),),
+        (
+            ("python dependencies (4/4)", ("python3", "-m", "tools.fast_editable", "--path", ".")),
+            ("pre-commit dependencies", ("pre-commit", "install", "--install-hooks", "-f")),
+        ),
     ):
         return 1
 

+ 0 - 36
scripts/lib.sh

@@ -78,30 +78,6 @@ sudo-askpass() {
     fi
 }
 
-pip-install() {
-    pip install --constraint "${HERE}/../requirements-dev-frozen.txt" "$@"
-}
-
-upgrade-pip() {
-    pip-install pip
-}
-
-install-py-dev() {
-    upgrade-pip
-    # It places us within top src dir to be at the same path as setup.py
-    # This helps when getsentry calls into this script
-    cd "${HERE}/.." || exit
-
-    echo "--> Installing Sentry (for development)"
-
-    # pip doesn't do well with swapping drop-ins
-    pip uninstall -qqy djangorestframework-stubs django-stubs
-
-    pip-install -r requirements-dev-frozen.txt
-
-    python3 -m tools.fast_editable --path .
-}
-
 node-version-check() {
     # Checks to see if node's version matches the one specified in package.json for Volta.
     node -pe "process.exit(Number(!(process.version == 'v' + require('./.volta.json').volta.node )))" ||
@@ -194,15 +170,3 @@ reset-db() {
     create-superuser
     echo 'Finished resetting database. To load mock data, run `./bin/load-mocks`'
 }
-
-direnv-help() {
-    cat >&2 <<EOF
-If you're a Sentry employee and you're stuck or have questions, ask in #discuss-dev-infra.
-If you're not, please file an issue under https://github.com/getsentry/sentry/issues/new/choose and mention @getsentry/owners-sentry-dev
-
-You can configure the behaviour of direnv by adding the following variables to a .env file:
-
-- SENTRY_DIRENV_DEBUG=1: This will allow printing debug messages
-- SENTRY_DEVENV_NO_REPORT=1: Do not report development environment errors to Sentry.io
-EOF
-}