update scripts (todo: fix)

This commit is contained in:
Chester Curme 2025-02-03 12:48:38 -05:00
parent dcbedef4d8
commit 4dcc659f48
2 changed files with 22 additions and 15 deletions

View File

@ -7,6 +7,8 @@ from typing import Dict, List, Set
from pathlib import Path
import tomllib
from packaging.requirements import Requirement
from get_min_versions import get_min_version_from_toml
@ -55,7 +57,9 @@ def dependents_graph() -> dict:
"""
dependents = defaultdict(set)
for path in glob.glob("./libs/**/pyproject.toml", recursive=True):
# for path in glob.glob("./libs/**/pyproject.toml", recursive=True):
# TODO: fix this
for path in ["./libs/langchain/pyproject.toml", "./libs/core/pyproject.toml"]:
if "template" in path:
continue
@ -65,11 +69,13 @@ def dependents_graph() -> dict:
pkg_dir = "libs" + "/".join(path.split("libs")[1].split("/")[:-1])
for dep in [
*pyproject["project"]["dependencies"].keys(),
*pyproject["dependency-groups"]["test"].keys(),
*pyproject["project"]["dependencies"],
*pyproject["dependency-groups"]["test"],
]:
requirement = Requirement(dep)
package_name = requirement.name
if "langchain" in dep:
dependents[dep].add(pkg_dir)
dependents[package_name].add(pkg_dir)
continue
# load extended deps from extended_testing_deps.txt

View File

@ -7,6 +7,7 @@ else:
# for python 3.10 and below, which doesnt have stdlib tomllib
import tomli as tomllib
from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet
from packaging.version import Version
@ -105,7 +106,10 @@ def get_min_version_from_toml(
with open(toml_path, "rb") as file:
toml_data = tomllib.load(file)
dependencies = toml_data["project"]["dependencies"]
dependencies = {}
for dep in toml_data["project"]["dependencies"]:
requirement = Requirement(dep)
dependencies[requirement.name] = requirement
# Initialize a dictionary to store the minimum versions
min_versions = {}
@ -120,17 +124,14 @@ def get_min_version_from_toml(
if lib in dependencies:
if include and lib not in include:
continue
requirement = dependencies[lib]
# TODO: fix this
if requirement.marker and not requirement.marker.evaluate(
{"python_version": python_version}
):
continue
# Get the version string
version_string = dependencies[lib]
if isinstance(version_string, dict):
version_string = version_string["version"]
if isinstance(version_string, list):
version_string = [
vs
for vs in version_string
if check_python_version(python_version, vs["python"])
][0]["version"]
version_string = str(requirement.specifier)
# Use parse_version to get the minimum supported version from version_string
min_version = get_minimum_version(lib, version_string)