diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index c913e605..3a18c949 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -44,6 +44,7 @@ jobs: steps: - name: Checkout code + # Do not change this to v5 until cirun can handle node v24 uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Build on Linux diff --git a/recipe/build-core.bat b/recipe/build-core.bat index e4f5f522..9a1867f5 100644 --- a/recipe/build-core.bat +++ b/recipe/build-core.bat @@ -27,6 +27,12 @@ echo %CONDA_PREFIX% python -c "import os; print('\n'.join(os.environ['PATH'].split(';')))" echo ---------- +echo ======================================== +echo Fix up the sha in python/ray/_version.py +echo ======================================== +"%PYTHON%" "%RECIPE_DIR%/fixup_sha.py" python/ray/_version.py "%PKG_VERSION%" + + echo ========================================================== echo calling pip to install echo ========================================================== diff --git a/recipe/build-core.sh b/recipe/build-core.sh index 6863ea18..2ecc754c 100644 --- a/recipe/build-core.sh +++ b/recipe/build-core.sh @@ -49,6 +49,11 @@ echo '---------------- .bazelrc --------------------------' cat .bazelrc echo '----------------------------------------------------' +echo ======================================== +echo Fix up the sha in python/ray/_version.py +echo ======================================== +python3 ${RECIPE_DIR}/fixup_sha.py python/ray/_version.py ${PKG_VERSION} + cd python/ export SKIP_THIRDPARTY_INSTALL_CONDA_FORGE=1 diff --git a/recipe/fixup_sha.py b/recipe/fixup_sha.py new file mode 100644 index 00000000..410f9bea --- /dev/null +++ b/recipe/fixup_sha.py @@ -0,0 +1,56 @@ +# Call like python3 __file__ python/ray/_version.py 2.49.2 + +import json +import os +import sys +import time +from urllib.request import HTTPError, urlopen + + +def get_commit_sha(ver: str) -> str: + """ + Return sha from version tag commit. + + Use retry information in headers and exponential backoff to address rate limiting issues. + See: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit + """ + exp_backoff = 60 + retry_count = 0 + while True: + try: + content = urlopen( + f"https://api.github.com/repos/ray-project/ray/git/ref/tags/ray-{ver}" + ).read() + return json.loads(content)["object"]["sha"] + except HTTPError as e: + if retry_count < 10: + if (e.code == 403 and e.msg == "rate limit exceeded") or e.code == 429: + retry_count += 1 + timeout = exp_backoff + if "retry-after" in e.hdrs: + timeout = int(e.hdrs["retry-after"]) + elif e.hdrs.get("x-ratelimit-remaining", None) == "0": + timeout = max(int(e.hdrs["x-ratelimit-reset"]) - time.time(), 0) + else: + exp_backoff *= 1.5 + print(f"{e}:, retrying after {timeout} s", file=sys.stderr) + time.sleep(timeout) + continue + raise + + +versionpy = sys.argv[1] +ver = sys.argv[2] + +assert os.path.exists(versionpy) + +with open(versionpy, "r") as fid: + txt = fid.read() + +sha = get_commit_sha(ver) + +txt = txt.replace("{{RAY_COMMIT_SHA}}", sha) +assert f'version = "{ver}"' in txt +assert f'commit = "{sha}"' in txt +with open(versionpy, "w") as fid: + fid.write(txt) diff --git a/recipe/patches/0004-update-commit-sha.patch b/recipe/patches/0004-update-commit-sha.patch deleted file mode 100644 index 0161fe34..00000000 --- a/recipe/patches/0004-update-commit-sha.patch +++ /dev/null @@ -1,23 +0,0 @@ -From dec76249e3ccd2d636b80d84a52896c20ea4fc89 Mon Sep 17 00:00:00 2001 -From: Matti Picus -Date: Thu, 28 Aug 2025 23:52:06 +0300 -Subject: [PATCH 04/11] update-commit-sha.patch - ---- - python/ray/_version.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/python/ray/_version.py b/python/ray/_version.py -index b8896ef218..64d5291380 100644 ---- a/python/ray/_version.py -+++ b/python/ray/_version.py -@@ -1,5 +1,5 @@ - # Replaced with the current commit when building the wheels. --commit = "{{RAY_COMMIT_SHA}}" -+commit = "c057f1ea836f3e93f110e895029caa32136fc156" - version = "2.49.0" - - if __name__ == "__main__": --- -2.39.5 (Apple Git-154) - diff --git a/recipe/recipe.yaml b/recipe/recipe.yaml index a6038033..dade7384 100644 --- a/recipe/recipe.yaml +++ b/recipe/recipe.yaml @@ -15,8 +15,6 @@ source: - patches/0001-Disable-making-entry-scripts.patch - patches/0002-Ignore-warnings-in-event.cc-and-logging.cc.patch - patches/0003-Newer-hermetic-python.patch - # This needs modification for each release - - patches/0004-update-commit-sha.patch # See https://github.com/conda-forge/ray-packages-feedstock/issues/136 # Keep in sync with current or active migration of libgrpc to avoid # ABI breakage @@ -35,7 +33,8 @@ source: - patches/0012-No-path-isolation.patch build: - number: 0 + number: 2 + outputs: - package: