Module-CPANfile-1.0002 > cpanfile-faq
Module-CPANfile-1.0002
Other versions:
Module-CPANfile-1.0001

名前

cpanfile-faq - cpanfile FAQ

質問

Does cpanfile replace Makefile.PL/Build.PL or META.yml/json?

cpanfile は Makefile.PL/Build.PL や META.yml/json を置き換えますか?

No, it doesn't. cpanfile is a simpler way to declare CPAN dependencies, mainly for your application rather than CPAN distributions.

いいえ、cpanfileは、単純にCPANの依存を宣言する方法です。 CPANディストリビューションよりもむしろ、主にあなたのアプリケーション のためのものです。

However, while CPAN distributions do not need to switch to cpanfile, you can certainly manage the dependencies in cpanfile, then export them into META.json files when shipping to CPAN, using tools such as Dist::Milla or Module::Install::CPANfile

しかしながら、CPANディストリビューションcpanfile切り替える必要が ないとはいえ、確かに、cpanfileで依存を管理できます。それから、CPANに シッピングするときに、Dist::MillaModule::Install::CPANfileのような ツールを使って、その依存をMETA.jsonファイルにエクスポートできます。

Why do we need yet another format?

なぜ、別のフォーマットが必要なのでしょう?

Here are some of the reasons that motivates the new cpanfile format.

新しくcpanfileフォーマットを作る動機となる理由がいくつかあります。

Not everything is a CPAN distribution

(すべてがCPANディストリビューションではない)

First of all, it is annoying to write (a dummy) Makefile.PL when what you develop is not a CPAN distribution, just so that installation like cpanm --installdeps . would work.

まず最初に、CPANディストリビューションでないものを開発をするときに、 単に、cpanm --installdeps . のようにが動かしたいがために、 (ダミーの)Makefile.PLを書くのは面倒です。

It gets more painful when you develop a web application that you want to deploy on a different environment using version control system (such as PaaS/cloud infrastructure), because it requires you to often commit the META file or inc/ directory (or even worse, both) to a repository.

(PaaS/クラウドのようなインフラで)、バージョンコントロールシステムを使って 違った環境でデプロイしたいWebアプリケーションを開発するときに、 より苦痛です。なぜなら、METAファイルかinc/ディレクトリ(悪い時には、両方)を リポジトリに頻繁にコミットしなければならないからです。

Many web application frameworks generate a boiler-plate Makefile.PL for dependency declaration and to let you install dependencies with cpanm --installdeps ., but that doesn't always mean they are meant to be installed. Things can be often much simpler if you run the application from the checkout directory.

多くのWebアプリケーションフレームワークは、依存性の宣言のために、 サンプルのMakefile.PLを生成し、cpanm --installdeps .で、 依存をインストールさせます。ですが、常にインストールするつもりであるとは 限りません。チェックアウトしたディレクトリからアプリケーションを 走らせるなら、多くの場合、より簡単にできます。

With cpanfile, dependencies can be installed either globally or locally using supported tools such as cpanm or Carton. Because cpanfile lists all the dependencies of your entire application and will be updated over time, it makes perfect sense to commit the file to a version control system, and push the file for a deployment.

cpanfileを使えば、cpanmCartonのようなcpanfileをサポートしたツール を使って、依存をグローバルにもローカルにもインストールできます。 cpanfileはアプリケーション全体のすべての依存をリストしており、 時間が経てば更新されるでしょう。バージョンコントロールシステムにこのファイルをコミットする 完全な意義があります。そして、デプロイメントのためにファイルを置きます。

Familiar DSL syntax

(なじみやすいDSLシンタックス)

This is a new file type, but the format and syntax isn't entirely new. The metadata it can declare is exactly a subset of "Prereqs" in CPAN Meta Spec.

これは新しいファイルタイプですが、フォーマットとシンタックスは完全に 新しいものではありません。宣言できるメタデータは、CPAN Meta Specの "Prereqs"のサブセットです。

The syntax borrows a lot from Module::Install. Module::Install is a great way to easily declare module metadata such as name, author and dependencies. cpanfile format is simply to extract the dependencies into a separate file, which means most of the developers are familiar with the syntax.

