Carmel at YAPC::EU 2015

Carmel at YAPC::EU 2015

B2d653d5d663e750a2cd57bfbc9b727f?s=128

Tatsuhiko Miyagawa

September 03, 2015
Tweet

Transcript

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

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

    • Perl, Ruby
  3. Agenda • Why manage CPAN dependencies • Introduction of tools

    • Demo • Future Plans
  4. Carton Bundler(-ish) for Perl

  5. None
  6. (quick recap)

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

      Installed  Poles-­‐2.1.tar.gz
  8. None
  9. “Updating CPAN modules broke my app”

  10. Takeaway • CPAN dependencies = Your app • Describe it

    • Manage it • Version Control it
  11. cpanfile

  12. cpanfile • DSL to describe CPAN dependencies • Version Range,

    Phases • a la Gemfile • Module::CPANfile • Supported by many tools (cpanm)
  13. requires  'Plack',  '1.001';   requires  'Mojolicious',  '==  6.17';   on

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

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

     'develop'  =>  sub  {      requires  'Devel::NYTProf';   };   on  'test'  =>  sub  {      requires  'Test::More';      requires  'Test::mysql';   };
  16. >  cpanm  -­‐-­‐installdeps  .

  17. cpanm + cpanfile • Grabs latest versions that satisfy ranges

    • '== version' can pin versions • cpanmetadb/MetaCPAN SPOF
  18. Carton Bundler(-ish) for Perl

  19. Carton + cpanfile • Installs into ./local • Creates cpanfile.snapshot

    • Git friendly • carton  install  -­‐-­‐deployment
  20. requires  'Poles',  '1.0';  

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

     -­‐-­‐deployment   Installed  Poles-­‐1.0.tar.gz
  22. None
  23. Carton 1.0 released in late 2013 1.1 was in the

    development
  24. None
  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
  26. Carmel Yet another Bundler for Perl

  27. Carmel • Same UI/UX with Carton • Different internals •

    Rewritten from scratch • Deeper understandings of how Bundler works • Fast and Reliable
  28. blib The core of Carmel

  29. How to build a CPAN module • Configure • Build

    • Test (Optional) • Install
  30. How to build a CPAN module • perl  Makefile.PL  

    • make   • make  test   • make  install
  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  
  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  
  33. blib/{lib,arch} Can be pushed to @INC   CPAN.pm does it

    for ages
  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
  35. Carmel Written in a few hours as a hack. Turned

    into a module at Berlin QA Hackathon.
  36. DEMO

  37. Commands • carmel install • carmel list/tree • carmel exec

    • carmel package • carmel rollout • carmel inject <Module>
  38. Tools • carmel exec • Carmel::Setup • Carmel::Preload

  39. None
  40. Current status • pre-1.0 • Usable (I use it on

    cpanmetadb production) • Snapshot support in development
  41. >  cpanm  Carmel  

  42. >  cpanm  Carmel   Successfully  installed  Menlo-­‐1.9001   Successfully  installed

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

     Carmel-­‐v0.1.25   2  distributions  installed  
  44. Menlo

  45. Menlo "cpanm 2.0"

  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
  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
  48. >  cpanm  Menlo   >  cpanm-­‐menlo  Plack

  49. Current status • github.com/miyagawa/cpanminus @ menlo • New features (static

    installs) • Pre big refactoring • No plugins
  50. 2.0 planned for QAH 2016 ... but with continuous 1.9x

    releases
  51. github.com/miyagawa

  52. irc.perl.org #cpanm

  53. Thank you. Questions?

  54. FAQ • Why Carmel/Menlo? • 1.0/2.0 ETA? • Is Carton

    deprecated? • What's the purple thing in your avatar?