Make your CPAN module static installable
-
Upload
shoichi-kaji -
Category
Technology
-
view
164 -
download
0
Transcript of Make your CPAN module static installable
![Page 1: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/1.jpg)
Make your CPAN module static installable
Shoichi Kaji
![Page 2: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/2.jpg)
Me
CPAN, github: skaji
Shoichi Kaji
![Page 3: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/3.jpg)
Agenda• Typical CPAN module installation
• Introduce static install
• Why do you adopt static install?
• DEMO
• How to make your CPAN module static installable
• Conclusion
![Page 4: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/4.jpg)
Typical way
• This is a typical CPAN module installation
• Bundled Makefile.PL knows how to configure/build/test/install the CPAN module
• So you don’t need any tools to install CPAN modules; this is good
• CPAN modules can do almost anything in Makefile.PL; this is powerful
wget http://www.cpan.org/.../Module-0.1.tar.gztar xzf Module-0.1.tar.gzcd Module-0.1perl Makefile.PL # or perl Build.PLmakemake testmake install
![Page 5: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/5.jpg)
BTW
• Nowadays, a lot of people use CPAN clients, such as cpanm to install CPAN modules
• If CPAN modules are not "complicated", then CPAN clients easily expect how to configure/build/test/install them
• … do we really need Makefile.PL?
![Page 6: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/6.jpg)
Introduce static install• Now we have the concept static install introduced by
Leon Timmermans (sorry if I am wrong)
• That is, if CPAN modules - are not "complicated"- set x_static_install 1 in their META.jsonthen CPAN clients may configure/build/test/install them in the common way without executing Makefile.PL
• cpanm-menlo and cpm already support static install
![Page 7: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/7.jpg)
Why do you adopt static install?
• Fastwe don’t need to execute Makefile.PL, which makes CPAN module installation much faster
• Simple People can easily expect results (eg: which files are installed and where)
• SafeThere is no place to execute arbitrary code during configure/build/install steps
![Page 8: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/8.jpg)
DEMOhttps://gist.github.com/skaji/
24de4a819ca4a84b2018f5ee996ac52a
![Page 9: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/9.jpg)
How to make your CPAN module static installable
• First, check your CPAN modules are not complicated
• pm files are in lib/
• executable files are in script/ (if any)
• prereqs are declared in META.json statically
• no xs file, no Module_pm.PL file
![Page 10: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/10.jpg)
How to make your CPAN module static installable
• Here I assume you use Minilla
• Modify toml.minil as follows
• Then your module is static install ready 😄
> minil build> grep x_static_install META.json"x_static_install" : 1
name = "Your-Module"module_maker = "ModuleBuildTiny"[Metadata]x_static_install = 1
![Page 11: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/11.jpg)
Conclusion• CPAN ecosystem uses Makefile.PL/Build.PL to install
CPAN modules
• It is powerful, but often overly complicated
• Now we have the concept static install, which is much simpler and faster
• To make CPAN modules static installable, set x_static_install 1 in META.json
• Let’s make CPAN ecosystem simpler 👍
![Page 12: Make your CPAN module static installable](https://reader035.fdocuments.us/reader035/viewer/2022081808/58e4a45c1a28aba3458b6885/html5/thumbnails/12.jpg)
See also
• My blog posthttp://blogs.perl.org/users/shoichi_kaji1/2017/03/make-your-cpan-module-static-installable.html
• The spec of static installhttps://github.com/Perl-Toolchain-Gang/cpan-static
• An implementation of static install in Menlohttps://github.com/miyagawa/cpanminus/pull/467