シンタックスの多くはModule::Installから借りています。Module::Installは 名前や著者や依存といったモジュールのメタデータを簡単に宣言する素晴らしい方法 です。cpanfileフォーマットは単純に依存性を別のファイルに取り出したもの なので、開発者の多くはそのシンタックスに馴染みがあるということになります。

Complete CPAN Meta Spec v2 support

(CPAN メタスペック v2 の完全なサポート)

cpanfile basically allows you to declare CPAN::Meta::Spec prerequisite specification using an easy Perl DSL syntax. This makes it easy to declare per-phase dependencies and newer version 2 features such as conflicts and version ranges.

cpanfileは、基本的に、簡単なPerlのDSLシンタックスを使って、 CPAN::Meta::Specの必要条件を宣言できます。これにより、 フェーズごとの依存、コンフリクト、バージョンの範囲のような、 新しいバージョン2の機能を簡単に宣言できます。

How can I start using cpanfile?

どのようにcpanfileを使い始めますか?

First of all, most distributions on CPAN are not required to update to this format.

まず最初に、CPANにある多くのディストリビューションはこのフォーマットに アップデートする必要はありません。

If your application currently uses Makefile.PL etc. for dependency declaration because of the current toolchain implementation (e.g. cpanm --installdeps .), you can upgrade to cpanfile while keeping the build file based installation working for the backward compatibility.

現在、あなたのアプリケーションが、現在のツールチェインの実装 (e.g. <cpanm --installdeps . >)のために、Makefile.PLなどを、 依存の宣言に使っているなら、後方互換性のために動くインストレーションに基づいた ビルドファイルを持ち続けることで、cpanfileにアップグレードできます。

If you are an author of CPAN module and want to manage CPAN module prerequisites using cpanfile you can use one of the following tools:

CPANモジュールの作者で、CPANモジュールの必要条件をcpanfileを使って 管理したければ、以下のツールの一つを使うことができます。

Dist::Milla

Dist::Milla is a profile for Dist::Zilla that has a cpanfile support to declare dependencies for your module.

Dist::Milla は、Dist::Zilla のプロファイルです。 モジュールの依存の宣言のために、cpanfileをサポートしています。

Dist::Zilla

Dist::Zilla::Plugin::Prereqs::FromCPANfile provides a way to merge dependencies declared in cpanfile into META files as well as build files. You can combine them using other prerequisite scanners like AutoPrereqs.

Dist::Zilla::Plugin::Prereqs::FromCPANfileは、cpanfileに宣言された 依存をMETAファイルに加えけてビルドファイルにも、マージする方法を提供します。 AutoPrereqsのような他の必要条件スキャナーを使って、それらを一体化できます。

Minilla

Minilla is a yet another authoring tool that supports cpanfile as a way to describe dependencies for your CPAN module.

Minillaは、また別のオーサリングツールであり、 CPANモジュールの依存を宣言するための方法としてcpanfileをサポートします。

Module::Install

Module::Install::CPANfile provides a cpanfile DSL that reads cpanfile to merge prerequisites when dumping MYMETA files upon installation.

Module::Install::CPANfileは、cpanfileDSLを読み、 インストール時にMYMETAファイルをダンプするときに、 cpanfile を必要条件にマージします。

Module::Build

Module::Build::Pluggable::CPANfile merges cpanfile dependencies from Build.PL when dumping out MYMETA information.

Module::Build::Pluggable::CPANfileBuild.PLから、MYMETAの情報を ダンプするときに、cpanfile の依存をマージします。

ExtUtils::MakeMaker

ExtUtils::MakeMaker has no direct support for cpanfile yet, but you could use Module::CPANfile's merge_meta method to update MYMETA.json files with the contents in cpanfile, or convert the structure to appropriate options with PREREQ_PM and META_MERGE for WriteMakefile.

ExtUtils::MakeMaker は、cpanfileを直接にはサポートしません。ですが、 Module::CPANfilemerge_meta を使って、 MYMETA.json ファイルを、cpanfileの内容で更新するか、 WriteMakefilePREREQ_PMMETA_MERGEのオプションを使って、 構造を変換できます。