|
7 | 7 |
|
8 | 8 | CONTEXT_REGISTRY = ContextRegistry(default_context=DockerContext()) |
9 | 9 |
|
10 | | -# CONTEXT_REGISTRY.register( |
11 | | -# "astropy/astropy:pkg", |
12 | | -# DockerContext( |
13 | | -# building_data="""#!/usr/bin/env bash |
14 | | -# # Purpose: Build/install the repo (editable) in one or more ASV micromamba envs, then run health checks. |
15 | | -# set -euo pipefail |
16 | | - |
17 | | -# ###### SETUP CODE (NOT TO BE MODIFIED) ###### |
18 | | -# # Loads micromamba, common helpers, and persisted variables from the env stage. |
19 | | -# source /etc/profile.d/asv_utils.sh || true |
20 | | -# source /etc/profile.d/asv_build_vars.sh || true |
21 | | -# eval "$(micromamba shell hook --shell=bash)" |
| 10 | +CONTEXT_REGISTRY.register( |
| 11 | + "astropy/astropy:pkg", |
| 12 | + DockerContext( |
| 13 | + building_data="""#!/usr/bin/env bash |
| 14 | +# Purpose: Build/install the repo (editable) in one or more ASV micromamba envs, then run health checks. |
| 15 | +set -euo pipefail |
22 | 16 |
|
23 | | -# ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
24 | | -# REPO_ROOT="$ROOT_PATH" |
25 | | -# TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
26 | | -# EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
27 | | -# if [[ -z "${TARGET_VERSIONS}" ]]; then |
28 | | -# echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
29 | | -# exit 1 |
30 | | -# fi |
31 | | -# ###### END SETUP CODE ###### |
| 17 | +###### SETUP CODE (NOT TO BE MODIFIED) ###### |
| 18 | +# Loads micromamba, common helpers, and persisted variables from the env stage. |
| 19 | +source /etc/profile.d/asv_utils.sh || true |
| 20 | +source /etc/profile.d/asv_build_vars.sh || true |
32 | 21 |
|
33 | | -# # ----------------------------- |
34 | | -# # Agent guidance (read-first) |
35 | | -# # ----------------------------- |
36 | | -# # GOAL: For each Python version below, install the project in EDITABLE mode into env asv_{version}, |
37 | | -# # with NO build isolation, then run health checks. |
38 | | -# # |
39 | | -# # Below this comment, you should do whatever is necessary to build the project without errors. Including (but not limited to): |
40 | | -# # - Add extra conda/pip dependencies needed to build this project. |
41 | | -# # - Run repo-specific pre-steps (e.g., submodules, generating Cython, env vars). |
42 | | -# # - Run arbitrary micromamba/pip commands in the target env. |
43 | | -# # - Set CFLAGS/CXXFLAGS/LDFLAGS if needed for this repo. |
44 | | -# # - Change files in the repo if needed (e.g., fix a missing #include). |
45 | | -# # - Anything else needed to get a successful editable install. |
46 | | -# # |
47 | | -# # MUST: |
48 | | -# # - Keep this script idempotent. |
49 | | -# # - Use: `pip install --no-build-isolation -v -e .` or `pip install -e .` or equivalent. |
50 | | -# # - Do not modify the SETUP CODE or helper functions below. |
51 | | -# # |
52 | | -# # DO NOT: |
53 | | -# # - Change env names or Python versions outside MODEL EDIT AREA. |
54 | | -# # - Use build isolation unless absolutely necessary. |
| 22 | +ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
| 23 | +REPO_ROOT="$ROOT_PATH" |
| 24 | +TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 25 | +EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
| 26 | +if [[ -z "${TARGET_VERSIONS}" ]]; then |
| 27 | + echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | +###### END SETUP CODE ###### |
55 | 31 |
|
56 | | -# # ----------------------------- |
57 | | -# # Helpers (do not modify) |
58 | | -# # ----------------------------- |
59 | | -# log() { printf "\033[1;34m[build]\033[0m %s\n" "$*"; } |
60 | | -# warn() { printf "\033[1;33m[warn]\033[0m %s\n" "$*" >&2; } |
61 | | -# die() { printf "\033[1;31m[fail]\033[0m %s\n" "$*" >&2; exit 1; } |
| 32 | +# ----------------------------- |
| 33 | +# Agent guidance (read-first) |
| 34 | +# ----------------------------- |
| 35 | +# GOAL: For each Python version below, install the project in EDITABLE mode into env asv_{version}, |
| 36 | +# with NO build isolation, then run health checks. |
| 37 | +# |
| 38 | +# Below this comment, you should do whatever is necessary to build the project without errors. Including (but not limited to): |
| 39 | +# - Add extra conda/pip dependencies needed to build this project. |
| 40 | +# - Run repo-specific pre-steps (e.g., submodules, generating Cython, env vars). |
| 41 | +# - Run arbitrary micromamba/pip commands in the target env. |
| 42 | +# - Set CFLAGS/CXXFLAGS/LDFLAGS if needed for this repo. |
| 43 | +# - Change files in the repo if needed (e.g., fix a missing #include). |
| 44 | +# - Anything else needed to get a successful editable install. |
| 45 | +# |
| 46 | +# MUST: |
| 47 | +# - Keep this script idempotent. |
| 48 | +# - Use: `pip install --no-build-isolation -v -e .` or `pip install -e .` or equivalent. |
| 49 | +# - Do not modify the SETUP CODE or helper functions below. |
| 50 | +# |
| 51 | +# DO NOT: |
| 52 | +# - Change env names or Python versions outside MODEL EDIT AREA. |
| 53 | +# - Use build isolation unless absolutely necessary. |
62 | 54 |
|
63 | | -# # Conservative default parallelism (override if the repo benefits) |
64 | | -# export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-2}" |
65 | | -# export NPY_NUM_BUILD_JOBS="${NPY_NUM_BUILD_JOBS:-2}" |
| 55 | +# ----------------------------- |
| 56 | +# Helpers (do not modify) |
| 57 | +# ----------------------------- |
| 58 | +log() { printf "\033[1;34m[build]\033[0m %s\n" "$*"; } |
| 59 | +warn() { printf "\033[1;33m[warn]\033[0m %s\n" "$*" >&2; } |
| 60 | +die() { printf "\033[1;31m[fail]\033[0m %s\n" "$*" >&2; exit 1; } |
66 | 61 |
|
67 | | -# # ----------------------------- |
68 | | -# # Build & test across envs |
69 | | -# # ----------------------------- |
70 | | -# for version in $TARGET_VERSIONS; do |
71 | | -# ENV_NAME="asv_${version}" |
72 | | -# log "==> Building in env: $ENV_NAME (python=$version)" |
| 62 | +# Conservative default parallelism (override if the repo benefits) |
| 63 | +export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-2}" |
| 64 | +export NPY_NUM_BUILD_JOBS="${NPY_NUM_BUILD_JOBS:-2}" |
73 | 65 |
|
74 | | -# if ! micromamba env list | awk '{print $1}' | grep -qx "$ENV_NAME"; then |
75 | | -# die "Env $ENV_NAME not found. Did docker_build_env.sh run?" |
76 | | -# fi |
| 66 | +# ----------------------------- |
| 67 | +# Build & test across envs |
| 68 | +# ----------------------------- |
| 69 | +for version in $TARGET_VERSIONS; do |
| 70 | + ENV_NAME="asv_${version}" |
| 71 | + log "==> Building in env: $ENV_NAME (python=$version)" |
77 | 72 |
|
78 | | -# # Import name resolution (kept simple for the agent) |
79 | | -# IMP="${IMPORT_NAME:-}" |
80 | | -# if [[ -z "$IMP" ]]; then |
81 | | -# if ! IMP="$(asv_detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
82 | | -# die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
83 | | -# fi |
84 | | -# fi |
85 | | -# log "Using import name: $IMP" |
| 73 | + if ! micromamba env list | awk '{print $1}' | grep -qx "$ENV_NAME"; then |
| 74 | + die "Env $ENV_NAME not found. Did docker_build_env.sh run?" |
| 75 | + fi |
86 | 76 |
|
87 | | -# # ----------------------------- |
88 | | -# # MODEL EDIT AREA: repo-specific tweaks (optional) |
89 | | -# # ----------------------------- |
90 | | -# # Examples (uncomment if needed for this repo): |
91 | | -# # |
92 | | -# # log "Updating submodules" |
93 | | -# # git -C "$REPO_ROOT" submodule update --init --recursive |
94 | | -# # |
95 | | -# # log "Installing extra system libs via conda-forge" |
96 | | -# # micromamba install -y -n "$ENV_NAME" -c conda-forge 'openblas' 'blas=*=openblas' 'libopenmp' |
97 | | -# # |
98 | | -# # log "Pre-generating Cython sources" |
99 | | -# # micromamba run -n "$ENV_NAME" python -m cython --version |
100 | | -# # |
101 | | -# # export CFLAGS="${CFLAGS:-}" |
102 | | -# # export CXXFLAGS="${CXXFLAGS:-}" |
103 | | -# # export LDFLAGS="${LDFLAGS:-}" |
104 | | -# # ----------------------------- |
| 77 | + # Import name resolution (kept simple for the agent) |
| 78 | + IMP="${IMPORT_NAME:-}" |
| 79 | + if [[ -z "$IMP" ]]; then |
| 80 | + if ! IMP="$(detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
| 81 | + die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
| 82 | + fi |
| 83 | + fi |
| 84 | + log "Using import name: $IMP" |
105 | 85 |
|
106 | | -# # Install some basic micromamba packages. |
107 | | -# micromamba install -y -n "$ENV_NAME" -c conda-forge git conda mamba "libmambapy<=1.9.9" |
| 86 | + # ----------------------------- |
| 87 | + # MODEL EDIT AREA: repo-specific tweaks (optional) |
| 88 | + # ----------------------------- |
| 89 | + # Examples (uncomment if needed for this repo): |
| 90 | + # |
| 91 | + # log "Updating submodules" |
| 92 | + # git -C "$REPO_ROOT" submodule update --init --recursive |
| 93 | + # |
| 94 | + # log "Installing extra system libs via conda-forge" |
| 95 | + # micromamba install -y -n "$ENV_NAME" -c conda-forge 'openblas' 'blas=*=openblas' 'libopenmp' |
| 96 | + # |
| 97 | + # log "Pre-generating Cython sources" |
| 98 | + # micromamba run -n "$ENV_NAME" python -m cython --version |
| 99 | + # |
| 100 | + # export CFLAGS="${CFLAGS:-}" |
| 101 | + # export CXXFLAGS="${CXXFLAGS:-}" |
| 102 | + # export LDFLAGS="${LDFLAGS:-}" |
| 103 | + # ----------------------------- |
108 | 104 |
|
109 | | -# export CFLAGS="${CFLAGS:-} -Wno-error=incompatible-pointer-types" |
110 | | -# micromamba run -n "$ENV_NAME" pip install -e . scipy matplotlib |
| 105 | + # Install some generic packages needed for building/testing. |
| 106 | + # Libmambapy must be < 2 avoid issues running airspeed-velocity. |
| 107 | + micromamba install -y -n "$ENV_NAME" -c conda-forge pip git conda mamba "libmambapy<=1.9.9" \ |
| 108 | + "numpy<2" scipy "cython<2" joblib fakeredis threadpoolctl pytest \ |
| 109 | + compilers meson-python cmake ninja pkg-config tomli extension-helpers |
| 110 | + export CFLAGS="${CFLAGS:-} -Wno-error=incompatible-pointer-types" |
111 | 111 |
|
112 | | -# # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
113 | | -# # $EXTRAS is an optional argument to install all discovered extra dependencies. |
114 | | -# # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
115 | | -# # In case setup.py is used, no need to append $EXTRAS. |
116 | | -# log "Editable install with --no-build-isolation" |
117 | | -# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
| 112 | + # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
| 113 | + # $EXTRAS is an optional argument to install all discovered extra dependencies. |
| 114 | + # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
| 115 | + # In case setup.py is used, no need to append $EXTRAS. |
| 116 | + log "Editable install with --no-build-isolation" |
| 117 | + PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python setup.py develop |
118 | 118 |
|
119 | | -# # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
120 | | -# log "Running smoke checks" |
121 | | -# micromamba run -n "$ENV_NAME" asv_smokecheck.py --import-name "$IMP" --repo-root "$REPO_ROOT" ${RUN_PYTEST_SMOKE:+--pytest-smoke} |
| 119 | + # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
| 120 | + log "Running smoke checks" |
| 121 | + micromamba run -n "$ENV_NAME" asv_smokecheck.py --import-name "$IMP" --repo-root "$REPO_ROOT" ${RUN_PYTEST_SMOKE:+--pytest-smoke} |
122 | 122 |
|
123 | | -# # Machine-readable markers (useful in logs) |
124 | | -# echo "::import_name=${IMP}::env=${ENV_NAME}" |
125 | | -# done |
| 123 | + echo "::import_name=${IMP}::env=${ENV_NAME}" |
| 124 | +done |
126 | 125 |
|
127 | | -# log "All builds complete ✅" |
128 | | -# """.strip(), |
129 | | -# ), |
130 | | -# ) |
| 126 | +log "All builds complete ✅" |
| 127 | +""".strip(), |
| 128 | + ), |
| 129 | +) |
131 | 130 |
|
132 | 131 | CONTEXT_REGISTRY.register( |
133 | 132 | "scikit-learn/scikit-learn:pkg", |
|
200 | 199 | # Import name resolution (kept simple for the agent) |
201 | 200 | IMP="${IMPORT_NAME:-}" |
202 | 201 | if [[ -z "$IMP" ]]; then |
203 | | - if ! IMP="$(asv_detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
| 202 | + if ! IMP="$(detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
204 | 203 | die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
205 | 204 | fi |
206 | 205 | fi |
|
321 | 320 | # Import name resolution (kept simple for the agent) |
322 | 321 | IMP="${IMPORT_NAME:-}" |
323 | 322 | if [[ -z "$IMP" ]]; then |
324 | | - if ! IMP="$(asv_detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
| 323 | + if ! IMP="$(detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
325 | 324 | die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
326 | 325 | fi |
327 | 326 | fi |
|
449 | 448 | # Import name resolution (kept simple for the agent) |
450 | 449 | IMP="${IMPORT_NAME:-}" |
451 | 450 | if [[ -z "$IMP" ]]; then |
452 | | - if ! IMP="$(asv_detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
| 451 | + if ! IMP="$(detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
453 | 452 | die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
454 | 453 | fi |
455 | 454 | fi |
|
574 | 573 | # Import name resolution (kept simple for the agent) |
575 | 574 | IMP="${IMPORT_NAME:-}" |
576 | 575 | if [[ -z "$IMP" ]]; then |
577 | | - if ! IMP="$(asv_detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
| 576 | + if ! IMP="$(detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
578 | 577 | die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
579 | 578 | fi |
580 | 579 | fi |
|
699 | 698 | # # Import name resolution (kept simple for the agent) |
700 | 699 | # IMP="${IMPORT_NAME:-}" |
701 | 700 | # if [[ -z "$IMP" ]]; then |
702 | | -# if ! IMP="$(asv_detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
| 701 | +# if ! IMP="$(detect_import_name --repo-root "$REPO_ROOT" 2>/dev/null)"; then |
703 | 702 | # die "Could not determine import name. Set IMPORT_NAME in /etc/profile.d/asv_build_vars.sh" |
704 | 703 | # fi |
705 | 704 | # fi |
|
0 commit comments