Abstract
dc:description.abstractLibrary 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 of the involved libraries, map equivalent APIs, and perform the necessary code transformations. Due to its difficulty, most of the existing automated techniques and tooling stop at the API mapping stage or support a limited set of libraries and code transformations. In this thesis, we develop an end-to-end solution that can automatically migrate code between any arbitrary pair of Python libraries that provide similar functionality. Developing such a tool requires deep understanding of the nature of library migrations, which we focus on in the first phase of this thesis. In this first phase, we first build PyMigBench, a benchmark of 321 real-world library migrations that includes 2,989 migration-related code changes. We then analyze the benchmark and develop PyMigTax, a taxonomy to describe migration-related code changes. Using PyMigTax, we run an empirical study on PyMigBench to understand the nature of library migrations. In the second phase, we build on our findings to develop a migration tool. We use Large Language Models (LLMs) as the primary engine for migration given their proven capability of code generation and transformation. We first evaluate the capabilities of LLMs for library migration on PyMigBench. While we find it effective, we also identify some post-processing steps that can 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 migrations. We evaluate MigrateLib on 717 real-world Python applications that are not from PyMigBench. We find that MigrateLib can migrate 32% of the migrations with complete correctness, and more than half of the migrations with at least 86% of the tests passing after migration. We also manually fix a sample of the incomplete migrations, and find MigrateLib does 73% of the migration-related changes for more than half of the projects, leaving just 27% of the changes for the developers to fix. This shows that MigrateLib can significantly reduce the effort of library migration.
Degree
thesis:*- Name thesis:degree_name
- Doctor of Philosophy
- Level thesis:degree_level
- Doctoral
- Grantor
- University of Alberta
- Year dc:date.issued
- 2026
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Islam, Md Mohayeminul
- Advisor dc:contributor.advisor
-
- Nadi, Sarah (Computing Science)
Subjects
dc:subject × 5Rights
dc:rights- Statement dc:rights
-
- This thesis is made available by the University of Alberta Library with permission of the copyright owner solely for non-commercial purposes. This thesis, or any portion thereof, may not otherwise be copied or reproduced without the written consent of the copyright owner, except to the extent permitted by Canadian copyright law.
- Language dc:language.iso
- en
Identifiers
dc:identifier.*- DOI dc:identifier.doi
- https://doi.org/10.7939/84502