Return
MigrateLib: A tool for end-to-end Python library migration
DOI:10.1007/s10664-026-10970-9.png)
Abstract
En 中文
Library migration is the process of replacing a library with a similar one in a software project. Manual library migration is time-consuming and error-prone, as it requires developers to understand the Application Programming Interfaces (API) of both libraries, map equivalent APIs, and perform the necessary code transformations. This paper presents an LLM-based end-to-end solution that can automatically migrate code between any arbitrary pair of Python libraries that provide similar functionality. Before building the technique, we first systematically study the capabilities of LLMs for library migration on PyMigBench, an existing benchmark of 314 real-world library migrations. We find that the best performing LLM, GPT-4o, can correctly perform 57% of the migrations. We also identify post-processing steps that can further improve the performance. Based on this, we develop MigrateLib, a command-line application that combines the power of LLMs, static analysis, and dynamic analysis to provide accurate library migration. We evaluate MigrateLib on 717 migration scenarios in 175 real-world Python applications that are not from PyMigBench. We find that MigrateLib can migrate 32% of the migrations with complete correctness without any developer intervention. We inspect a sample of the incomplete migrations to understand how many of the required changes have already been done by MigrateLib and how many manual changes are still needed to complete the migration. We find that for more than half of the inspected migrations, MigrateLib completed 73% of the required migration-related changes, leaving only 27% of the required changes for manual intervention.
Keywords:
Library migration
Python
Large Language Models
Journal
IF:
3.6
Papers:
2.0K
Citations:
6.4K

