Files
langflow/scripts/ci/update_lfx_version.py
Eric Hare e555e470d9 fix: Cherry-pick nightly SDK build fixes to main (#12491)
* fix: Build and install the langflow-sdk for lfx (fixes nightly) (#12481)

* fix: Build and install the langflow-sdk for lfx

* Publish sdk as a nightly

* Update ci.yml

* Update python_test.yml

* Update ci.yml

* fix: Properly grep for the langflow version (#12486)

* fix: Properly grep for the langflow version

* Mount the sdk where needed

* Skip the sdk

* [autofix.ci] apply automated fixes

* Update setup.py

* fix(docker): Remove broken npm self-upgrade from Docker images (#12309)

* fix: replace grep -oP with sed for Node.js version extraction in Docker builds (#12331)

The grep -oP (PCRE regex) command fails in the python:3.12.12-slim-trixie
Docker base image because PCRE support is not available in the slim variant.

This replaces grep -oP with portable sed -nE in all 5 Dockerfiles and adds
an empty version guard to fail fast with a clear error message instead of
producing a broken download URL.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com>
Co-authored-by: vjgit96 <vijay.katuri@ibm.com>
2026-04-03 14:25:33 -04:00

96 lines
3.0 KiB
Python

"""Script to update LFX version for nightly builds."""
import re
import sys
from pathlib import Path
from update_pyproject_name import update_pyproject_name
from update_pyproject_version import update_pyproject_version
# Add the current directory to the path so we can import the other scripts
current_dir = Path(__file__).resolve().parent
sys.path.append(str(current_dir))
BASE_DIR = Path(__file__).parent.parent.parent
def update_lfx_workspace_dep(pyproject_path: str, new_project_name: str) -> None:
"""Update the LFX workspace dependency in pyproject.toml."""
filepath = BASE_DIR / pyproject_path
content = filepath.read_text(encoding="utf-8")
if new_project_name == "lfx-nightly":
pattern = re.compile(r"lfx = \{ workspace = true \}")
replacement = "lfx-nightly = { workspace = true }"
else:
msg = f"Invalid LFX project name: {new_project_name}"
raise ValueError(msg)
# Updates the dependency name for uv
if not pattern.search(content):
msg = f"lfx workspace dependency not found in {filepath}"
raise ValueError(msg)
content = pattern.sub(replacement, content)
filepath.write_text(content, encoding="utf-8")
def update_sdk_dependency_in_lfx(pyproject_path: str, sdk_version: str) -> None:
"""Update the SDK dependency in the LFX pyproject for nightly builds."""
filepath = BASE_DIR / pyproject_path
content = filepath.read_text(encoding="utf-8")
pattern = re.compile(r'"langflow-sdk(?:-nightly)?(?:==|~=|>=)[\d.]+(?:\.(?:post|dev|a|b|rc)\d+)*"')
replacement = f'"langflow-sdk-nightly=={sdk_version}"'
if not pattern.search(content):
msg = f"SDK dependency not found in {filepath}"
raise ValueError(msg)
content = pattern.sub(replacement, content)
filepath.write_text(content, encoding="utf-8")
def update_lfx_for_nightly(lfx_tag: str, sdk_tag: str):
"""Update LFX package for nightly build.
Args:
lfx_tag: The nightly tag for LFX (e.g., "v0.1.0.dev0")
sdk_tag: The nightly tag for the SDK (e.g., "v0.1.0.dev0")
"""
lfx_pyproject_path = "src/lfx/pyproject.toml"
# Update name to lfx-nightly
update_pyproject_name(lfx_pyproject_path, "lfx-nightly")
# Update version (strip 'v' prefix if present)
version = lfx_tag.lstrip("v")
update_pyproject_version(lfx_pyproject_path, version)
# Update workspace dependency in root pyproject.toml
update_lfx_workspace_dep("pyproject.toml", "lfx-nightly")
sdk_version = sdk_tag.lstrip("v")
update_sdk_dependency_in_lfx(lfx_pyproject_path, sdk_version)
print(f"Updated LFX package to lfx-nightly version {version}")
def main():
"""Update LFX for nightly builds.
Usage:
update_lfx_version.py <lfx_tag> <sdk_tag>
"""
expected_args = 3
if len(sys.argv) != expected_args:
print("Usage: update_lfx_version.py <lfx_tag> <sdk_tag>")
sys.exit(1)
lfx_tag = sys.argv[1]
sdk_tag = sys.argv[2]
update_lfx_for_nightly(lfx_tag, sdk_tag)
if __name__ == "__main__":
main()