1cpanfile-faq(3) User Contributed Perl Documentation cpanfile-faq(3)
2
3
4
6 cpanfile-faq - cpanfile FAQ
7
9 Does cpanfile replace Makefile.PL/Build.PL or META.yml/json?
10 No, it doesn't. "cpanfile" is a simpler way to declare CPAN
11 dependencies, mainly for your application rather than CPAN
12 distributions.
13
14 However, while CPAN distributions do not need to switch to "cpanfile",
15 you can certainly manage the dependencies in "cpanfile", then export
16 them into "META.json" files when shipping to CPAN, using tools such as
17 Dist::Milla or Module::Install::CPANfile
18
19 Why do we need yet another format?
20 Here are some of the reasons that motivates the new cpanfile format.
21
22 Not everything is a CPAN distribution
23 First of all, it is annoying to write (a dummy) "Makefile.PL" when
24 what you develop is not a CPAN distribution, just so that
25 installation like "cpanm --installdeps ." would work.
26
27 It gets more painful when you develop a web application that you
28 want to deploy on a different environment using version control
29 system (such as PaaS/cloud infrastructure), because it requires you
30 to often commit the META file or "inc/" directory (or even worse,
31 both) to a repository.
32
33 Many web application frameworks generate a boiler-plate
34 "Makefile.PL" for dependency declaration and to let you install
35 dependencies with "cpanm --installdeps .", but that doesn't always
36 mean they are meant to be installed. Things can be often much
37 simpler if you run the application from the checkout directory.
38
39 With cpanfile, dependencies can be installed either globally or
40 locally using supported tools such as cpanm or Carton. Because
41 "cpanfile" lists all the dependencies of your entire application
42 and will be updated over time, it makes perfect sense to commit the
43 file to a version control system, and push the file for a
44 deployment.
45
46 Familiar DSL syntax
47 This is a new file type, but the format and syntax isn't entirely
48 new. The metadata it can declare is exactly a subset of "Prereqs"
49 in CPAN Meta Spec.
50
51 The syntax borrows a lot from Module::Install. Module::Install is a
52 great way to easily declare module metadata such as name, author
53 and dependencies. cpanfile format is simply to extract the
54 dependencies into a separate file, which means most of the
55 developers are familiar with the syntax.
56
57 Complete CPAN Meta Spec v2 support
58 "cpanfile" basically allows you to declare CPAN::Meta::Spec
59 prerequisite specification using an easy Perl DSL syntax. This
60 makes it easy to declare per-phase dependencies and newer version 2
61 features such as conflicts and version ranges.
62
63 How can I start using "cpanfile"?
64 First of all, most distributions on CPAN are not required to update to
65 this format.
66
67 If your application currently uses "Makefile.PL" etc. for dependency
68 declaration because of the current toolchain implementation (e.g.
69 "cpanm --installdeps ."), you can upgrade to "cpanfile" while keeping
70 the build file based installation working for the backward
71 compatibility.
72
73 If you are an author of CPAN module and want to manage CPAN module
74 prerequisites using "cpanfile" you can use one of the following tools:
75
76 Dist::Milla
77 Dist::Milla is a profile for Dist::Zilla that has a "cpanfile"
78 support to declare dependencies for your module.
79
80 Dist::Zilla
81 Dist::Zilla::Plugin::Prereqs::FromCPANfile provides a way to merge
82 dependencies declared in "cpanfile" into META files as well as
83 build files. You can combine them using other prerequisite scanners
84 like "AutoPrereqs".
85
86 Minilla
87 Minilla is a yet another authoring tool that supports "cpanfile" as
88 a way to describe dependencies for your CPAN module.
89
90 Module::Install
91 Module::Install::CPANfile provides a "cpanfile" DSL that reads
92 "cpanfile" to merge prerequisites when dumping "MYMETA" files upon
93 installation.
94
95 Module::Build
96 Module::Build::Pluggable::CPANfile merges "cpanfile" dependencies
97 from "Build.PL" when dumping out MYMETA information.
98
99 However you're recommended to switch to an authoring system that
100 emits "Build.PL" with parsed CPANfile information, like Dist::Zilla
101 mentioned above.
102
103 ExtUtils::MakeMaker
104 ExtUtils::MakeMaker::CPANfile merges "cpanfile" prerequisites when
105 dumping "MYMETA" files upon installation.
106
107 However you're recommended to switch to an authoring system that
108 emits "Makefile.PL" with parsed CPANfile information, like
109 Dist::Zilla mentioned above.
110
111
112
113perl v5.32.0 2020-07-28 cpanfile-faq(3)