1 / 39

Perl Versioning

Perl Versioning. YAPC Israel 2004. Outline. Why do I care about versions? Perl versions Module versions How-To use module versions ‘only’. Why do I care about versions. Track changes Functional Performance Fixes. Why do I care about versions. Impose dependencies

aimee
Télécharger la présentation

Perl Versioning

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Perl Versioning YAPC Israel 2004

  2. Outline • Why do I care about versions? • Perl versions • Module versions • How-To use module versions • ‘only’ YAPC::Israel 2004

  3. Why do I care about versions • Track changes • Functional • Performance • Fixes YAPC::Israel 2004

  4. Why do I care about versions • Impose dependencies • I never tested this with versions older than X • Version X.Y is broken, don’t use it • This requires support that was only added in version Z YAPC::Israel 2004

  5. Why do I care about versions • Reporting/Fixing bugs • In what version did you see this bug? • Has it already been fixed? • Did a new release introduce the problem, or was it always there? YAPC::Israel 2004

  6. Perl –v or $] or $^V • Perl –v • This is perl, v5.8.2 built for cygwin-multi-64int • $] = 5.008002 • number • $PERL_VERSION == $^V • literal – avoid this YAPC::Israel 2004

  7. Perl –v or $] or $^V • Convention: • Major.Minor.Patchlevel • Minor Even/Odd = Release/Development • Examples: • 5.8.2 – latest release version • 5.9.1 – latest development version YAPC::Israel 2004

  8. Module versions • % perl –MCPAN –e shell cpan> m CPAN DESCRIPTION Implements default import method for modules CPAN_USERID P5P (The Perl5 Porters Mailing List <perl5-porters@perl.org>) CPAN_VERSION 1.76 INST_FILE /usr/lib/perl5/5.8.0/CPAN.pm INST_VERSION 1.75 YAPC::Israel 2004

  9. Module Versions • $CPAN::VERSION = 1.76 • In general: • $module::VERSION YAPC::Israel 2004

  10. Module Versions • Convention: • Major.Minor • Use a floating point number • Maintain the same number of decimal points • 5.008 < 5.08 < 5.8 YAPC::Israel 2004

  11. How-To USE module versions • Use use • use version; • use module; • use module version; • version and module are bare-words YAPC::Israel 2004

  12. USE’ing versions • use version; • use 5.8.0; • Use Perl version at least 5.8.0 • Newer versions are ok YAPC::Israel 2004

  13. USE’ing modules • use module; • use cpan; • Include the cpan module • Don’t check the version YAPC::Israel 2004

  14. USE’ing module versions • use module version; • Use Net::Telnet 3.0; • Include Net::Telnet only if the version is at least 3.0 • Otherwise, die YAPC::Israel 2004

  15. Specifying the version (old way) package Some::Module; use vars qw($VERSION); $VERSION = "4.03"; YAPC::Israel 2004

  16. Specifying the version (correct) package Some::Module; BEGIN { our $VERSION; $VERSION = "4.03"; } YAPC::Israel 2004

  17. Specifying the version (best) package Some::Module; require Exporter; @ISA = qw(Exporter); BEGIN { our $VERSION; $VERSION = "4.03"; } YAPC::Israel 2004

  18. Why did we use BEGIN? • Use is an implicit BEGIN • We want to know what version we are working with even if we have not yet processed the file YAPC::Israel 2004

  19. How does it work • Exporter checks the version when attempting to import a number $module->require_version($version) • Exporter supplies a default method YAPC::Israel 2004

  20. Is this good enough? • Track Changes • Impose Dependencies • Reporting/Fixing bugs • What else? YAPC::Israel 2004

  21. I need exactly this version! • 2.3 does not have the right support • 2.4 works • 2.5 is broken • 2.6 is good • How do we require only version 2.4? • There is no obvious way to do this YAPC::Israel 2004

  22. only • New package by Brian Ingerson • Now we can say: use only myModule => 1.4 YAPC::Israel 2004

  23. Only options • Require exactly the versions that we know to be working • Supports ranges ‘1.3-1.5’ • Supports exceptions ‘!1.35’ • Supports exactly ‘2.45’ YAPC::Israel 2004

  24. Only example • use only myModule => ‘1.1 1.3-1.5 !1.35 1.6-’; • Exactly v1.1 • Anything in the range v1.3 to v1.5 • But not 1.35 • Anything at least as new as 1.6 YAPC::Israel 2004

  25. only - Basic usage • Install the only package • Don’t change any packages Package Foo; our $VERSION; $VERSION = 1.5; Package Bar; use only Foo => 1.5; YAPC::Israel 2004

  26. Multiple versions • My cron jobs use version 1.6 • I am developing version 1.7 • If I install 1.7 for testing, all those depending on the package may fail! • Solution 1: Install 1.7 in a different place and play with @INC. YAPC::Israel 2004

  27. only can manage installation directories automatically Installation now supports more than one concurrent version cd myModule-1.3 perl Makefile.PL make test make –Monly=install only – multiple versions YAPC::Israel 2004

  28. only – multiple versions • myModule-1.6 is currently installed • Scripts use ‘use myModule’; • I want to test myModule-1.7 YAPC::Israel 2004

  29. only – multiple versions • Option 1: • Other packages use ‘use myModule’ • Install new version using ‘make –Monly’ • It will not only be accessible via ‘use only’ • Test with ‘only only myModule;’ YAPC::Israel 2004

  30. only – multiple versions • Option 2: • Other packages use ‘use only myModule;’ • Install new version using ‘make –Monly’ as version 0.1. • Test with ‘use only myModule => 0.1;’ YAPC::Israel 2004

  31. Modperl • Running multiple systems in the same interpreter • What if they require different versions? • Perl cannot currently install multiple versions of a given module YAPC::Israel 2004

  32. Modperl -- only • only can specify what you want on a per package basis • only cannot currently import the same package with different versions YAPC::Israel 2004

  33. Other systems • Compiled languages do not support version dependencies • Most scripted languages do not support versioning • Why should Perl? • Is this overkill? YAPC::Israel 2004

  34. Compiled languages • Compiled languages (C, C++) use • version control systems • search paths YAPC::Israel 2004

  35. Run time languages • Languages that include libraries on the fly • Java • Perl • Unix YAPC::Israel 2004

  36. Run time languages • Name libraries uniquely • libc.so.3.64 • Pray that no-one changed the environment YAPC::Israel 2004

  37. Size counts • Large production systems are static • Versions are managed externally • Shoot anyone who touches the system YAPC::Israel 2004

  38. Size counts • Small systems are more easily managed • Most scripted systems are small • The problem occurs when scripts collide • Multiple systems on the same platform YAPC::Israel 2004

  39. Review • $] • $VERSION • use • only YAPC::Israel 2004

More Related