[PerlChina] Question on module dependency_display

agentzh agentzh at gmail.com
Wed Dec 31 02:09:06 PST 2008


2008/12/31 Qiang (James) <shijialee at gmail.com>:
>> CPAN上做PM的Dependency Check和显示的工具叫什么?
>
> CPAN 打包模块常用的有 Module::Build 或 Module::Install(基于ExtUtils::
> MakeMaker). 每个打包工具可设定 Dependecy 的模块和版本.
>
> 另外 CPAN 也提供一个不错的在线查找模块 Dependency 工具
> http://deps.cpantesters.org/
>

根据 CPAN Dependencies 网页上的提示:

 "It relies on modules having META.yml files so it can work out their
dependencies, and is case-sensitive."

所以对于 CPAN 模块而言,扫描它们自己的 META.yml 文件即可.而 META.yml 中的依赖项一般也是 CPAN 模块的作者自己手工列出的.
不过有趣的是 Jifty 有一个 .t 文件自己扫描实际使用的模块并将之与 Makefile.PL 中列出的进行比较:

http://search.cpan.org/src/SARTAK/Jifty-0.80408/t/01-dependencies.t

本质上是一种源码级别的正则扫描:

   # look for use and use base statements
   $used{$1}{$File::Find::name}++ while $data =~ /^\s*use\s+([\w:]+)/gm;
   while ($data =~ m|^\s*use base qw.([\w\s:]+)|gm) {
       $used{$_}{$File::Find::name}++ for split ' ', $1;
   }

因此不是 100% 可靠的东西,但能满足需要 ^_^ 这小片代码其实来自 CPAN 上的 Test::Dependencies::Light 模块(
Jifty 为了减少一个依赖项就把代码内联了,呵呵,它原先确实是使用 Test::Dependencies 模块的).

真正运行时级别上的依赖项扫描, 可能当属 pp 工具使用的 Module::ScanDeps 模块了.呵呵.
(Test::Dependencies::Heavy 模块会实际编译 Perl 代码.)

>> 打算利用元旦假期整理下很多PM的关系,并且Display出一张图.
>

我很有兴趣把你的代码整合到 UML::Class::Simple 中来,如果你愿意分享的话,呵呵.

> 感觉应该有人做过类似的工作, 可以找找.
>

Qiang 所言极是 ^_^

>> 谢谢, 祝各位新年快乐-工作顺利,身体健康!
>>

新年好!新年好!

Cheers,
-agentzh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/china-pm/attachments/20081231/94621824/attachment.html>


More information about the China-pm mailing list