Skip to content

Commit 28bf80c

Browse files
Modify oracledb pyproject for updated standard and fix get_min_versions (#72)
* modify oracledb pyproject for updated standard and fix get_min_versions * update poetry.lock to reflect the latest pyproject.toml change * add min version test in CI * fix tomllib error with python3.9 * fix dep version for langchain
1 parent 03e6feb commit 28bf80c

File tree

6 files changed

+91
-32
lines changed

6 files changed

+91
-32
lines changed

.github/scripts/get_min_versions.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import sys
22

3-
import tomllib
43
from packaging.version import parse as parse_version
54
import re
65

6+
try:
7+
import tomllib
8+
except ModuleNotFoundError:
9+
import pip._vendor.tomli as tomllib
10+
711
MIN_VERSION_LIBS = ["langchain-core"]
812

913

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

37-
# Get the dependencies from tool.poetry.dependencies
38-
dependencies = toml_data["tool"]["poetry"]["dependencies"]
41+
# Get the dependencies from [project] section (PEP 621 format)
42+
if "project" not in toml_data or "dependencies" not in toml_data["project"]:
43+
raise ValueError("Could not find dependencies in [project] section")
44+
45+
dependencies_list = toml_data["project"]["dependencies"]
46+
47+
# Parse dependencies list into a dictionary
48+
# Format: "package-name>=x.x.x,<y.y.y" or "package-name>=x.x.x; python_version < '3.10'"
49+
dependencies = {}
50+
for dep in dependencies_list:
51+
# Remove environment markers (everything after semicolon)
52+
dep_without_marker = dep.split(";")[0].strip()
53+
54+
# Extract package name and version spec
55+
match = re.match(r"^([a-zA-Z0-9_-]+)(.*)$", dep_without_marker)
56+
if match:
57+
pkg_name = match.group(1)
58+
version_spec = match.group(2)
59+
60+
# If this package already exists, collect both version specs
61+
if pkg_name in dependencies:
62+
# Store as a list to handle multiple version constraints
63+
if isinstance(dependencies[pkg_name], list):
64+
dependencies[pkg_name].append(version_spec)
65+
else:
66+
dependencies[pkg_name] = [dependencies[pkg_name], version_spec]
67+
else:
68+
dependencies[pkg_name] = version_spec
3969

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

5080
# Handle list format (multiple version constraints for different Python versions)
5181
if isinstance(version_spec, list):
5282
# Extract all version strings from the list and find the minimum
5383
versions = []
5484
for spec in version_spec:
55-
if isinstance(spec, dict) and "version" in spec:
56-
versions.append(get_min_version(spec["version"]))
85+
if spec:
86+
versions.append(get_min_version(spec))
5787

5888
# If we found versions, use the minimum one
5989
if versions:
60-
# Parse all versions and select the minimum
6190
min_version = min(versions, key=parse_version)
6291
min_versions[lib] = min_version
63-
elif isinstance(version_spec, str):
92+
elif isinstance(version_spec, str) and version_spec:
6493
# Handle simple string format
6594
min_version = get_min_version(version_spec)
6695
min_versions[lib] = min_version

.github/workflows/_test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@ jobs:
4949
run: |
5050
make test
5151
52+
- name: Get minimum versions
53+
working-directory: ${{ inputs.working-directory }}
54+
id: min-version
55+
run: |
56+
poetry run pip install packaging
57+
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
58+
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
59+
echo "min-versions=$min_versions"
60+
61+
- name: Run unit tests with minimum dependency versions
62+
if: ${{ steps.min-version.outputs.min-versions != '' }}
63+
env:
64+
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
65+
run: |
66+
poetry run pip install $MIN_VERSIONS
67+
make tests
68+
working-directory: ${{ inputs.working-directory }}
69+
5270
- name: Ensure the tests did not create any additional files
5371
shell: bash
5472
run: |

libs/oci/poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/oci/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = "README.md"
66
license = "UPL-1.0"
77
requires-python = ">=3.9,<4.0"
88
dependencies = [
9-
"langchain-core>=0.3.20,<1.0.0",
9+
"langchain-core>=0.3.78,<1.0.0",
1010
"langchain>=0.3.20,<1.0.0",
1111
"oci>=2.161.0",
1212
"pydantic>=2,<3",

libs/oracledb/poetry.lock

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/oracledb/pyproject.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
[tool.poetry]
1+
[project]
22
name = "langchain-oracledb"
33
version = "1.1.0"
44
description = "An integration package connecting Oracle Database and LangChain"
5-
authors = []
65
readme = "README.md"
7-
repository = "https://github.com/oracle/langchain-oracle"
8-
license = "UPL"
6+
license = "UPL-1.0"
7+
requires-python = ">=3.9,<4.0"
8+
dependencies = [
9+
"langchain-core>=0.3.15,<1.0.0; python_version < '3.10'",
10+
"langchain-core>=1.0.0,<2.0.0; python_version >= '3.10'",
11+
"langchain-community>=0.3.0",
12+
"oracledb>=2.2.0",
13+
"pydantic>=2,<3",
14+
"numpy>=1.21,<3",
15+
]
916

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

13-
[tool.poetry.dependencies]
14-
python = ">=3.9,<4.0"
15-
langchain-core = [
16-
{ version = "^0.3.15", python = "<3.10" },
17-
{ version = "^1.0.0", python = ">=3.10" }
18-
]
19-
langchain-community = ">=0.3.0"
20-
oracledb = ">=2.2.0"
21-
pydantic = ">=2,<3"
22-
numpy = ">=1.21,<3"
21+
[tool.poetry]
22+
package-mode = true
2323

2424
[tool.poetry.group.test]
2525
optional = true
@@ -32,8 +32,8 @@ pytest-asyncio = "^0.23.2"
3232
pytest-watcher = "^0.3.4"
3333
sentence-transformers = "^5.0.0"
3434
langchain-tests = [
35-
{ version = "^0.3.21", python = "<3.10" },
36-
{ version = "^1.0.0", python = ">=3.10" }
35+
{ version = "^0.3.21", python = "<3.10" },
36+
{ version = "^1.0.0", python = ">=3.10" }
3737
]
3838

3939
[tool.poetry.group.codespell]
@@ -64,6 +64,9 @@ optional = true
6464

6565
[tool.ruff]
6666

67+
[tool.ruff.format]
68+
docstring-code-format = true
69+
6770
[tool.ruff.lint]
6871
select = [
6972
"E", # pycodestyle
@@ -75,9 +78,6 @@ ignore = [
7578
"COM812", # Messes with the formatter
7679
]
7780

78-
[tool.ruff.format]
79-
docstring-code-format = true
80-
8181
[tool.mypy]
8282
plugins = ["pydantic.mypy"]
8383
check_untyped_defs = true

0 commit comments

Comments
 (0)