Plenv and carton
-
Upload
jose-luis-martinez -
Category
Technology
-
view
428 -
download
0
description
Transcript of Plenv and carton
![Page 1: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/1.jpg)
Set yourself free from
the system: managing
non-system Perls
Jose Luis Martínez Torres
JLMARTIN
Barcelona Perl Workshop 2014
@pplu_io
![Page 2: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/2.jpg)
System perl
Debian
squeeze: 5.10
wheezy: 5.14
jessie: 5.20
Redhat
RHEL5: 5.8
RHEL6: 5.10
RHEL7: 5.16
![Page 3: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/3.jpg)
The distribution perl is not what you
think it is
For Debian Perl 5.14
$ /usr/bin/perl -V | grep DEBPKG | wc -l
57
![Page 4: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/4.jpg)
The distribution perl is not what you
think it is
http://perlbuzz.com/2008/08/red-hats-patch-slows-down-overloading-in-
perl.html
Some investigation revealed that there’s a long standing bug in Redhat Perl that
causes *severe* performance degradation on code that uses the bless/overload
combo. The thread on this is here:
https://bugzilla.redhat.com/show_bug.cgi?id=379791
![Page 5: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/5.jpg)
The distribution perl is not what you
think it is
http://perlbuzz.com/2008/08/red-hats-patch-slows-down-overloading-in-
perl.html
Some investigation revealed that there’s a long standing bug in Redhat Perl that
causes *severe* performance degradation on code that uses the bless/overload
combo. The thread on this is here:
https://bugzilla.redhat.com/show_bug.cgi?id=379791
![Page 6: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/6.jpg)
Compile my own perl? Hard???
In the olden days it could be a challenge
![Page 7: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/7.jpg)
Compile my own perl: Now
No need for root!
You only need compiler (and libs)
apt-get install build-essential
Now you choose: perlbrew / plenv
I’ll use plenv today… (like it more)
![Page 8: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/8.jpg)
Plenv to the rescue
https://github.com/tokuhirom/plenv/
git clone git://github.com/tokuhirom/plenv.git ~/.plenvecho 'export PATH="$HOME/.plenv/bin:$PATH"' >> ~/.profileecho 'eval "$(plenv init -)"' >> ~/.profileexec $SHELL –lgit clone git://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/plenv install 5.20.1# wait for it…plenv rehashplenv install-cpanm
![Page 9: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/9.jpg)
A Word of Caution
#!/usr/bin/perl is soooooooooooo 2010…
#!/usr/bin/env perl is the new #!/usr/bin/perl
It’ll help your programs find the correct perl!
![Page 10: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/10.jpg)
Switching perls
(At the directory level)
plenv global 5.16.2
cd project1plenv local 5.14.0
./my_project
![Page 11: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/11.jpg)
My Modules!
carton to the rescue
![Page 12: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/12.jpg)
Carton
cpanm Carton
vi cpanfilerequires ‘Module1’;requires ‘Module2’;
carton install
# Magic happens… All modules get installed# Also generates a cpanfile.snapshot with all modules and versionsinstalled
carton exec ./my_project
![Page 13: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/13.jpg)
Trick
carton exec $SHELL –l
#Perl will find your modules without invoking carton
![Page 14: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/14.jpg)
Handling failures
![Page 15: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/15.jpg)
Handling failures
Look at the log
Normally some headers missing
DBD::mysql requires libmysqlclient-dev to be installed (Debian/Ubuntu)
SSL related modules usually require OpenSSL: libssl-dev (Debian/Ubuntu)
Some XML related modules require libexpat1-dev libxml2-dev
Find a missing .h file in the compiler errors, and find which package it belongs to
Rinse and Repeat “carton install”
![Page 16: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/16.jpg)
BUNDLE!!!
carton bundle
- Look at your vendor/cache dir!
- Look at vendor/bin!
./vendor/bin/carton (fat packed version)
I personally add the vendor directory to version control
Smells like we get repeatable
![Page 17: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/17.jpg)
DEPLOY!!!
carton install# install all modules that don’t meet cpanfile requirements
carton install --deployment# installs all versions from cpanfile.snapshot
carton install --deployment --cached# installs versions from the vendor/cache
![Page 18: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/18.jpg)
Conclusions
plenv controls your Perl version
carton controls your dependencies
Enables
Repeatablility
Independant interpreters for different needs (think of microservices)
Testing new versions
Using up-to-date modules with no fear of CPAN breakage
![Page 19: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/19.jpg)
Thanks
Tokuhiro Matsuno for plenv
Tatsuhiko Miyagawa for carton
![Page 20: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/20.jpg)
Extra, Extra
![Page 21: Plenv and carton](https://reader033.fdocuments.us/reader033/viewer/2022052413/559bdc4d1a28ab4e568b4570/html5/thumbnails/21.jpg)
Extra, Extra: Here’s the cat