Some checks failed
Auto-update / Auto-update (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Nightly Build / validate-inputs (push) Has been cancelled
Nightly Build / resolve-release-branch (push) Has been cancelled
Nightly Build / create-nightly-tag (push) Has been cancelled
Nightly Build / Run Frontend Tests - Linux (push) Has been cancelled
Nightly Build / Run Frontend Tests - Windows (push) Has been cancelled
Nightly Build / Run Backend Unit Tests (push) Has been cancelled
Nightly Build / Run Nightly Langflow Build (push) Has been cancelled
Nightly Build / Send Slack Notification (push) Has been cancelled
Store pytest durations / Run pytest and store durations (push) Has been cancelled
Update OpenAPI Spec / check-openapi-updates (push) Has been cancelled
* 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>
83 lines
3.3 KiB
Python
Executable File
83 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).parent.parent.parent
|
|
ARGUMENT_NUMBER = 3
|
|
|
|
|
|
def update_pyproject_name(pyproject_path: str, new_project_name: str) -> None:
|
|
"""Update the project name in pyproject.toml."""
|
|
filepath = BASE_DIR / pyproject_path
|
|
content = filepath.read_text(encoding="utf-8")
|
|
|
|
# Regex to match the name field only within the [project] section.
|
|
# This avoids replacing 'name' in other sections like [[tool.uv.index]].
|
|
# Pattern matches: [project] + any content (non-greedy) + name = "value"
|
|
pattern = re.compile(r'(\[project\]\s*\n(?:[^\[]*?))(name = ")[^"]+(")', re.DOTALL)
|
|
|
|
if not pattern.search(content):
|
|
msg = f'Project name not found in "{filepath}"'
|
|
raise ValueError(msg)
|
|
content = pattern.sub(rf"\1\g<2>{new_project_name}\3", content)
|
|
|
|
# Update extra references in [complete] and [all] extras for nightly builds
|
|
if new_project_name == "langflow-base-nightly":
|
|
# Replace langflow-base[extra] with langflow-base-nightly[extra] in optional dependencies
|
|
content = re.sub(r'"langflow-base\[([^\]]+)\]"', r'"langflow-base-nightly[\1]"', content)
|
|
elif new_project_name == "langflow-nightly":
|
|
# Replace langflow[extra] with langflow-nightly[extra] in optional dependencies
|
|
content = re.sub(r'"langflow\[([^\]]+)\]"', r'"langflow-nightly[\1]"', content)
|
|
|
|
filepath.write_text(content, encoding="utf-8")
|
|
|
|
|
|
def update_uv_dep(pyproject_path: str, new_project_name: str) -> None:
|
|
"""Update the langflow-base dependency in pyproject.toml."""
|
|
filepath = BASE_DIR / pyproject_path
|
|
content = filepath.read_text(encoding="utf-8")
|
|
|
|
if new_project_name == "langflow-nightly":
|
|
pattern = re.compile(r"langflow = \{ workspace = true \}")
|
|
replacement = "langflow-nightly = { workspace = true }"
|
|
elif new_project_name == "langflow-base-nightly":
|
|
pattern = re.compile(r"langflow-base = \{ workspace = true \}")
|
|
replacement = "langflow-base-nightly = { workspace = true }"
|
|
elif new_project_name == "langflow-sdk-nightly":
|
|
pattern = re.compile(r"langflow-sdk = \{ workspace = true \}")
|
|
replacement = "langflow-sdk-nightly = { workspace = true }"
|
|
else:
|
|
msg = f"Invalid project name: {new_project_name}"
|
|
raise ValueError(msg)
|
|
|
|
# Updates the dependency name for uv
|
|
if not pattern.search(content):
|
|
msg = f"{replacement} uv dependency not found in {filepath}"
|
|
raise ValueError(msg)
|
|
content = pattern.sub(replacement, content)
|
|
filepath.write_text(content, encoding="utf-8")
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) != ARGUMENT_NUMBER:
|
|
msg = "Must specify project name and build type, e.g. langflow-nightly base"
|
|
raise ValueError(msg)
|
|
new_project_name = sys.argv[1]
|
|
build_type = sys.argv[2]
|
|
|
|
if build_type == "base":
|
|
update_pyproject_name("src/backend/base/pyproject.toml", new_project_name)
|
|
update_uv_dep("pyproject.toml", new_project_name)
|
|
elif build_type == "main":
|
|
update_pyproject_name("pyproject.toml", new_project_name)
|
|
update_uv_dep("pyproject.toml", new_project_name)
|
|
else:
|
|
msg = f"Invalid build type: {build_type}"
|
|
raise ValueError(msg)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|