This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update CPAN-Meta to CPAN version 2.130880
[perl5.git] / cpan / CPAN-Meta / lib / CPAN / Meta / Spec.pm
1 # vi:tw=72
2 use 5.006;
3 use strict;
4 use warnings;
5 package CPAN::Meta::Spec;
6 our $VERSION = '2.130880'; # VERSION
7
8 1;
9
10 # ABSTRACT: specification for CPAN distribution metadata
11
12 __END__
13
14 =pod
15
16 =encoding utf-8
17
18 =head1 NAME
19
20 CPAN::Meta::Spec - specification for CPAN distribution metadata
21
22 =head1 VERSION
23
24 version 2.130880
25
26 =head1 SYNOPSIS
27
28   my $distmeta = {
29     name => 'Module-Build',
30     abstract => 'Build and install Perl modules',
31     description =>  "Module::Build is a system for "
32       . "building, testing, and installing Perl modules. "
33       . "It is meant to ... blah blah blah ...",
34     version  => '0.36',
35     release_status => 'stable',
36     author   => [
37       'Ken Williams <kwilliams@cpan.org>',
38       'Module-Build List <module-build@perl.org>', # additional contact
39     ],
40     license  => [ 'perl_5' ],
41     prereqs => {
42       runtime => {
43         requires => {
44           'perl'   => '5.006',
45           'ExtUtils::Install' => '0',
46           'File::Basename' => '0',
47           'File::Compare'  => '0',
48           'IO::File'   => '0',
49         },
50         recommends => {
51           'Archive::Tar' => '1.00',
52           'ExtUtils::Install' => '0.3',
53           'ExtUtils::ParseXS' => '2.02',
54         },
55       },
56       build => {
57         requires => {
58           'Test::More' => '0',
59         },
60       }
61     },
62     resources => {
63       license => ['http://dev.perl.org/licenses/'],
64     },
65     optional_features => {
66       domination => {
67         description => 'Take over the world',
68         prereqs     => {
69           develop => { requires => { 'Genius::Evil'     => '1.234' } },
70           runtime => { requires => { 'Machine::Weather' => '2.0'   } },
71         },
72       },
73     },
74     dynamic_config => 1,
75     keywords => [ qw/ toolchain cpan dual-life / ],
76     'meta-spec' => {
77       version => '2',
78       url     => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
79     },
80     generated_by => 'Module::Build version 0.36',
81   };
82
83 =head1 DESCRIPTION
84
85 This document describes version 2 of the CPAN distribution metadata
86 specification, also known as the "CPAN Meta Spec".
87
88 Revisions of this specification for typo corrections and prose
89 clarifications may be issued as CPAN::Meta::Spec 2.I<x>.  These
90 revisions will never change semantics or add or remove specified
91 behavior.
92
93 Distribution metadata describe important properties of Perl
94 distributions. Distribution building tools like Module::Build,
95 Module::Install, ExtUtils::MakeMaker or Dist::Zilla should create a
96 metadata file in accordance with this specification and include it with
97 the distribution for use by automated tools that index, examine, package
98 or install Perl distributions.
99
100 =head1 TERMINOLOGY
101
102 =over 4
103
104 =item distribution
105
106 This is the primary object described by the metadata. In the context of
107 this document it usually refers to a collection of modules, scripts,
108 and/or documents that are distributed together for other developers to
109 use.  Examples of distributions are C<Class-Container>, C<libwww-perl>,
110 or C<DBI>.
111
112 =item module
113
114 This refers to a reusable library of code contained in a single file.
115 Modules usually contain one or more packages and are often referred
116 to by the name of a primary package that can be mapped to the file
117 name. For example, one might refer to C<File::Spec> instead of
118 F<File/Spec.pm>
119
120 =item package
121
122 This refers to a namespace declared with the Perl C<package> statement.
123 In Perl, packages often have a version number property given by the
124 C<$VERSION> variable in the namespace.
125
126 =item consumer
127
128 This refers to code that reads a metadata file, deserializes it into a
129 data structure in memory, or interprets a data structure of metadata
130 elements.
131
132 =item producer
133
134 This refers to code that constructs a metadata data structure,
135 serializes into a bytestream and/or writes it to disk.
136
137 =item must, should, may, etc.
138
139 These terms are interpreted as described in IETF RFC 2119.
140
141 =back
142
143 =head1 DATA TYPES
144
145 Fields in the L</STRUCTURE> section describe data elements, each of
146 which has an associated data type as described herein.  There are four
147 primitive types: Boolean, String, List and Map.  Other types are
148 subtypes of primitives and define compound data structures or define
149 constraints on the values of a data element.
150
151 =head2 Boolean
152
153 A I<Boolean> is used to provide a true or false value.  It B<must> be
154 represented as a defined value.
155
156 =head2 String
157
158 A I<String> is data element containing a non-zero length sequence of
159 Unicode characters, such as an ordinary Perl scalar that is not a
160 reference.
161
162 =head2 List
163
164 A I<List> is an ordered collection of zero or more data elements.
165 Elements of a List may be of mixed types.
166
167 Producers B<must> represent List elements using a data structure which
168 unambiguously indicates that multiple values are possible, such as a
169 reference to a Perl array (an "arrayref").
170
171 Consumers expecting a List B<must> consider a String as equivalent to a
172 List of length 1.
173
174 =head2 Map
175
176 A I<Map> is an unordered collection of zero or more data elements
177 ("values"), indexed by associated String elements ("keys").  The Map's
178 value elements may be of mixed types.
179
180 =head2 License String
181
182 A I<License String> is a subtype of String with a restricted set of
183 values.  Valid values are described in detail in the description of
184 the L</license> field.
185
186 =head2 URL
187
188 I<URL> is a subtype of String containing a Uniform Resource Locator or
189 Identifier.  [ This type is called URL and not URI for historical reasons. ]
190
191 =head2 Version
192
193 A I<Version> is a subtype of String containing a value that describes
194 the version number of packages or distributions.  Restrictions on format
195 are described in detail in the L</Version Formats> section.
196
197 =head2 Version Range
198
199 The I<Version Range> type is a subtype of String.  It describes a range
200 of Versions that may be present or installed to fulfill prerequisites.
201 It is specified in detail in the L</Version Ranges> section.
202
203 =head1 STRUCTURE
204
205 The metadata structure is a data element of type Map.  This section
206 describes valid keys within the Map.
207
208 Any keys not described in this specification document (whether top-level
209 or within compound data structures described herein) are considered
210 I<custom keys> and B<must> begin with an "x" or "X" and be followed by an
211 underscore; i.e. they must match the pattern: C<< qr{\Ax_}i >>.  If a
212 custom key refers to a compound data structure, subkeys within it do not
213 need an "x_" or "X_" prefix.
214
215 Consumers of metadata may ignore any or all custom keys.  All other keys
216 not described herein are invalid and should be ignored by consumers.
217 Producers must not generate or output invalid keys.
218
219 For each key, an example is provided followed by a description.  The
220 description begins with the version of spec in which the key was added
221 or in which the definition was modified, whether the key is I<required>
222 or I<optional> and the data type of the corresponding data element.
223 These items are in parentheses, brackets and braces, respectively.
224
225 If a data type is a Map or Map subtype, valid subkeys will be described
226 as well.
227
228 Some fields are marked I<Deprecated>.  These are shown for historical
229 context and must not be produced in or consumed from any metadata structure
230 of version 2 or higher.
231
232 =head2 REQUIRED FIELDS
233
234 =head3 abstract
235
236 Example:
237
238   abstract => 'Build and install Perl modules'
239
240 (Spec 1.2) [required] {String}
241
242 This is a short description of the purpose of the distribution.
243
244 =head3 author
245
246 Example:
247
248   author => [ 'Ken Williams <kwilliams@cpan.org>' ]
249
250 (Spec 1.2) [required] {List of one or more Strings}
251
252 This List indicates the person(s) to contact concerning the
253 distribution. The preferred form of the contact string is:
254
255   contact-name <email-address>
256
257 This field provides a general contact list independent of other
258 structured fields provided within the L</resources> field, such as
259 C<bugtracker>.  The addressee(s) can be contacted for any purpose
260 including but not limited to (security) problems with the distribution,
261 questions about the distribution or bugs in the distribution.
262
263 A distribution's original author is usually the contact listed within
264 this field.  Co-maintainers, successor maintainers or mailing lists
265 devoted to the distribution may also be listed in addition to or instead
266 of the original author.
267
268 =head3 dynamic_config
269
270 Example:
271
272   dynamic_config => 1
273
274 (Spec 2) [required] {Boolean}
275
276 A boolean flag indicating whether a F<Build.PL> or F<Makefile.PL> (or
277 similar) must be executed to determine prerequisites.
278
279 This field should be set to a true value if the distribution performs
280 some dynamic configuration (asking questions, sensing the environment,
281 etc.) as part of its configuration.  This field should be set to a false
282 value to indicate that prerequisites included in metadata may be
283 considered final and valid for static analysis.
284
285 This field explicitly B<does not> indicate whether installation may be
286 safely performed without using a Makefile or Build file, as there may be
287 special files to install or custom installation targets (e.g. for
288 dual-life modules that exist on CPAN as well as in the Perl core).  This
289 field only defines whether prerequisites are complete as given in the
290 metadata.
291
292 =head3 generated_by
293
294 Example:
295
296   generated_by => 'Module::Build version 0.36'
297
298 (Spec 1.0) [required] {String}
299
300 This field indicates the tool that was used to create this metadata.
301 There are no defined semantics for this field, but it is traditional to
302 use a string in the form "Generating::Package version 1.23" or the
303 author's name, if the file was generated by hand.
304
305 =head3 license
306
307 Example:
308
309   license => [ 'perl_5' ]
310
311   license => [ 'apache_2', 'mozilla_1_0' ]
312
313 (Spec 2) [required] {List of one or more License Strings}
314
315 One or more licenses that apply to some or all of the files in the
316 distribution.  If multiple licenses are listed, the distribution
317 documentation should be consulted to clarify the interpretation of
318 multiple licenses.
319
320 The following list of license strings are valid:
321
322  string          description
323  -------------   -----------------------------------------------
324  agpl_3          GNU Affero General Public License, Version 3
325  apache_1_1      Apache Software License, Version 1.1
326  apache_2_0      Apache License, Version 2.0
327  artistic_1      Artistic License, (Version 1)
328  artistic_2      Artistic License, Version 2.0
329  bsd             BSD License (three-clause)
330  freebsd         FreeBSD License (two-clause)
331  gfdl_1_2        GNU Free Documentation License, Version 1.2
332  gfdl_1_3        GNU Free Documentation License, Version 1.3
333  gpl_1           GNU General Public License, Version 1
334  gpl_2           GNU General Public License, Version 2
335  gpl_3           GNU General Public License, Version 3
336  lgpl_2_1        GNU Lesser General Public License, Version 2.1
337  lgpl_3_0        GNU Lesser General Public License, Version 3.0
338  mit             MIT (aka X11) License
339  mozilla_1_0     Mozilla Public License, Version 1.0
340  mozilla_1_1     Mozilla Public License, Version 1.1
341  openssl         OpenSSL License
342  perl_5          The Perl 5 License (Artistic 1 & GPL 1 or later)
343  qpl_1_0         Q Public License, Version 1.0
344  ssleay          Original SSLeay License
345  sun             Sun Internet Standards Source License (SISSL)
346  zlib            zlib License
347
348 The following license strings are also valid and indicate other
349 licensing not described above:
350
351  string          description
352  -------------   -----------------------------------------------
353  open_source     Other Open Source Initiative (OSI) approved license
354  restricted      Requires special permission from copyright holder
355  unrestricted    Not an OSI approved license, but not restricted
356  unknown         License not provided in metadata
357
358 All other strings are invalid in the license field.
359
360 =head3 meta-spec
361
362 Example:
363
364   'meta-spec' => {
365     version => '2',
366     url     => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
367   }
368
369 (Spec 1.2) [required] {Map}
370
371 This field indicates the version of the CPAN Meta Spec that should be
372 used to interpret the metadata.  Consumers must check this key as soon
373 as possible and abort further metadata processing if the meta-spec
374 version is not supported by the consumer.
375
376 The following keys are valid, but only C<version> is required.
377
378 =over
379
380 =item version
381
382 This subkey gives the integer I<Version> of the CPAN Meta Spec against
383 which the document was generated.
384
385 =item url
386
387 This is a I<URL> of the metadata specification document corresponding to
388 the given version.  This is strictly for human-consumption and should
389 not impact the interpretation of the document.
390
391 =back
392
393 =head3 name
394
395 Example:
396
397   name => 'Module-Build'
398
399 (Spec 1.0) [required] {String}
400
401 This field is the name of the distribution.  This is often created by
402 taking the "main package" in the distribution and changing C<::> to
403 C<->, but the name may be completely unrelated to the packages within
404 the distribution.  C.f. L<http://search.cpan.org/dist/libwww-perl/>.
405
406 =head3 release_status
407
408 Example:
409
410   release_status => 'stable'
411
412 (Spec 2) [required] {String}
413
414 This field provides the  release status of this distribution.  If the
415 C<version> field contains an underscore character, then
416 C<release_status> B<must not> be "stable."
417
418 The C<release_status> field B<must> have one of the following values:
419
420 =over
421
422 =item stable
423
424 This indicates an ordinary, "final" release that should be indexed by PAUSE
425 or other indexers.
426
427 =item testing
428
429 This indicates a "beta" release that is substantially complete, but has an
430 elevated risk of bugs and requires additional testing.  The distribution
431 should not be installed over a stable release without an explicit request
432 or other confirmation from a user.  This release status may also be used
433 for "release candidate" versions of a distribution.
434
435 =item unstable
436
437 This indicates an "alpha" release that is under active development, but has
438 been released for early feedback or testing and may be missing features or
439 may have serious bugs.  The distribution should not be installed over a
440 stable release without an explicit request or other confirmation from a
441 user.
442
443 =back
444
445 Consumers B<may> use this field to determine how to index the
446 distribution for CPAN or other repositories in addition to or in
447 replacement of heuristics based on version number or file name.
448
449 =head3 version
450
451 Example:
452
453   version => '0.36'
454
455 (Spec 1.0) [required] {Version}
456
457 This field gives the version of the distribution to which the metadata
458 structure refers.
459
460 =head2 OPTIONAL FIELDS
461
462 =head3 description
463
464 Example:
465
466     description =>  "Module::Build is a system for "
467       . "building, testing, and installing Perl modules. "
468       . "It is meant to ... blah blah blah ...",
469
470 (Spec 2) [optional] {String}
471
472 A longer, more complete description of the purpose or intended use of
473 the distribution than the one provided by the C<abstract> key.
474
475 =head3 keywords
476
477 Example:
478
479   keywords => [ qw/ toolchain cpan dual-life / ]
480
481 (Spec 1.1) [optional] {List of zero or more Strings}
482
483 A List of keywords that describe this distribution.  Keywords
484 B<must not> include whitespace.
485
486 =head3 no_index
487
488 Example:
489
490   no_index => {
491     file      => [ 'My/Module.pm' ],
492     directory => [ 'My/Private' ],
493     package   => [ 'My::Module::Secret' ],
494     namespace => [ 'My::Module::Sample' ],
495   }
496
497 (Spec 1.2) [optional] {Map}
498
499 This Map describes any files, directories, packages, and namespaces that
500 are private to the packaging or implementation of the distribution and
501 should be ignored by indexing or search tools.
502
503 Valid subkeys are as follows:
504
505 =over
506
507 =item file
508
509 A I<List> of relative paths to files.  Paths B<must be> specified with
510 unix conventions.
511
512 =item directory
513
514 A I<List> of relative paths to directories.  Paths B<must be> specified
515 with unix conventions.
516
517 [ Note: previous editions of the spec had C<dir> instead of C<directory> ]
518
519 =item package
520
521 A I<List> of package names.
522
523 =item namespace
524
525 A I<List> of package namespaces, where anything below the namespace
526 must be ignored, but I<not> the namespace itself.
527
528 In the example above for C<no_index>, C<My::Module::Sample::Foo> would
529 be ignored, but C<My::Module::Sample> would not.
530
531 =back
532
533 =head3 optional_features
534
535 Example:
536
537   optional_features => {
538     sqlite => {
539       description => 'Provides SQLite support',
540       prereqs => {
541         runtime => {
542           requires => {
543             'DBD::SQLite' => '1.25'
544           }
545         }
546       }
547     }
548   }
549
550 (Spec 2) [optional] {Map}
551
552 This Map describes optional features with incremental prerequisites.
553 Each key of the C<optional_features> Map is a String used to identify
554 the feature and each value is a Map with additional information about
555 the feature.  Valid subkeys include:
556
557 =over
558
559 =item description
560
561 This is a String describing the feature.  Every optional feature
562 should provide a description
563
564 =item prereqs
565
566 This entry is required and has the same structure as that of the
567 C<L</prereqs>> key.  It provides a list of package requirements
568 that must be satisfied for the feature to be supported or enabled.
569
570 There is one crucial restriction:  the prereqs of an optional feature
571 B<must not> include C<configure> phase prereqs.
572
573 =back
574
575 Consumers B<must not> include optional features as prerequisites without
576 explicit instruction from users (whether via interactive prompting,
577 a function parameter or a configuration value, etc. ).
578
579 If an optional feature is used by a consumer to add additional
580 prerequisites, the consumer should merge the optional feature
581 prerequisites into those given by the C<prereqs> key using the same
582 semantics.  See L</Merging and Resolving Prerequisites> for details on
583 merging prerequisites.
584
585 I<Suggestion for disuse:> Because there is currently no way for a
586 distribution to specify a dependency on an optional feature of another
587 dependency, the use of C<optional_feature> is discouraged.  Instead,
588 create a separate, installable distribution that ensures the desired
589 feature is available.  For example, if C<Foo::Bar> has a "Baz" feature,
590 release a separate C<Foo-Bar-Baz> distribution that satisfies
591 requirements for the feature.
592
593 =head3 prereqs
594
595 Example:
596
597   prereqs => {
598     runtime => {
599       requires => {
600         'perl'          => '5.006',
601         'File::Spec'    => '0.86',
602         'JSON'          => '2.16',
603       },
604       recommends => {
605         'JSON::XS'      => '2.26',
606       },
607       suggests => {
608         'Archive::Tar'  => '0',
609       },
610     },
611     build => {
612       requires => {
613         'Alien::SDL'    => '1.00',
614       },
615     },
616     test => {
617       recommends => {
618         'Test::Deep'    => '0.10',
619       },
620     }
621   }
622
623 (Spec 2) [optional] {Map}
624
625 This is a Map that describes all the prerequisites of the distribution.
626 The keys are phases of activity, such as C<configure>, C<build>, C<test>
627 or C<runtime>.  Values are Maps in which the keys name the type of
628 prerequisite relationship such as C<requires>, C<recommends>, or
629 C<suggests> and the value provides a set of prerequisite relations.  The
630 set of relations B<must> be specified as a Map of package names to
631 version ranges.
632
633 The full definition for this field is given in the L</Prereq Spec>
634 section.
635
636 =head3 provides
637
638 Example:
639
640   provides => {
641     'Foo::Bar' => {
642       file    => 'lib/Foo/Bar.pm',
643       version => 0.27_02
644     },
645     'Foo::Bar::Blah' => {
646       file    => 'lib/Foo/Bar/Blah.pm',
647     },
648     'Foo::Bar::Baz' => {
649       file    => 'lib/Foo/Bar/Baz.pm',
650       version => 0.3,
651     },
652   }
653
654 (Spec 1.2) [optional] {Map}
655
656 This describes all packages provided by this distribution.  This
657 information is used by distribution and automation mechanisms like
658 PAUSE, CPAN, and search.cpan.org to build indexes saying in which
659 distribution various packages can be found.
660
661 The keys of C<provides> are package names that can be found within
662 the distribution.  The values are Maps with the following valid subkeys:
663
664 =over
665
666 =item file
667
668 This field is required.  The value must contain a Unix-style relative
669 file path from the root of the distribution to the module containing the
670 package.
671
672 =item version
673
674 This field contains a I<Version> String for the package, if one exists.
675
676 =back
677
678 =head3 resources
679
680 Example:
681
682   resources => {
683     license     => [ 'http://dev.perl.org/licenses/' ],
684     homepage    => 'http://sourceforge.net/projects/module-build',
685     bugtracker  => {
686       web    => 'http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Meta',
687       mailto => 'meta-bugs@example.com',
688     },
689     repository  => {
690       url  => 'git://github.com/dagolden/cpan-meta.git',
691       web  => 'http://github.com/dagolden/cpan-meta',
692       type => 'git',
693     },
694     x_twitter   => 'http://twitter.com/cpan_linked/',
695   }
696
697 (Spec 2) [optional] {Map}
698
699 This field describes resources related to this distribution.
700
701 Valid subkeys include:
702
703 =over
704
705 =item homepage
706
707 The official home of this project on the web.
708
709 =item license
710
711 A List of I<URL>'s that relate to this distribution's license.  As with the
712 top-level C<license> field, distribution documentation should be consulted
713 to clarify the interpretation of multiple licenses provided here.
714
715 =item bugtracker
716
717 This entry describes the bug tracking system for this distribution.  It
718 is a Map with the following valid keys:
719
720   web    - a URL pointing to a web front-end for the bug tracker
721   mailto - an email address to which bugs can be sent
722
723 =item repository
724
725 This entry describes the source control repository for this distribution.  It
726 is a Map with the following valid keys:
727
728   url  - a URL pointing to the repository itself
729   web  - a URL pointing to a web front-end for the repository
730   type - a lowercase string indicating the VCS used
731
732 Because a url like C<http://myrepo.example.com/> is ambiguous as to
733 type, producers should provide a C<type> whenever a C<url> key is given.
734 The C<type> field should be the name of the most common program used
735 to work with the repository, e.g. git, svn, cvs, darcs, bzr or hg.
736
737 =back
738
739 =head2 DEPRECATED FIELDS
740
741 =head3 build_requires
742
743 I<(Deprecated in Spec 2)> [optional] {String}
744
745 Replaced by C<prereqs>
746
747 =head3 configure_requires
748
749 I<(Deprecated in Spec 2)> [optional] {String}
750
751 Replaced by C<prereqs>
752
753 =head3 conflicts
754
755 I<(Deprecated in Spec 2)> [optional] {String}
756
757 Replaced by C<prereqs>
758
759 =head3 distribution_type
760
761 I<(Deprecated in Spec 2)> [optional] {String}
762
763 This field indicated 'module' or 'script' but was considered
764 meaningless, since many distributions are hybrids of several kinds of
765 things.
766
767 =head3 license_uri
768
769 I<(Deprecated in Spec 1.2)> [optional] {URL}
770
771 Replaced by C<license> in C<resources>
772
773 =head3 private
774
775 I<(Deprecated in Spec 1.2)> [optional] {Map}
776
777 This field has been renamed to L</"no_index">.
778
779 =head3 recommends
780
781 I<(Deprecated in Spec 2)> [optional] {String}
782
783 Replaced by C<prereqs>
784
785 =head3 requires
786
787 I<(Deprecated in Spec 2)> [optional] {String}
788
789 Replaced by C<prereqs>
790
791 =head1 VERSION NUMBERS
792
793 =head2 Version Formats
794
795 This section defines the Version type, used by several fields in the
796 CPAN Meta Spec.
797
798 Version numbers must be treated as strings, not numbers.  For
799 example, C<1.200> B<must not> be serialized as C<1.2>.  Version
800 comparison should be delegated to the Perl L<version> module, version
801 0.80 or newer.
802
803 Unless otherwise specified, version numbers B<must> appear in one of two
804 formats:
805
806 =over
807
808 =item Decimal versions
809
810 Decimal versions are regular "decimal numbers", with some limitations.
811 They B<must> be non-negative and B<must> begin and end with a digit.  A
812 single underscore B<may> be included, but B<must> be between two digits.
813 They B<must not> use exponential notation ("1.23e-2").
814
815    version => '1.234'       # OK
816    version => '1.23_04'     # OK
817
818    version => '1.23_04_05'  # Illegal
819    version => '1.'          # Illegal
820    version => '.1'          # Illegal
821
822 =item Dotted-integer versions
823
824 Dotted-integer (also known as dotted-decimal) versions consist of
825 positive integers separated by full stop characters (i.e. "dots",
826 "periods" or "decimal points").  This are equivalent in format to Perl
827 "v-strings", with some additional restrictions on form.  They must be
828 given in "normal" form, which has a leading "v" character and at least
829 three integer components.  To retain a one-to-one mapping with decimal
830 versions, all components after the first B<should> be restricted to the
831 range 0 to 999.  The final component B<may> be separated by an
832 underscore character instead of a period.
833
834    version => 'v1.2.3'      # OK
835    version => 'v1.2_3'      # OK
836    version => 'v1.2.3.4'    # OK
837    version => 'v1.2.3_4'    # OK
838    version => 'v2009.10.31' # OK
839
840    version => 'v1.2'          # Illegal
841    version => '1.2.3'         # Illegal
842    version => 'v1.2_3_4'      # Illegal
843    version => 'v1.2009.10.31' # Not recommended
844
845 =back
846
847 =head2 Version Ranges
848
849 Some fields (prereq, optional_features) indicate the particular
850 version(s) of some other module that may be required as a prerequisite.
851 This section details the Version Range type used to provide this
852 information.
853
854 The simplest format for a Version Range is just the version
855 number itself, e.g. C<2.4>.  This means that B<at least> version 2.4
856 must be present.  To indicate that B<any> version of a prerequisite is
857 okay, even if the prerequisite doesn't define a version at all, use
858 the version C<0>.
859
860 Alternatively, a version range B<may> use the operators E<lt> (less than),
861 E<lt>= (less than or equal), E<gt> (greater than), E<gt>= (greater than
862 or equal), == (equal), and != (not equal).  For example, the
863 specification C<E<lt> 2.0> means that any version of the prerequisite
864 less than 2.0 is suitable.
865
866 For more complicated situations, version specifications B<may> be AND-ed
867 together using commas.  The specification C<E<gt>= 1.2, != 1.5, E<lt>
868 2.0> indicates a version that must be B<at least> 1.2, B<less than> 2.0,
869 and B<not equal to> 1.5.
870
871 =head1 PREREQUISITES
872
873 =head2 Prereq Spec
874
875 The C<prereqs> key in the top-level metadata and within
876 C<optional_features> define the relationship between a distribution and
877 other packages.  The prereq spec structure is a hierarchical data
878 structure which divides prerequisites into I<Phases> of activity in the
879 installation process and I<Relationships> that indicate how
880 prerequisites should be resolved.
881
882 For example, to specify that C<Data::Dumper> is C<required> during the
883 C<test> phase, this entry would appear in the distribution metadata:
884
885   prereqs => {
886     test => {
887       requires => {
888         'Data::Dumper' => '2.00'
889       }
890     }
891   }
892
893 =head3 Phases
894
895 Requirements for regular use must be listed in the C<runtime> phase.
896 Other requirements should be listed in the earliest stage in which they
897 are required and consumers must accumulate and satisfy requirements
898 across phases before executing the activity. For example, C<build>
899 requirements must also be available during the C<test> phase.
900
901   before action       requirements that must be met
902   ----------------    --------------------------------
903   perl Build.PL       configure
904   perl Makefile.PL
905
906   make                configure, runtime, build
907   Build
908
909   make test           configure, runtime, build, test
910   Build test
911
912 Consumers that install the distribution must ensure that
913 I<runtime> requirements are also installed and may install
914 dependencies from other phases.
915
916   after action        requirements that must be met
917   ----------------    --------------------------------
918   make install        runtime
919   Build install
920
921 =over
922
923 =item configure
924
925 The configure phase occurs before any dynamic configuration has been
926 attempted.  Libraries required by the configure phase B<must> be
927 available for use before the distribution building tool has been
928 executed.
929
930 =item build
931
932 The build phase is when the distribution's source code is compiled (if
933 necessary) and otherwise made ready for installation.
934
935 =item test
936
937 The test phase is when the distribution's automated test suite is run.
938 Any library that is needed only for testing and not for subsequent use
939 should be listed here.
940
941 =item runtime
942
943 The runtime phase refers not only to when the distribution's contents
944 are installed, but also to its continued use.  Any library that is a
945 prerequisite for regular use of this distribution should be indicated
946 here.
947
948 =item develop
949
950 The develop phase's prereqs are libraries needed to work on the
951 distribution's source code as its author does.  These tools might be
952 needed to build a release tarball, to run author-only tests, or to
953 perform other tasks related to developing new versions of the
954 distribution.
955
956 =back
957
958 =head3 Relationships
959
960 =over
961
962 =item requires
963
964 These dependencies B<must> be installed for proper completion of the
965 phase.
966
967 =item recommends
968
969 Recommended dependencies are I<strongly> encouraged and should be
970 satisfied except in resource constrained environments.
971
972 =item suggests
973
974 These dependencies are optional, but are suggested for enhanced operation
975 of the described distribution.
976
977 =item conflicts
978
979 These libraries cannot be installed when the phase is in operation.
980 This is a very rare situation, and the C<conflicts> relationship should
981 be used with great caution, or not at all.
982
983 =back
984
985 =head2 Merging and Resolving Prerequisites
986
987 Whenever metadata consumers merge prerequisites, either from different
988 phases or from C<optional_features>, they should merged in a way which
989 preserves the intended semantics of the prerequisite structure.  Generally,
990 this means concatenating the version specifications using commas, as
991 described in the L<Version Ranges> section.
992
993 Another subtle error that can occur in resolving prerequisites comes from
994 the way that modules in prerequisites are indexed to distribution files on
995 CPAN.  When a module is deleted from a distribution, prerequisites calling
996 for that module could indicate an older distribution should installed,
997 potentially overwriting files from a newer distribution.
998
999 For example, as of Oct 31, 2009, the CPAN index file contained these
1000 module-distribution mappings:
1001
1002   Class::MOP                   0.94  D/DR/DROLSKY/Class-MOP-0.94.tar.gz
1003   Class::MOP::Class            0.94  D/DR/DROLSKY/Class-MOP-0.94.tar.gz
1004   Class::MOP::Class::Immutable 0.04  S/ST/STEVAN/Class-MOP-0.36.tar.gz
1005
1006 Consider the case where "Class::MOP" 0.94 is installed.  If a
1007 distribution specified "Class::MOP::Class::Immutable" as a prerequisite,
1008 it could result in Class-MOP-0.36.tar.gz being installed, overwriting
1009 any files from Class-MOP-0.94.tar.gz.
1010
1011 Consumers of metadata B<should> test whether prerequisites would result
1012 in installed module files being "downgraded" to an older version and
1013 B<may> warn users or ignore the prerequisite that would cause such a
1014 result.
1015
1016 =head1 SERIALIZATION
1017
1018 Distribution metadata should be serialized (as a hashref) as
1019 JSON-encoded data and packaged with distributions as the file
1020 F<META.json>.
1021
1022 In the past, the distribution metadata structure had been packed with
1023 distributions as F<META.yml>, a file in the YAML Tiny format (for which,
1024 see L<YAML::Tiny>).  Tools that consume distribution metadata from disk
1025 should be capable of loading F<META.yml>, but should prefer F<META.json>
1026 if both are found.
1027
1028 =head1 NOTES FOR IMPLEMENTORS
1029
1030 =head2 Extracting Version Numbers from Perl Modules
1031
1032 To get the version number from a Perl module, consumers should use the
1033 C<< MM->parse_version($file) >> method provided by
1034 L<ExtUtils::MakeMaker> or L<Module::Metadata>.  For example, for the
1035 module given by C<$mod>, the version may be retrieved in one of the
1036 following ways:
1037
1038   # via ExtUtils::MakeMaker
1039   my $file = MM->_installed_file_for_module($mod);
1040   my $version = MM->parse_version($file)
1041
1042 The private C<_installed_file_for_module> method may be replaced with
1043 other methods for locating a module in C<@INC>.
1044
1045   # via Module::Metadata
1046   my $info = Module::Metadata->new_from_module($mod);
1047   my $version = $info->version;
1048
1049 If only a filename is available, the following approach may be used:
1050
1051   # via Module::Build
1052   my $info = Module::Metadata->new_from_file($file);
1053   my $version = $info->version;
1054
1055 =head2 Comparing Version Numbers
1056
1057 The L<version> module provides the most reliable way to compare version
1058 numbers in all the various ways they might be provided or might exist
1059 within modules.  Given two strings containing version numbers, C<$v1> and
1060 C<$v2>, they should be converted to C<version> objects before using
1061 ordinary comparison operators.  For example:
1062
1063   use version;
1064   if ( version->new($v1) <=> version->new($v2) ) {
1065     print "Versions are not equal\n";
1066   }
1067
1068 If the only comparison needed is whether an installed module is of a
1069 sufficiently high version, a direct test may be done using the string
1070 form of C<eval> and the C<use> function.  For example, for module C<$mod>
1071 and version prerequisite C<$prereq>:
1072
1073   if ( eval "use $mod $prereq (); 1" ) {
1074     print "Module $mod version is OK.\n";
1075   }
1076
1077 If the values of C<$mod> and C<$prereq> have not been scrubbed, however,
1078 this presents security implications.
1079
1080 =head1 SEE ALSO
1081
1082 CPAN, L<http://www.cpan.org/>
1083
1084 CPAN.pm, L<http://search.cpan.org/dist/CPAN/>
1085
1086 CPANPLUS, L<http://search.cpan.org/dist/CPANPLUS/>
1087
1088 ExtUtils::MakeMaker, L<http://search.cpan.org/dist/ExtUtils-MakeMaker/>
1089
1090 Module::Build, L<http://search.cpan.org/dist/Module-Build/>
1091
1092 Module::Install, L<http://search.cpan.org/dist/Module-Install/>
1093
1094 JSON, L<http://json.org/>
1095
1096 YAML, L<http://www.yaml.org/>
1097
1098 =head1 CONTRIBUTORS
1099
1100 Ken Williams wrote the original CPAN Meta Spec (also known as the
1101 "META.yml spec") in 2003 and maintained it through several revisions
1102 with input from various members of the community.  In 2005, Randy
1103 Sims redrafted it from HTML to POD for the version 1.2 release.  Ken
1104 continued to maintain the spec through version 1.4.
1105
1106 In late 2009, David Golden organized the version 2 proposal review
1107 process.  David and Ricardo Signes drafted the final version 2 spec
1108 in April 2010 based on the version 1.4 spec and patches contributed
1109 during the proposal process.
1110
1111 Several others have contributed patches over the years.  The full list
1112 of contributors in the repository history currently includes:
1113
1114   2shortplanks
1115   Avar Arnfjord Bjarmason
1116   Christopher J. Madsen
1117   Damyan Ivanov
1118   David Golden
1119   Eric Wilhelm
1120   Ken Williams
1121   Lars DIECKOW
1122   Michael G. Schwern
1123   Randy Sims
1124   Ricardo Signes
1125
1126 =head1 AUTHORS
1127
1128 =over 4
1129
1130 =item *
1131
1132 David Golden <dagolden@cpan.org>
1133
1134 =item *
1135
1136 Ricardo Signes <rjbs@cpan.org>
1137
1138 =back
1139
1140 =head1 CONTRIBUTORS
1141
1142 =over 4
1143
1144 =item *
1145
1146 Ansgar Burchardt <ansgar@cpan.org>
1147
1148 =item *
1149
1150 Michael G. Schwern <mschwern@cpan.org>
1151
1152 =item *
1153
1154 Randy Sims <randys@thepierianspring.org>
1155
1156 =item *
1157
1158 Ævar Arnfjörð Bjarmason <avar@cpan.org>
1159
1160 =item *
1161
1162 Christopher J. Madsen <cjm@cpan.org>
1163
1164 =item *
1165
1166 Cory G Watson <gphat@cpan.org>
1167
1168 =item *
1169
1170 Damyan Ivanov <dam@cpan.org>
1171
1172 =item *
1173
1174 Eric Wilhelm <ewilhelm@cpan.org>
1175
1176 =item *
1177
1178 Gregor Hermann <gregoa@debian.org>
1179
1180 =item *
1181
1182 Ken Williams <kwilliams@cpan.org>
1183
1184 =item *
1185
1186 Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯 <daxim@cpan.org>
1187
1188 =item *
1189
1190 Leon Timmermans <leont@cpan.org>
1191
1192 =item *
1193
1194 Mark Fowler <markf@cpan.org>
1195
1196 =back
1197
1198 =head1 COPYRIGHT AND LICENSE
1199
1200 This software is copyright (c) 2010 by David Golden and Ricardo Signes.
1201
1202 This is free software; you can redistribute it and/or modify it under
1203 the same terms as the Perl 5 programming language system itself.
1204
1205 =cut