PyTrim: 一种减少Python依赖膨胀的实用工具
PyTrim: A Practical Tool for Reducing Python Dependency Bloat
AI总结:
PyTrim是一种自动化减少Python项目依赖膨胀的工具,通过动态分析和模块化设计提高依赖检测准确性,并已成功应用于多个开源项目。
摘要:
依赖膨胀是Python项目中的持续挑战,会增加维护成本和安全风险。尽管已有众多工具用于检测Python中的未使用依赖项,但跨项目源代码和配置文件删除这些依赖项需要手动努力和专业知识。为解决这一挑战,我们引入了PYTRIM,一个端到端系统,用于自动化此过程。PYTRIM能够在多种文件类型中消除未使用的导入和包声明,包括Python源代码和配置文件,如requirements.txt和setup.py。PYTRIM的模块化设计使其对依赖膨胀信息的来源无关,能够与任何检测工具集成。除了其在自动化方面的贡献外,PYTRIM还包含一个新颖的动态分析组件,提高了依赖检测的召回率。我们对PYTRIM在37个合并的pull request数据集上的端到端有效性评估显示,PYTRIM在复制人工修改方面实现了98.3%的准确率。为了展示其实际影响,我们对971个开源项目运行了PYTRIM,识别并裁剪了39个项目的膨胀依赖项。对于每个案例,我们提交了相应的pull request,其中6个已被接受并合并。PYTRIM作为开源项目可用,鼓励社区贡献和进一步发展。视频演示:https://youtu.be/LqTEdOUbJRI;代码仓库:https://github.com/TrimTeam/PyTrim
英文摘要:
Dependency bloat is a persistent challenge in Python projects, which increases maintenance costs and security risks. While numerous tools exist for detecting unused dependencies in Python, removing these dependencies across the source code and configuration files of a project requires manual effort and expertise. To tackle this challenge we introduce PYTRIM, an end-to-end system to automate this process. PYTRIM eliminates unused imports and package declarations across a variety of file types, including Python source and configuration files such as requirements.txt and setup.py. PYTRIM's modular design makes it agnostic to the source of dependency bloat information, enabling integration with any detection tool. Beyond its contribution when it comes to automation, PYTRIM also incorporates a novel dynamic analysis component that improves dependency detection recall. Our evaluation of PYTRIM's end-to-end effectiveness on a ground-truth dataset of 37 merged pull requests from prior work, shows that PYTRIM achieves 98.3% accuracy in replicating human-made changes. To show its practical impact, we run PYTRIM on 971 open-source packages, identifying and trimming bloated dependencies in 39 of them. For each case, we submit a corresponding pull request, 6 of which have already been accepted and merged. PYTRIM is available as an open-source project, encouraging community contributions and further development. Video demonstration: https://youtu.be/LqTEdOUbJRI Code repository: https://github.com/TrimTeam/PyTrim
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。