Implementation:Langchain ai Langchain Pyproject Version Edit
Overview
Concrete tool for setting the release version of a LangChain package, provided by manual editing of the [project].version field in pyproject.toml.
Description
Each package in the LangChain monorepo declares its version in its own pyproject.toml under the [project] table. Before triggering a release, a maintainer edits this field to the desired version string. The build system (Hatchling) and CI pipeline (_release.yml) both read this value at build time to stamp artifacts and create Git tags.
The version field follows PEP 440 semantics and supports:
- Stable versions:
"1.2.11" - Release candidates:
"0.3.0rc1" - Development builds:
"0.3.0dev0"
The CI build job extracts the version using a Python step that loads the TOML file with tomllib and reads data["project"]["version"].
Usage
Edit the version field in the target package's pyproject.toml before initiating a release workflow. The value must be a valid PEP 440 version string.
Code Reference
Source Location: Each package directory under libs/, e.g.:
libs/core/pyproject.tomllibs/partners/openai/pyproject.tomllibs/langchain_v1/pyproject.toml
Version Field Format:
[project]
name = "langchain-core"
version = "1.2.11"
Pre-release Convention:
[project]
name = "langchain-core"
version = "0.3.0rc1"
CI Extraction (from _release.yml build job, L85-98):
import os
import tomllib
with open("pyproject.toml", "rb") as f:
data = tomllib.load(f)
pkg_name = data["project"]["name"]
version = data["project"]["version"]
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"pkg-name={pkg_name}\n")
f.write(f"version={version}\n")
Invocation: Manual edit by a maintainer, then committed to the repository before triggering the release pipeline.
I/O Contract
| Direction | Name | Type | Description |
|---|---|---|---|
| Input | pyproject.toml | File | The package metadata file containing the [project].version field
|
| Input | new version string | String | A PEP 440-compliant version (e.g., "1.2.11", "0.3.0rc1")
|
| Output | updated pyproject.toml | File | The file with the version field set to the new value
|
| Output (CI) | pkg-name | String | Package name extracted from [project].name
|
| Output (CI) | version | String | Version string extracted from [project].version
|
Usage Examples
Example 1: Stable release bump
# Before
[project]
name = "langchain-openai"
version = "1.1.8"
# After
[project]
name = "langchain-openai"
version = "1.1.9"
Example 2: Release candidate
# Before
[project]
name = "langchain-core"
version = "1.2.11"
# After (preparing an RC for next minor)
[project]
name = "langchain-core"
version = "1.3.0rc1"
Example 3: Verifying the version locally
import tomllib
with open("libs/core/pyproject.toml", "rb") as f:
data = tomllib.load(f)
print(data["project"]["version"]) # "1.2.11"