chore: uv to replace poetry (#3900)

* uv sync works

* fist stab at Makefile

* uv treatment for langflow-base

* sqlmodel to 0.0.18

* add reinstall_backend to Makefile

* makefile - reinstall_backend fix and unit_test dependency

* fix dev dependencies

* fix dev dependencies

* fix dev dependencies

* lock

* Makefile

* [autofix.ci] apply automated fixes

* Update Makefile

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* delete update_dependencies

* fix lint

* Remove Poetry lock check from GitHub Actions workflow

* Switch to 'uv' for dependency management and caching in style-check workflow

* Update style-check workflow to use '--only-dev' flag for Ruff check

* Integrate 'uv' package setup and caching in GitHub Actions workflows

* Update version check in GitHub Actions to use 'uv tree' for langflow-base

* Remove redundant poetry environment setup in GitHub Actions workflow

* Add step to minimize uv cache in GitHub Actions workflow

* Update GitHub Actions workflow to use 'uv' for dependency management and caching

* Remove redundant script execution from build_langflow target in Makefile

* [autofix.ci] apply automated fixes

* Switch build system from Poetry to Hatchling and update dependencies

- Replace `poetry-core` with `hatchling` in build-system requirements
- Update `langflow-base` dependency to version `0.0.96`
- Add `tool.hatch.build.targets.wheel` configuration
- Adjust `tool.uv.sources` paths for `langflow-frontend` and `langflow-base`

* update lock

* Switch build system from Poetry to Hatchling in pyproject.toml

* Add langchain-unstructured dependency to pyproject.toml

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Sebastián Estévez 2024-09-25 16:40:30 -04:00 committed by GitHub
commit fbb097dc4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 14382 additions and 199 deletions

View file

@ -1,82 +0,0 @@
import re
from pathlib import Path
def read_version_from_pyproject(file_path):
with open(file_path, "r") as file:
for line in file:
match = re.search(r'version = "(.*)"', line)
if match:
return match.group(1)
return None
# def get_version_from_pypi(package_name):
# import requests
# response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
# if response.ok:
# return response.json()["info"]["version"]
# return None
def get_version_from_pypi(package_name):
# Use default python lib to make the GET for this because it runs in github actions
import json
import urllib.request
response = urllib.request.urlopen(f"https://pypi.org/pypi/{package_name}/json")
if response.getcode() == 200:
return json.loads(response.read())["info"]["version"]
return None
def is_development_release(version):
"""
Determines if the version is a development version based on PEP 440.
We consider a development version (.devN) as our nightly versions
"""
return "dev" in version
def update_pyproject_dependency(pyproject_path, version, is_nightly):
# Strip "v" prefix from version if present
if version.startswith("v"):
version = version[1:]
pattern = re.compile(r'langflow-base = \{ path = "\./src/backend/base", develop = true \}')
if is_nightly:
# NOTE: This process can be simplified; see the note in update_lf_base_dependency.py
replacement = f'langflow-base-nightly = "{version}"'
else:
replacement = f'langflow-base = "^{version}"'
with open(pyproject_path, "r") as file:
content = file.read()
content = pattern.sub(replacement, content)
with open(pyproject_path, "w") as file:
file.write(content)
if __name__ == "__main__":
# Backing up files
pyproject_path = Path(__file__).resolve().parent / "../pyproject.toml"
pyproject_path = pyproject_path.resolve()
with open(pyproject_path, "r") as original, open(pyproject_path.with_name("pyproject.toml.bak"), "w") as backup:
backup.write(original.read())
# Now backup poetry.lock
with open(pyproject_path.with_name("poetry.lock"), "r") as original, open(
pyproject_path.with_name("poetry.lock.bak"), "w"
) as backup:
backup.write(original.read())
# Reading version and updating pyproject.toml
langflow_base_path = Path(__file__).resolve().parent / "../src/backend/base/pyproject.toml"
version = read_version_from_pyproject(langflow_base_path)
if version:
# Nightly versions contain "dev"
# WARNING: This will cause issues if we release `.dev` versions to `langflow` or `langflow-base`
is_nightly = is_development_release(version)
update_pyproject_dependency(pyproject_path, version, is_nightly)
else:
print("Error: Version not found.")