Metadata-Version: 2.4
Name: langchain-community-migrate
Version: 0.1.0
Summary: Unofficial migration helper for the sunset langchain-community: finds every langchain_community import, the standalone package that replaces it, rewrites 1:1 moves and vendors orphaned classes.
Author-email: agent-one <rafal.baranowski.iot@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/rafal-one/langchain-community-migrate
Keywords: langchain,langchain-community,migration,codemod,sunset,imports
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# langchain-community-migrate

Find the replacement for every `langchain_community` import in your project, rewrite the 1:1 moves, and
**vendor** the classes that never got a standalone package.

> Unofficial community tool. Not affiliated with or endorsed by LangChain. Stdlib only, Python 3.9+.

## Why

`langchain-community` was sunset on 2026-05-22 (no more fixes or security patches, repo archived 2026-06-19)
but is still downloaded ~27M times a month. Teams have to work out, for each loader, vector store, chat model
and tool they import, whether a standalone package replaces it (`langchain-openai`, `langchain-chroma`,
`langchain-postgres`, ...), whether the API changed, or whether nothing replaces it. The official docs only
link index pages. `langchain-cli migrate` needs the grit binary and covers a handful of partners.

This tool ships a **mapping table** generated from the real packages: the public symbols of
langchain-community 0.2.19, 0.3.31 and 0.4.2 matched against the exports of 70+ partner packages plus
`langchain-core`, with curated overrides for renames and API changes (see `scripts/` in the repo; regenerate
it yourself). 1,856 symbols: 152 with a replacement, 29 to verify, 1,675 with no standalone package.

```
pip install langchain-community-migrate     # or: pip install git+https://github.com/rafal-one/langchain-community-migrate
```

## `scan`: what do I use and what replaces it?

```
$ langchain-community-migrate scan src/
src/app.py:1:1: vectorstores.Chroma -> moved
    from langchain_chroma import Chroma  [pip install langchain-chroma]
src/app.py:1:1: vectorstores.FAISS -> orphaned
    no standalone package; vendor it (`vendor`) or stay on a pinned langchain-community
src/app.py:1:1: vectorstores.Pinecone -> moved, API change
    from langchain_pinecone import PineconeVectorStore  [pip install langchain-pinecone]
      note: renamed; construct with an index handle: PineconeVectorStore(index=..., embedding=...) ...

9 reference(s) in 1 file(s): 5 moved, 1 moved, API change, 3 orphaned
install: pip install langchain-chroma langchain-huggingface langchain-ollama langchain-openai langchain-pinecone
```

It understands `from langchain_community.x[.y] import Z`, aliases, `import langchain_community.x as m; m.Z`,
`langchain_community.x.Z` chains, and the legacy `from langchain.llms import OpenAI` style paths that forwarded
to langchain-community. Statuses:

| Status | Meaning |
|---|---|
| moved | a standalone package exports the same class (or the replacement is a known rename) |
| moved, API change | replaced, but constructor/behaviour differs; the note says how |
| verify | a same-named class exists elsewhere; check before switching |
| orphaned | no standalone package found; `vendor` it or pin langchain-community |
| unknown | not in the mapping (star import, private module) |

`--format json|markdown` for reports, `-q` to drop the footer. Exit codes: `0` nothing found (or `--fail-on
never`), `1` references found (`--fail-on orphaned`: only orphaned/unknown), `2` bad usage or missing path.

## `fix`: rewrite imports and dependencies

Dry run by default (unified diff); `--write` applies it.

```
langchain-community-migrate fix src/                          # diff
langchain-community-migrate fix src/ --write                  # apply
langchain-community-migrate fix src/ --write --include-api-changes
```

* Rewrites `from langchain_community.vectorstores import Chroma, FAISS` into
  `from langchain_community.vectorstores import FAISS` + `from langchain_chroma import Chroma`; aliases and
  multi-line imports are kept; renamed classes get `as OldName` so the rest of the file still works.
* API-change moves are only rewritten with `--include-api-changes`, and get a `TODO` comment with the note.
* Adds the needed packages to `requirements*.txt` / `pyproject.toml` (next to `langchain-community`), and drops
  `langchain-community` only when no reference is left anywhere under the given paths.
* It never touches `import langchain_community.x as m` style usage; `scan` lists those.

## `vendor`: keep the orphans, drop the dependency

```
pip install 'langchain-community<0.5'   # source of the code to copy; needed once
langchain-community-migrate vendor src/ --dest src/myapp/_vendor            # dry run
langchain-community-migrate vendor src/ --dest src/myapp/_vendor --write
```

Copies the module of every orphaned symbol you import (e.g. `FAISS`) plus the langchain_community modules it
imports (static closure) into `_vendor/langchain_community/...`, rewrites their imports to the vendored copy,
rewrites your imports, and copies the MIT licence next to them. Third-party packages the vendored code needs
(`faiss-cpu`, `numpy`, ...) are listed for you to add. `--source DIR` uses an unpacked copy instead of the
installed package; `--only NAME` limits it. Vendored code is yours to maintain: nobody patches it upstream anymore.

## `lookup`

```
$ langchain-community-migrate lookup PGVector
vectorstores:PGVector [moved, API change]  langchain_community.vectorstores.pgvector
    from langchain_postgres import PGVector  [pip install langchain-postgres]
      note: connection string argument is now `connection=`; table schema differs ...
```

## Limits

The mapping matches names, not behaviour: always read the notes, run your tests, and treat "verify" entries as
suggestions. It reflects the partner packages as of 2026-10-18; a partner package that adds a class later will
show up as orphaned until the mapping is regenerated. Only Python source is scanned (no notebooks or YAML configs).

## Development

`pytest` (39 tests), Python 3.9 and 3.14; wheel and sdist clean installs checked.
`python scripts/fetch_partners.py WORK exports.json` then `python scripts/gen_mapping.py exports.json out.json
0.4.2=DIR 0.3.31=DIR ...` rebuilds `mapping.json`.

## Donate

If this saved your team a migration week: https://paypal.me/RafalBaranowski

MIT licensed.
