| 1 |
NAME |
| 2 |
Alt - Alternate Module Implementations |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
PERL_ALT_INSTALL=OVERWRITE cpanm Alt::IO::All::Redux |
| 6 |
|
| 7 |
DESCRIPTION |
| 8 |
"Alt::" is the namespace for alternate implementations of CPAN modules. |
| 9 |
|
| 10 |
The purpose of the Alt module is to provide documentation explaining the |
| 11 |
Alt concept, how it works, and guidelines for using it well. |
| 12 |
|
| 13 |
THE PROBLEM |
| 14 |
For a given piece of software, CPAN only allows for one implementation |
| 15 |
of a given module/distribution name. |
| 16 |
|
| 17 |
GitHub on the other hand, is not limited this way. Any author can make a |
| 18 |
fork, since GitHub repos are namespaced by author id. |
| 19 |
|
| 20 |
On CPAN, even the author(s) of the module in question is limited by |
| 21 |
this, as they cannot release newer or older forks of their code, without |
| 22 |
introducing a new name. |
| 23 |
|
| 24 |
THE SOLUTION |
| 25 |
A module "Foo::Bar" is distributed on CPAN as "Foo-Bar". It may have |
| 26 |
submodules like "Foo::Bar::Baz". |
| 27 |
|
| 28 |
To make an alternate CPAN version, leave everything exactly the same, |
| 29 |
except distribute the new version as "Alt-Foo-Bar-AltIdentifier". |
| 30 |
|
| 31 |
When a user installs your module like so: |
| 32 |
|
| 33 |
PERL_ALT_INSTALL=OVERWRITE cpanm Alt::Foo::Bar::better |
| 34 |
|
| 35 |
they will get your version of the Foo::Bar framework (Foo::Bar, |
| 36 |
Foo::Bar::Baz). |
| 37 |
|
| 38 |
Obviously, this completely overlays the old Foo::Bar install, but that's |
| 39 |
the whole idea. The user isn't surprised by this because they just asked |
| 40 |
for an Alternate implementation. If they don't like it, they can simply |
| 41 |
reinstall the original Foo-Bar, or try some other alternate. |
| 42 |
|
| 43 |
ALT BEST PRACTICES |
| 44 |
This idea is new, and the details should be sorted out through proper |
| 45 |
discussions. Pull requests welcome. |
| 46 |
|
| 47 |
Here are the basic guidelines for best using the Alt namespace: |
| 48 |
|
| 49 |
Name Creation |
| 50 |
Names for alternate modules should be minted like this: |
| 51 |
|
| 52 |
"Alt-$Original_Dist_Name-$phrase" |
| 53 |
|
| 54 |
For instance, if MSTROUT wants to make an alternate IO-All |
| 55 |
distribution to have it be Moo-based, he might call it: |
| 56 |
|
| 57 |
Alt-IO-All-Moo |
| 58 |
|
| 59 |
He might also just call it: |
| 60 |
|
| 61 |
Alt-IO-All-MSTROUT |
| 62 |
|
| 63 |
By having 'Alt' at the start, it guarantees that it does not mess |
| 64 |
with future IO::All development. The "phrase" at the end can be |
| 65 |
anything unique to CPAN, but should describe the spirit of the |
| 66 |
alternate. If the alternate is meant to be short-lived, it can just |
| 67 |
be the author's CPAN id. |
| 68 |
|
| 69 |
Makefile.PL Changes |
| 70 |
Due to experience with <http://cpantesters.org/> problems, it is |
| 71 |
important to make your Alt module not install without explicit |
| 72 |
direction. You can accomplish this easily in a Makefile.PL, with |
| 73 |
something like this: |
| 74 |
|
| 75 |
my $alt = $ENV{PERL_ALT_INSTALL} || ''; |
| 76 |
$WriteMakefileArgs{DESTDIR} = |
| 77 |
$alt ? $alt eq 'OVERWRITE' ? '' : $alt : 'no-install-alt'; |
| 78 |
|
| 79 |
Similar techniques should be available for other module release |
| 80 |
frameworks. |
| 81 |
|
| 82 |
Module for CPAN Indexing |
| 83 |
You will need to provide a module like "Alt::IO::All::MSTROUT" so |
| 84 |
that CPAN will index something that can cause your distribution to |
| 85 |
get installed by people: |
| 86 |
|
| 87 |
PERL_ALT_INSTALL=OVERWRITE cpanm Alt::IO::All::MSTROUT |
| 88 |
|
| 89 |
Since you are adding this module, you should add some doc to it |
| 90 |
explaining your alternate version's improvements. |
| 91 |
|
| 92 |
The Alt:: module can be as simple as this: |
| 93 |
|
| 94 |
package Alt::IO::All::MSTROUT; |
| 95 |
our $VERSION = '0.01'; |
| 96 |
|
| 97 |
no_index |
| 98 |
It is important to use the "no_index" directive on the modules you |
| 99 |
are providing an alternates for. This is especially important if you |
| 100 |
are the author of the original, as PAUSE will reindex CPAN to your |
| 101 |
Alt- version which defeats the purpose. Even if you are not the same |
| 102 |
author, it will make your index reports not show failures. |
| 103 |
|
| 104 |
Versioning |
| 105 |
It is important to not declare a $VERSION in any of the modules that |
| 106 |
you are providing alternates for. This will help ensure that your |
| 107 |
alternate module does not satisfy the version requirements for |
| 108 |
something that wants the real module. |
| 109 |
|
| 110 |
If you want to depend on the alternate versions, then set the |
| 111 |
dependency on the "Alt::" module. |
| 112 |
|
| 113 |
NOTE: If you provide an alternate Foo::Bar (with no VERSION) it will |
| 114 |
satisfy the version requirements for someone who requires "Foo::Bar |
| 115 |
=> 0". In a sense, depending on version 0 means that alternates are |
| 116 |
OK. |
| 117 |
|
| 118 |
"use" the Alt |
| 119 |
You should add this line to your alternate modules: |
| 120 |
|
| 121 |
use Alt::IO::All::MSTROUT; |
| 122 |
|
| 123 |
That way the Alt:: module gets loaded any time you "use IO::All" |
| 124 |
(with the alternate version installed). This gives debugging clues |
| 125 |
since the Alt:: module is now in %INC. |
| 126 |
|
| 127 |
Other Concerns |
| 128 |
If you have em, I(ngy) would like to know them. Discuss on |
| 129 |
#toolchain on irc.perl.org for now. |
| 130 |
|
| 131 |
WHENCE ALT? |
| 132 |
The Alt- concept was thought up by Ingy as he tried to figure out how to |
| 133 |
revamp the somewhat popular IO::All and YAML.pm modules. Alternates can |
| 134 |
now be released and alpha/beta tested, while the originals remain |
| 135 |
stable. |
| 136 |
|
| 137 |
When Alt-IO-All-new is "community approved" it can replace IO-All. If |
| 138 |
people want the old code, they can can install Alt-IO-All-old. |
| 139 |
|
| 140 |
AUTHOR |
| 141 |
Ingy döt Net <[email protected]> |
| 142 |
|
| 143 |
COPYRIGHT |
| 144 |
Copyright 2012-2014. Ingy döt Net. |
| 145 |
|
| 146 |
See <http://www.perl.com/perl/misc/Artistic.html> |
| 147 |
|