github にある module を require したい

github (or github enterprise) にある module を require したい。

かなり前の dev 版 carton には github にあるモジュールを require する機能があったが、消えてしまった。

モジュールは cpan にあげるべきだという意見はもっともだが、会社で書いているモジュールは社内の c++ コードに依存しているのでちょっと無理である。

また、cpan mirror server を立てるべきというのももっともだが、もっとコンパクトにやりたい。

ということでできるようにしてみた。

これは cpanm or carton を実行する直前に OrePAN2 によって local repository を作ってから、それらを実行するラッパーである。

cpanfile が以下のようなものであるとする。

# Test::PackageName というのは github にしかない
requires 'Test::PackageName', git => 'git://github.com/shoichikaji/Test-PackageName.git@master';

で、cpan-zero をかまして cpanm or carton を実行する。

> cpan-zero carton install
Installing modules using /Users/skaji/cpanfile
Successfully installed ExtUtils-Config-0.008
Successfully installed ExtUtils-InstallPaths-0.011
Successfully installed ExtUtils-Helpers-0.022
Successfully installed Module-Build-Tiny-0.039
Successfully installed Test-PackageName-0.01
5 distributions installed
Complete! Modules were installed into /Users/skaji/local

random thoughts

  • carton の git をはじめとするいろいろな dependencies support を期待している。
  • local repository をまず作る、というのは module 探索手段が統一され悪くないかもしれない。
  • 最初に local mirror から module を探すので、 ~/.cpanm/build.log に Download failedが出まくる。