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 from pathlib import Path
import tomllib import tomllib
from packaging.requirements import Requirement
from get_min_versions import get_min_version_from_toml from get_min_versions import get_min_version_from_toml
@ -55,7 +57,9 @@ def dependents_graph() -> dict:
""" """
dependents = defaultdict(set) 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: if "template" in path:
continue continue
@ -65,11 +69,13 @@ def dependents_graph() -> dict:
pkg_dir = "libs" + "/".join(path.split("libs")[1].split("/")[:-1]) pkg_dir = "libs" + "/".join(path.split("libs")[1].split("/")[:-1])
for dep in [ for dep in [
*pyproject["project"]["dependencies"].keys(), *pyproject["project"]["dependencies"],
*pyproject["dependency-groups"]["test"].keys(), *pyproject["dependency-groups"]["test"],
]: ]:
requirement = Requirement(dep)
package_name = requirement.name
if "langchain" in dep: if "langchain" in dep:
dependents[dep].add(pkg_dir) dependents[package_name].add(pkg_dir)
continue continue
# load extended deps from extended_testing_deps.txt # 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 # for python 3.10 and below, which doesnt have stdlib tomllib
import tomli as tomllib import tomli as tomllib
from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet from packaging.specifiers import SpecifierSet
from packaging.version import Version from packaging.version import Version
@ -105,7 +106,10 @@ def get_min_version_from_toml(
with open(toml_path, "rb") as file: with open(toml_path, "rb") as file:
toml_data = tomllib.load(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 # Initialize a dictionary to store the minimum versions
min_versions = {} min_versions = {}
@ -120,17 +124,14 @@ def get_min_version_from_toml(
if lib in dependencies: if lib in dependencies:
if include and lib not in include: if include and lib not in include:
continue continue
requirement = dependencies[lib]
# TODO: fix this
if requirement.marker and not requirement.marker.evaluate(
{"python_version": python_version}
):
continue
# Get the version string # Get the version string
version_string = dependencies[lib] version_string = str(requirement.specifier)
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"]
# Use parse_version to get the minimum supported version from version_string # Use parse_version to get the minimum supported version from version_string
min_version = get_minimum_version(lib, version_string) min_version = get_minimum_version(lib, version_string)