{"id":7332,"date":"2022-12-20T19:37:44","date_gmt":"2022-12-20T22:37:44","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/modulebuildbundling-man3\/"},"modified":"2022-12-20T19:37:44","modified_gmt":"2022-12-20T22:37:44","slug":"modulebuildbundling-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/modulebuildbundling-man3\/","title":{"rendered":"Module::Build::Bundling (man3)"},"content":{"rendered":"<h1 align=\"center\">Module::Build::Bundling<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#BUNDLING OTHER CONFIGURATION DEPENDENCIES\">BUNDLING OTHER CONFIGURATION DEPENDENCIES<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Module::Build::Bundling \u2212 How to bundle Module::Build with a distribution<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"># Build.PL <br \/> use inc::latest &#8216;Module::Build&#8217;; <br \/> Module::Build\u2212>new( <br \/> module_name => &#8216;Foo::Bar&#8217;, <br \/> license => &#8216;perl&#8217;, <br \/> )\u2212>create_build_script;<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b><small>WARNING<\/small> &#8212; <small>THIS IS AN EXPERIMENTAL FEATURE<\/small><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In order to install a distribution using Module::Build, users must have Module::Build available on their systems. There are two ways to do this. The first way is to include Module::Build in the &#8220;configure_requires&#8221; metadata field. This field is supported by recent versions <small>CPAN<\/small> and <small>CPANPLUS<\/small> and is a standard feature in the Perl core as of Perl 5.10.1. Module::Build now adds itself to &#8220;configure_requires&#8221; by default.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The second way supports older Perls that have not upgraded <small>CPAN<\/small> or <small>CPANPLUS<\/small> and involves bundling an entire copy of Module::Build into the distribution\u2019s &#8220;inc\/&#8221; directory. This is the same approach used by Module::Install, a modern wrapper around ExtUtils::MakeMaker for Makefile.PL based distributions.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;trick&#8221; to making this work for Module::Build is making sure the highest version Module::Build is used, whether this is in &#8220;inc\/&#8221; or already installed on the user\u2019s system. This ensures that all necessary features are available as well as any new bug fixes. This is done using the experimental inc::latest module, available on <small>CPAN.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A &#8220;normal&#8221; Build.PL looks like this (with only the minimum required fields):<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use Module::Build; <br \/> Module::Build\u2212>new( <br \/> module_name => &#8216;Foo::Bar&#8217;, <br \/> license => &#8216;perl&#8217;, <br \/> )\u2212>create_build_script;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A &#8220;bundling&#8221; Build.PL replaces the initial &#8220;use&#8221; line with a nearly transparent replacement:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use inc::latest &#8216;Module::Build&#8217;; <br \/> Module::Build\u2212>new( <br \/> module_name => &#8216;Foo::Bar&#8217;, <br \/> license => &#8216;perl&#8217;, <br \/> )\u2212>create_build_script;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For <i>authors<\/i>, when &#8220;Build dist&#8221; is run, Module::Build will be automatically bundled into &#8220;inc&#8221; according to the rules for inc::latest.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For <i>users<\/i>, inc::latest will load the latest Module::Build, whether installed or bundled in &#8220;inc\/&#8221;.<\/p>\n<h2>BUNDLING OTHER CONFIGURATION DEPENDENCIES <a name=\"BUNDLING OTHER CONFIGURATION DEPENDENCIES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The same approach works for other configuration dependencies &#8212; modules that <i>must<\/i> be available for Build.PL to run. All other dependencies can be specified as usual in the Build.PL and <small>CPAN<\/small> or <small>CPANPLUS<\/small> will install them after Build.PL finishes.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For example, to bundle the Devel::AssertOS::Unix module (which ensures a &#8220;Unix-like&#8221; operating system), one could do this:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use inc::latest &#8216;Devel::AssertOS::Unix&#8217;; <br \/> use inc::latest &#8216;Module::Build&#8217;; <br \/> Module::Build\u2212>new( <br \/> module_name => &#8216;Foo::Bar&#8217;, <br \/> license => &#8216;perl&#8217;, <br \/> )\u2212>create_build_script;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;inc::latest&#8221; module creates bundled directories based on the packlist file of an installed distribution. Even though &#8220;inc::latest&#8221; takes module name arguments, it is better to think of it as bundling and making available entire <i>distributions<\/i>. When a module is loaded through &#8220;inc::latest&#8221;, it looks in all bundled distributions in &#8220;inc\/&#8221; for a newer module than can be found in the existing @INC array.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Thus, the module-name provided should usually be the &#8220;top-level&#8221; module name of a distribution, though this is not strictly required. For example, Module::Build has a number of heuristics to map module names to packlists, allowing users to do things like this:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use inc::latest &#8216;Devel::AssertOS::Unix&#8217;;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">even though Devel::AssertOS::Unix is contained within the Devel-CheckOS distribution.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">At the current time, packlists are required. Thus, bundling dual-core modules, <i>including Module::Build<\/i>, may require a \u2019forced install\u2019 over versions in the latest version of perl in order to create the necessary packlist for bundling. This limitation will hopefully be addressed in a future version of Module::Build.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b><small>WARNING<\/small> &#8212; How to Manage Dependency Chains<\/b> <br \/> Before bundling a distribution you must ensure that all prerequisites are also bundled and load in the correct order. For Module::Build itself, this should not be necessary, but it is necessary for any other distribution. (A future release of Module::Build will hopefully address this deficiency.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For example, if you need &#8220;Wibble&#8221;, but &#8220;Wibble&#8221; depends on &#8220;Wobble&#8221;, your Build.PL might look like this:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">use inc::latest &#8216;Wobble&#8217;; <br \/> use inc::latest &#8216;Wibble&#8217;; <br \/> use inc::latest &#8216;Module::Build&#8217;; <br \/> Module::Build\u2212>new( <br \/> module_name => &#8216;Foo::Bar&#8217;, <br \/> license => &#8216;perl&#8217;, <br \/> )\u2212>create_build_script;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Authors are strongly suggested to limit the bundling of additional dependencies if at all possible and to carefully test their distribution tarballs on older versions of Perl before uploading to <small>CPAN.<\/small><\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">David Golden <dagolden@cpan.org><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Development questions, bug reports, and patches should be sent to the Module-Build mailing list at <module\u2212build@perl.org>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Bug reports are also welcome at <http:\/\/rt.cpan.org\/NoAuth\/Bugs.html?Dist=Module\u2212Build>.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>perl<\/b>(1), inc::latest, Module::Build(3), Module::Build::API(3), Module::Build::Cookbook(3),<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Module::Build::Bundling \u2212 How to bundle Module::Build with a distribution <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3650],"class_list":["post-7332","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-modulebuildbundling"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7332"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7332\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}