$30 off During Our Annual Pro Sale. View Details »

Carmel at YAPC::EU 2015

Carmel at YAPC::EU 2015

Tatsuhiko Miyagawa

September 03, 2015
Tweet

More Decks by Tatsuhiko Miyagawa

Other Decks in Technology

Transcript

  1. Carmel
    Yet another CPAN dependencies management tool
    Tatsuhiko Miyagawa
    YAPC::EU 2015

    View Slide

  2. Me
    • MIYAGAWA, @miyagawa
    • San Francisco, CA, United States
    • Perl, Ruby

    View Slide

  3. Agenda
    • Why manage CPAN dependencies
    • Introduction of tools
    • Demo
    • Future Plans

    View Slide

  4. Carton
    Bundler(-ish) for Perl

    View Slide

  5. View Slide

  6. (quick recap)

    View Slide

  7.  @local>  cpanm  Poles  
    Installed  Poles-­‐1.0.tar.gz  
    @remote>  cpanm  Poles  
    Installed  Poles-­‐2.1.tar.gz

    View Slide

  8. View Slide

  9. “Updating CPAN modules
    broke my app”

    View Slide

  10. Takeaway
    • CPAN dependencies = Your app
    • Describe it
    • Manage it
    • Version Control it

    View Slide

  11. cpanfile

    View Slide

  12. cpanfile
    • DSL to describe CPAN dependencies
    • Version Range, Phases
    • a la Gemfile
    • Module::CPANfile
    • Supported by many tools (cpanm)

    View Slide

  13. requires  'Plack',  '1.001';  
    requires  'Mojolicious',  '==  6.17';  
    on  'develop'  =>  sub  {  
       requires  'Devel::NYTProf';  
    };  
    on  'test'  =>  sub  {  
       requires  'Test::More';  
       requires  'Test::mysql';  
    };

    View Slide

  14. requires  'Plack',  '1.001';  
    requires  'Mojolicious',  '==  6.17';  
    on  'develop'  =>  sub  {  
       requires  'Devel::NYTProf';  
    };  
    on  'test'  =>  sub  {  
       requires  'Test::More';  
       requires  'Test::mysql';  
    };

    View Slide

  15. requires  'Plack',  '1.001';  
    requires  'Mojolicious',  '==  6.17';  
    on  'develop'  =>  sub  {  
       requires  'Devel::NYTProf';  
    };  
    on  'test'  =>  sub  {  
       requires  'Test::More';  
       requires  'Test::mysql';  
    };

    View Slide

  16. >  cpanm  -­‐-­‐installdeps  .

    View Slide

  17. cpanm + cpanfile
    • Grabs latest versions that satisfy ranges
    • '== version' can pin versions
    • cpanmetadb/MetaCPAN SPOF

    View Slide

  18. Carton
    Bundler(-ish) for Perl

    View Slide

  19. Carton + cpanfile
    • Installs into ./local
    • Creates cpanfile.snapshot
    • Git friendly
    • carton  install  -­‐-­‐deployment

    View Slide

  20. requires  'Poles',  '1.0';  

    View Slide

  21.  @local>  carton  install  
    Installed  Poles-­‐1.0.tar.gz  
    @remote>  carton  install  -­‐-­‐deployment  
    Installed  Poles-­‐1.0.tar.gz

    View Slide

  22. View Slide

  23. Carton
    1.0 released in late 2013
    1.1 was in the development

    View Slide

  24. View Slide

  25. Carton
    • Slow for large installs
    • Relies on cpanm internals
    • Git support is hard
    • Update/Rollback is unreliable
    • -­‐-­‐deployment is confusing
    • carton  exec doesn't check on development

    View Slide

  26. Carmel
    Yet another Bundler for Perl

    View Slide

  27. Carmel
    • Same UI/UX with Carton
    • Different internals
    • Rewritten from scratch
    • Deeper understandings of how Bundler works
    • Fast and Reliable

    View Slide

  28. blib
    The core of Carmel

    View Slide

  29. How to build a CPAN module
    • Configure
    • Build
    • Test (Optional)
    • Install

    View Slide

  30. How to build a CPAN module
    • perl  Makefile.PL  
    • make  
    • make  test  
    • make  install

    View Slide

  31. ➜  perl  Makefile.PL    
    Checking  if  your  kit  is  complete...  
    Looks  good  
    Generating  a  Unix-­‐style  Makefile  
    Writing  Makefile  for  Try::Tiny  
    Writing  MYMETA.yml  and  MYMETA.json  
    ➜  make  
    cp  lib/Try/Tiny.pm  blib/lib/Try/Tiny.pm  
    Manifying  1  pod  document  

    View Slide

  32. ➜  perl  Makefile.PL    
    Checking  if  your  kit  is  complete...  
    Looks  good  
    Generating  a  Unix-­‐style  Makefile  
    Writing  Makefile  for  Try::Tiny  
    Writing  MYMETA.yml  and  MYMETA.json  
    ➜  make  
    cp  lib/Try/Tiny.pm  blib/lib/Try/Tiny.pm  
    Manifying  1  pod  document  

    View Slide

  33. blib/{lib,arch}
    Can be pushed to @INC  
    CPAN.pm does it for ages

    View Slide

  34. The idea
    • Builds all modules without installing them
    • Manages these "blib"s (call them artifacts)
    • Chooses artifact paths dynamically on dev
    • Freezes artifact paths statically on prod

    View Slide

  35. Carmel
    Written in a few hours as a hack.
    Turned into a module at Berlin QA Hackathon.

    View Slide

  36. DEMO

    View Slide

  37. Commands
    • carmel install
    • carmel list/tree
    • carmel exec
    • carmel package
    • carmel rollout
    • carmel inject

    View Slide

  38. Tools
    • carmel exec
    • Carmel::Setup
    • Carmel::Preload

    View Slide

  39. View Slide

  40. Current status
    • pre-1.0
    • Usable (I use it on cpanmetadb production)
    • Snapshot support in development

    View Slide

  41. >  cpanm  Carmel  

    View Slide

  42. >  cpanm  Carmel  
    Successfully  installed  Menlo-­‐1.9001  
    Successfully  installed  Carmel-­‐v0.1.25  
    2  distributions  installed  

    View Slide

  43. >  cpanm  Carmel  
    Successfully  installed  Menlo-­‐1.9001  
    Successfully  installed  Carmel-­‐v0.1.25  
    2  distributions  installed  

    View Slide

  44. Menlo

    View Slide

  45. Menlo
    "cpanm 2.0"

    View Slide

  46. cpanm
    • Loved by the users
    • Mixed feelings by the developer (me)
    • God class, Hard to refactor
    • Grown out of a pre-fatpack single script
    • Not extensible

    View Slide

  47. Menlo
    • Modular, Scriptable, Object-Oriented APIs
    • Plugin Hooks
    • uses CPAN::Common::*
    • Extracts the common bits (e.g. HTTP::Tinyish)
    • Still bootstrappable with fatpack/vendoring

    View Slide

  48. >  cpanm  Menlo  
    >  cpanm-­‐menlo  Plack

    View Slide

  49. Current status
    • github.com/miyagawa/cpanminus @ menlo
    • New features (static installs)
    • Pre big refactoring
    • No plugins

    View Slide

  50. 2.0 planned for QAH 2016
    ... but with continuous 1.9x releases

    View Slide

  51. github.com/miyagawa

    View Slide

  52. irc.perl.org #cpanm

    View Slide

  53. Thank you.
    Questions?

    View Slide

  54. FAQ
    • Why Carmel/Menlo?
    • 1.0/2.0 ETA?
    • Is Carton deprecated?
    • What's the purple thing in your avatar?

    View Slide