1Module::Build::BundlingU(s3e)r Contributed Perl DocumentaMtoidounle::Build::Bundling(3)
2
3
4
6 Module::Build::Bundling - How to bundle Module::Build with a
7 distribution
8
10 # Build.PL
11 use inc::latest 'Module::Build';
12
13 Module::Build->new(
14 module_name => 'Foo::Bar',
15 license => 'perl',
16 )->create_build_script;
17
19 WARNING -- THIS IS AN EXPERIMENTAL FEATURE
20
21 In order to install a distribution using Module::Build, users must have
22 Module::Build available on their systems. There are two ways to do
23 this. The first way is to include Module::Build in the
24 "configure_requires" metadata field. This field is supported by recent
25 versions CPAN and CPANPLUS and is a standard feature in the Perl core
26 as of Perl 5.10.1. Module::Build now adds itself to
27 "configure_requires" by default.
28
29 The second way supports older Perls that have not upgraded CPAN or
30 CPANPLUS and involves bundling an entire copy of Module::Build into the
31 distribution's "inc/" directory. This is the same approach used by
32 Module::Install, a modern wrapper around ExtUtils::MakeMaker for
33 Makefile.PL based distributions.
34
35 The "trick" to making this work for Module::Build is making sure the
36 highest version Module::Build is used, whether this is in "inc/" or
37 already installed on the user's system. This ensures that all
38 necessary features are available as well as any new bug fixes. This is
39 done using the experimental inc::latest module, available on CPAN.
40
41 A "normal" Build.PL looks like this (with only the minimum required
42 fields):
43
44 use Module::Build;
45
46 Module::Build->new(
47 module_name => 'Foo::Bar',
48 license => 'perl',
49 )->create_build_script;
50
51 A "bundling" Build.PL replaces the initial "use" line with a nearly
52 transparent replacement:
53
54 use inc::latest 'Module::Build';
55
56 Module::Build->new(
57 module_name => 'Foo::Bar',
58 license => 'perl',
59 )->create_build_script;
60
61 For authors, when "Build dist" is run, Module::Build will be
62 automatically bundled into "inc" according to the rules for
63 inc::latest.
64
65 For users, inc::latest will load the latest Module::Build, whether
66 installed or bundled in "inc/".
67
69 The same approach works for other configuration dependencies -- modules
70 that must be available for Build.PL to run. All other dependencies can
71 be specified as usual in the Build.PL and CPAN or CPANPLUS will install
72 them after Build.PL finishes.
73
74 For example, to bundle the Devel::AssertOS::Unix module (which ensures
75 a "Unix-like" operating system), one could do this:
76
77 use inc::latest 'Devel::AssertOS::Unix';
78 use inc::latest 'Module::Build';
79
80 Module::Build->new(
81 module_name => 'Foo::Bar',
82 license => 'perl',
83 )->create_build_script;
84
85 The "inc::latest" module creates bundled directories based on the
86 packlist file of an installed distribution. Even though "inc::latest"
87 takes module name arguments, it is better to think of it as bundling
88 and making available entire distributions. When a module is loaded
89 through "inc::latest", it looks in all bundled distributions in "inc/"
90 for a newer module than can be found in the existing @INC array.
91
92 Thus, the module-name provided should usually be the "top-level" module
93 name of a distribution, though this is not strictly required. For
94 example, Module::Build has a number of heuristics to map module names
95 to packlists, allowing users to do things like this:
96
97 use inc::latest 'Devel::AssertOS::Unix';
98
99 even though Devel::AssertOS::Unix is contained within the Devel-CheckOS
100 distribution.
101
102 At the current time, packlists are required. Thus, bundling dual-core
103 modules, including Module::Build, may require a 'forced install' over
104 versions in the latest version of perl in order to create the necessary
105 packlist for bundling. This limitation will hopefully be addressed in
106 a future version of Module::Build.
107
108 WARNING -- How to Manage Dependency Chains
109 Before bundling a distribution you must ensure that all prerequisites
110 are also bundled and load in the correct order. For Module::Build
111 itself, this should not be necessary, but it is necessary for any other
112 distribution. (A future release of Module::Build will hopefully
113 address this deficiency.)
114
115 For example, if you need "Wibble", but "Wibble" depends on "Wobble",
116 your Build.PL might look like this:
117
118 use inc::latest 'Wobble';
119 use inc::latest 'Wibble';
120 use inc::latest 'Module::Build';
121
122 Module::Build->new(
123 module_name => 'Foo::Bar',
124 license => 'perl',
125 )->create_build_script;
126
127 Authors are strongly suggested to limit the bundling of additional
128 dependencies if at all possible and to carefully test their
129 distribution tarballs on older versions of Perl before uploading to
130 CPAN.
131
133 David Golden <dagolden@cpan.org>
134
135 Development questions, bug reports, and patches should be sent to the
136 Module-Build mailing list at <module-build@perl.org>.
137
138 Bug reports are also welcome at
139 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Build>.
140
142 perl(1), inc::latest, Module::Build(3), Module::Build::API(3),
143 Module::Build::Cookbook(3),
144
145
146
147perl v5.30.0 2019-07-26 Module::Build::Bundling(3)