Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions .github/scripts/get_min_versions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import sys

import tomllib
from packaging.version import parse as parse_version
import re

try:
import tomllib
except ModuleNotFoundError:
import pip._vendor.tomli as tomllib

MIN_VERSION_LIBS = ["langchain-core"]


Expand Down Expand Up @@ -34,8 +38,34 @@ def get_min_version_from_toml(toml_path: str):
with open(toml_path, "rb") as file:
toml_data = tomllib.load(file)

# Get the dependencies from tool.poetry.dependencies
dependencies = toml_data["tool"]["poetry"]["dependencies"]
# Get the dependencies from [project] section (PEP 621 format)
if "project" not in toml_data or "dependencies" not in toml_data["project"]:
raise ValueError("Could not find dependencies in [project] section")

dependencies_list = toml_data["project"]["dependencies"]

# Parse dependencies list into a dictionary
# Format: "package-name>=x.x.x,<y.y.y" or "package-name>=x.x.x; python_version < '3.10'"
dependencies = {}
for dep in dependencies_list:
# Remove environment markers (everything after semicolon)
dep_without_marker = dep.split(";")[0].strip()

# Extract package name and version spec
match = re.match(r"^([a-zA-Z0-9_-]+)(.*)$", dep_without_marker)
if match:
pkg_name = match.group(1)
version_spec = match.group(2)

# If this package already exists, collect both version specs
if pkg_name in dependencies:
# Store as a list to handle multiple version constraints
if isinstance(dependencies[pkg_name], list):
dependencies[pkg_name].append(version_spec)
else:
dependencies[pkg_name] = [dependencies[pkg_name], version_spec]
else:
dependencies[pkg_name] = version_spec

# Initialize a dictionary to store the minimum versions
min_versions = {}
Expand All @@ -44,23 +74,22 @@ def get_min_version_from_toml(toml_path: str):
for lib in MIN_VERSION_LIBS:
# Check if the lib is present in the dependencies
if lib in dependencies:
# Get the version string or list
# Get the version string(s)
version_spec = dependencies[lib]

# Handle list format (multiple version constraints for different Python versions)
if isinstance(version_spec, list):
# Extract all version strings from the list and find the minimum
versions = []
for spec in version_spec:
if isinstance(spec, dict) and "version" in spec:
versions.append(get_min_version(spec["version"]))
if spec:
versions.append(get_min_version(spec))

# If we found versions, use the minimum one
if versions:
# Parse all versions and select the minimum
min_version = min(versions, key=parse_version)
min_versions[lib] = min_version
elif isinstance(version_spec, str):
elif isinstance(version_spec, str) and version_spec:
# Handle simple string format
min_version = get_min_version(version_spec)
min_versions[lib] = min_version
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ jobs:
run: |
make test

- name: Get minimum versions
working-directory: ${{ inputs.working-directory }}
id: min-version
run: |
poetry run pip install packaging
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
echo "min-versions=$min_versions"

- name: Run unit tests with minimum dependency versions
if: ${{ steps.min-version.outputs.min-versions != '' }}
env:
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
run: |
poetry run pip install $MIN_VERSIONS
make tests
working-directory: ${{ inputs.working-directory }}

- name: Ensure the tests did not create any additional files
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion libs/oci/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/oci/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readme = "README.md"
license = "UPL-1.0"
requires-python = ">=3.9,<4.0"
dependencies = [
"langchain-core>=0.3.20,<1.0.0",
"langchain-core>=0.3.78,<1.0.0",
"langchain>=0.3.20,<1.0.0",
"oci>=2.161.0",
"pydantic>=2,<3",
Expand Down
16 changes: 14 additions & 2 deletions libs/oracledb/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions libs/oracledb/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[tool.poetry]
[project]
name = "langchain-oracledb"
version = "1.1.0"
description = "An integration package connecting Oracle Database and LangChain"
authors = []
readme = "README.md"
repository = "https://github.com/oracle/langchain-oracle"
license = "UPL"
license = "UPL-1.0"
requires-python = ">=3.9,<4.0"
dependencies = [
"langchain-core>=0.3.15,<1.0.0; python_version < '3.10'",
"langchain-core>=1.0.0,<2.0.0; python_version >= '3.10'",
"langchain-community>=0.3.0",
"oracledb>=2.2.0",
"pydantic>=2,<3",
"numpy>=1.21,<3",
]

[tool.poetry.urls]
[project.urls]
"Source Code" = "https://github.com/oracle/langchain-oracle/tree/main/libs/oracledb"
Repository = "https://github.com/oracle/langchain-oracle"

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
langchain-core = [
{ version = "^0.3.15", python = "<3.10" },
{ version = "^1.0.0", python = ">=3.10" }
]
langchain-community = ">=0.3.0"
oracledb = ">=2.2.0"
pydantic = ">=2,<3"
numpy = ">=1.21,<3"
[tool.poetry]
package-mode = true

[tool.poetry.group.test]
optional = true
Expand All @@ -32,8 +32,8 @@ pytest-asyncio = "^0.23.2"
pytest-watcher = "^0.3.4"
sentence-transformers = "^5.0.0"
langchain-tests = [
{ version = "^0.3.21", python = "<3.10" },
{ version = "^1.0.0", python = ">=3.10" }
{ version = "^0.3.21", python = "<3.10" },
{ version = "^1.0.0", python = ">=3.10" }
]

[tool.poetry.group.codespell]
Expand Down Expand Up @@ -64,6 +64,9 @@ optional = true

[tool.ruff]

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
select = [
"E", # pycodestyle
Expand All @@ -75,9 +78,6 @@ ignore = [
"COM812", # Messes with the formatter
]

[tool.ruff.format]
docstring-code-format = true

[tool.mypy]
plugins = ["pydantic.mypy"]
check_untyped_defs = true
Expand Down