|
23 | 23 | # ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
24 | 24 | # REPO_ROOT="$ROOT_PATH" |
25 | 25 | # TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 26 | +# EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
26 | 27 | # if [[ -z "${TARGET_VERSIONS}" ]]; then |
27 | 28 | # echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
28 | 29 | # exit 1 |
|
109 | 110 | # micromamba run -n "$ENV_NAME" pip install -e . scipy matplotlib |
110 | 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. |
112 | 116 | # log "Editable install with --no-build-isolation" |
113 | | -# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT" |
| 117 | +# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
114 | 118 |
|
115 | 119 | # # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
116 | 120 | # log "Running smoke checks" |
|
141 | 145 | ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
142 | 146 | REPO_ROOT="$ROOT_PATH" |
143 | 147 | TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 148 | +EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
144 | 149 | if [[ -z "${TARGET_VERSIONS}" ]]; then |
145 | 150 | echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
146 | 151 | exit 1 |
|
226 | 231 | micromamba run -n "$ENV_NAME" pip install meson-python cython |
227 | 232 |
|
228 | 233 | # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
| 234 | + # $EXTRAS is an optional argument to install all discovered extra dependencies. |
| 235 | + # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
| 236 | + # In case setup.py is used, no need to append $EXTRAS. |
229 | 237 | log "Editable install with --no-build-isolation" |
230 | | - PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT" |
| 238 | + PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
231 | 239 |
|
232 | 240 | # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
233 | 241 | log "Running smoke checks" |
|
258 | 266 | ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
259 | 267 | REPO_ROOT="$ROOT_PATH" |
260 | 268 | TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 269 | +EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
261 | 270 | if [[ -z "${TARGET_VERSIONS}" ]]; then |
262 | 271 | echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
263 | 272 | exit 1 |
|
344 | 353 | export CFLAGS="${CFLAGS:-} -Wno-error=incompatible-pointer-types" |
345 | 354 |
|
346 | 355 | # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
| 356 | + # $EXTRAS is an optional argument to install all discovered extra dependencies. |
| 357 | + # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
| 358 | + # In case setup.py is used, no need to append $EXTRAS. |
347 | 359 | log "Editable install with --no-build-isolation" |
348 | | - PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT" |
| 360 | + PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
349 | 361 |
|
350 | 362 | # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
351 | 363 | log "Running smoke checks" |
|
377 | 389 | ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
378 | 390 | REPO_ROOT="$ROOT_PATH" |
379 | 391 | TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 392 | +EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
380 | 393 | if [[ -z "${TARGET_VERSIONS}" ]]; then |
381 | 394 | echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
382 | 395 | exit 1 |
|
469 | 482 | micromamba run -n "$ENV_NAME" python "${ROOT_PATH}/build_lib.py" |
470 | 483 |
|
471 | 484 | # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
| 485 | + # $EXTRAS is an optional argument to install all discovered extra dependencies. |
| 486 | + # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
| 487 | + # In case setup.py is used, no need to append $EXTRAS. |
472 | 488 | log "Editable install with --no-build-isolation" |
473 | | - PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT" |
| 489 | + PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
474 | 490 |
|
475 | 491 | # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
476 | 492 | log "Running smoke checks" |
|
503 | 519 | ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
504 | 520 | REPO_ROOT="$ROOT_PATH" |
505 | 521 | TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 522 | +EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
506 | 523 | if [[ -z "${TARGET_VERSIONS}" ]]; then |
507 | 524 | echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
508 | 525 | exit 1 |
|
590 | 607 | fi |
591 | 608 |
|
592 | 609 | # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
| 610 | + # $EXTRAS is an optional argument to install all discovered extra dependencies. |
| 611 | + # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
| 612 | + # In case setup.py is used, no need to append $EXTRAS. |
593 | 613 | log "Editable install with --no-build-isolation" |
594 | | - PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT" |
| 614 | + PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
595 | 615 |
|
596 | 616 | # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1) |
597 | 617 | log "Running smoke checks" |
|
624 | 644 | # ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo |
625 | 645 | # REPO_ROOT="$ROOT_PATH" |
626 | 646 | # TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}" |
| 647 | +# EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}" |
627 | 648 | # if [[ -z "${TARGET_VERSIONS}" ]]; then |
628 | 649 | # echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2 |
629 | 650 | # exit 1 |
|
715 | 736 | # cd "$working_dir" || exit 1 |
716 | 737 | # else |
717 | 738 | # # Editable install (no build isolation preferrably). Toolchain lives in the env already. |
| 739 | +# # $EXTRAS is an optional argument to install all discovered extra dependencies. |
| 740 | +# # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies]. |
| 741 | +# # In case setup.py is used, no need to append $EXTRAS. |
718 | 742 | # log "Editable install with --no-build-isolation" |
719 | | -# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT" |
| 743 | +# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS |
720 | 744 | # fi |
721 | 745 |
|
722 | 746 |
|
|
734 | 758 | # ) |
735 | 759 |
|
736 | 760 |
|
737 | | -# if __name__ == "__main__": |
738 | | -# from pathlib import Path |
739 | | - |
740 | | -# CONTEXT_REGISTRY.save_to_file(Path("scratch/context_registry_init.json")) |
741 | | -# # for each context, build an image with the context. |
742 | | -# import docker |
743 | | - |
744 | | -# from datasmith.docker.context import ContextRegistry, DockerContext, Task |
745 | | - |
746 | | -# client = docker.from_env() |
747 | | - |
748 | | -# import concurrent.futures |
749 | | - |
750 | | -# fails = dict() |
751 | | - |
752 | | -# def build_context(task_context): |
753 | | -# task, context = task_context |
754 | | -# if not task.sha: |
755 | | -# import requests |
756 | | - |
757 | | -# resp = requests.get(f"https://api.github.com/repos/{task.owner}/{task.repo}") |
758 | | -# resp.raise_for_status() |
759 | | -# commit_sha = resp.json().get("default_branch", "main") |
760 | | -# task = Task(owner=task.owner, repo=task.repo, sha=commit_sha, tag=task.tag) |
761 | | -# print(f"Building image for {task.get_image_name()} at {task.sha}") |
762 | | -# res = context.build_container_streaming( |
763 | | -# client=client, |
764 | | -# image_name=task.get_image_name(), |
765 | | -# build_args={ |
766 | | -# "REPO_URL": f"https://www.github.com/{task.owner}/{task.repo}", |
767 | | -# "COMMIT_SHA": task.sha, # pyright: ignore[reportArgumentType] |
768 | | -# }, |
769 | | -# force=True, |
770 | | -# timeout_s=1200, |
771 | | -# pull=True, |
772 | | -# ) |
773 | | -# return (task, res) |
774 | | - |
775 | | -# with concurrent.futures.ProcessPoolExecutor() as executor: |
776 | | -# futures = {executor.submit(build_context, item): item[0] for item in CONTEXT_REGISTRY.registry.items()} |
777 | | -# for future in concurrent.futures.as_completed(futures): |
778 | | -# task = futures[future] |
779 | | -# try: |
780 | | -# task, res = future.result() |
781 | | -# if res.ok: |
782 | | -# print(f"Built image {task.get_image_name()} successfully") |
783 | | -# else: |
784 | | -# print(f"Failed to build image {task.get_image_name()}") |
785 | | -# fails[task] = res |
786 | | -# except Exception as exc: |
787 | | -# print(f"Exception building image {task.get_image_name()}: {exc}") |
788 | | -# fails[task] = exc |
789 | | - |
790 | | -# if fails: |
791 | | -# import IPython |
792 | | - |
793 | | -# IPython.embed() |
| 761 | +if __name__ == "__main__": |
| 762 | + from pathlib import Path |
| 763 | + |
| 764 | + CONTEXT_REGISTRY.save_to_file(Path("scratch/context_registry_init.json")) |
| 765 | + # # for each context, build an image with the context. |
| 766 | + # import docker |
| 767 | + |
| 768 | + # from datasmith.docker.context import ContextRegistry, DockerContext, Task |
| 769 | + |
| 770 | + # client = docker.from_env() |
| 771 | + |
| 772 | + # import concurrent.futures |
| 773 | + |
| 774 | + # fails = dict() |
| 775 | + |
| 776 | + # def build_context(task_context): |
| 777 | + # task, context = task_context |
| 778 | + # if not task.sha: |
| 779 | + # import requests |
| 780 | + |
| 781 | + # resp = requests.get(f"https://api.github.com/repos/{task.owner}/{task.repo}") |
| 782 | + # resp.raise_for_status() |
| 783 | + # commit_sha = resp.json().get("default_branch", "main") |
| 784 | + # task = Task(owner=task.owner, repo=task.repo, sha=commit_sha, tag=task.tag) |
| 785 | + # print(f"Building image for {task.get_image_name()} at {task.sha}") |
| 786 | + # res = context.build_container_streaming( |
| 787 | + # client=client, |
| 788 | + # image_name=task.get_image_name(), |
| 789 | + # build_args={ |
| 790 | + # "REPO_URL": f"https://www.github.com/{task.owner}/{task.repo}", |
| 791 | + # "COMMIT_SHA": task.sha, # pyright: ignore[reportArgumentType] |
| 792 | + # }, |
| 793 | + # force=True, |
| 794 | + # timeout_s=1200, |
| 795 | + # pull=True, |
| 796 | + # ) |
| 797 | + # return (task, res) |
| 798 | + |
| 799 | + # with concurrent.futures.ProcessPoolExecutor() as executor: |
| 800 | + # futures = {executor.submit(build_context, item): item[0] for item in CONTEXT_REGISTRY.registry.items()} |
| 801 | + # for future in concurrent.futures.as_completed(futures): |
| 802 | + # task = futures[future] |
| 803 | + # try: |
| 804 | + # task, res = future.result() |
| 805 | + # if res.ok: |
| 806 | + # print(f"Built image {task.get_image_name()} successfully") |
| 807 | + # else: |
| 808 | + # print(f"Failed to build image {task.get_image_name()}") |
| 809 | + # fails[task] = res |
| 810 | + # except Exception as exc: |
| 811 | + # print(f"Exception building image {task.get_image_name()}: {exc}") |
| 812 | + # fails[task] = exc |
| 813 | + |
| 814 | + # if fails: |
| 815 | + # import IPython |
| 816 | + |
| 817 | + # IPython.embed() |
0 commit comments