PCREQ is an automated tool for inferring compatible requirements for Python third-party library (TPL) upgrades. It is the first to achieve a fully automated process (end-to-end) that includes knowledge acquisition, version compatibility assessment, invoked APIs and modules extraction, code compatibility assessment, and missing TPL completion. PCREQ specializes in generating a compatible requirements.txt when upgrading a target TPL through a comprehensive analysis of both version and code compatibility issues.
For PCREQ's design and implementation details, please refer to our paper.
REQBench Benchmark for Python Third-Party Libraries Upgrade.
PCREQ's evaluation results are available here.
- Linux (tested on Ubuntu 18.04.1)
- Python 3.9.12
- thefuzz 0.22.1
- z3-solver 4.13.4.0
- packaging 24.0
- requests 2.32.3
In the configure directory, construct a JSON configuration file, which should include the following information:
{
"projPath": "/home/usr/project",
"requirementsPath": "/home/usr/requirements.txt",
"targetLibrary": "pillow",
"startVersion": "6.2.0",
"targetVersion": "7.0.0",
"pythonVersion": "3.7",
"knowledgePath": "/home/usr/knowledge/"
}projPath: project path, requirementsPath: requirements path, targetLibrary: target third-party library name, startVersion: current version of target third-party library, targetVersion: target version of target third-party library, pythonVersion: the Python version, knowledgePath: the path of knowledge.
Given the potentially large knowledge size, knowledgePath supports custom storage locations.
The extracted knowledge (Third-party library source code) of REQBench can be accessed at libraries-Part1, libraries-Part2, libraries-Part3. To use the downloaded knowledge, run:
cd /home/usr/knowledge/
mkdir libraries
tar -xzvf *.tar.gz -C librariesThe extracted knowledge (extracted code entities, candidate versions, and version constraints) of REQBench can be accessed at Entities, Versions, Constraints. To use the downloaded knowledge, run:
cd /home/usr/knowledge/
tar -xzvf *.tar.gz -C .Run Command
python knowledge_acquisition.py -config config.jsonRun Command
python main.py -config config.jsonpython knowledge_acquisition.py -config config.json
python main.py -config config.jsonThe output consists of two parts: the updated requirements.txt and an analysis report, which is located in the report directory and contains what PCREQ performed in terms of version and code compatibility checks and fixes. The contents of the report are as follows:
*************Upgrade pillow from 6.2.0 to 7.0.0 in PyTorch-ENet*************
Checking PyTorch-ENet is compatible with pillow7.0.0?...
PyTorch-ENet is compatible with pillow7.0.0
Checking torchvision0.3.0 is compatible with pillow7.0.0?...
torchvision0.3.0 is not compatible with pillow7.0.0-The PIL.PILLOW_VERSION is deprecated.
Checking torchvision0.4.0 is compatible with pillow7.0.0?...
torchvision0.4.0 is not compatible with pillow7.0.0-The PIL.PILLOW_VERSION is deprecated.
Checking PyTorch-ENet is compatible with torchvision0.4.0?...
PyTorch-ENet is compatible with torchvision0.4.0
Checking torchvision0.4.1 is compatible with pillow7.0.0?...
torchvision0.4.1 is not compatible with pillow7.0.0-The PIL.PILLOW_VERSION is deprecated.
Checking PyTorch-ENet is compatible with torchvision0.4.1?...
PyTorch-ENet is compatible with torchvision0.4.1
Checking torchvision0.4.2 is compatible with pillow7.0.0?...
torchvision0.4.2 is not compatible with pillow7.0.0-The PIL.PILLOW_VERSION is deprecated.
Checking PyTorch-ENet is compatible with torchvision0.4.2?...
PyTorch-ENet is compatible with torchvision0.4.2
Checking torchvision0.5.0 is compatible with pillow7.0.0?...
torchvision0.5.0 is compatible with pillow7.0.0
Checking PyTorch-ENet is compatible with torchvision0.5.0?...
PyTorch-ENet is compatible with torchvision0.5.0
Checking torchvision0.5.0 is compatible with torch1.4.0?...
torchvision0.5.0 is compatible with torch1.4.0
Checking PyTorch-ENet is compatible with torch1.4.0?...
PyTorch-ENet is compatible with torch1.4.0
*************New requirements.txt has been generated!*************
Time cost: 9.06177806854248 s
