[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: [mp2] Module naming
From:       Stas Bekman <stas () stason ! org>
Date:       2003-04-30 23:47:49
[Download RAW message or body]

Christopher Hicks wrote:
> On Thu, 1 May 2003, Stas Bekman wrote:
> 
>>There is still too much dust in the air with regards to mp2 module naming, 
>>therefore the docs aren't very clear.
> 
> 
> At least it's not just me.  :)

Neither for me. I've realized that discussions without doing the actual work 
aren't very useful. So we go ahead try different things and see what works the 
best.

>>The rumour says that you should keep the same name as in mp1.
> 
> 
> But in one case we're doing a total rewrite with no motivation to backport
> to mp1 and in another we've been doing major tweaking without any concern 
> about maintaining mp1 compatibility.  Regardless of the two modules I'm 
> working on there's surely going to be a time when many modules are written 
> purely for mp2.

It doesn't matter.

If you already have Apache/Foo for mp1 and now want to add a mp2 port, you 
either have to packages on CPAN with the same name but different versions 
(e.g. Apache-Foo-10.xx and Apache-Foo-20.xx to have enough space to grow) or 
you have one package with

Apache-Foo/Makefile.PL

Apache-Foo/mp1/lib/Apache/Foo.pm
Apache-Foo/mp1/Foo.xs
Apache-Foo/mp1/Makefile.PL

Apache-Foo/mp2/lib/Apache/Foo.pm
Apache-Foo/mp2/Foo.xs
Apache-Foo/mp2/Makefile.PL

where the top-level Makefile.PL controls which dir MakeMaker should descend to.

(I think CPAN indexer will have a problem with this approach).

Either use the DIR attribute:

     ModPerl::BuildMM::WriteMakefile(
        DIR => $USE_MODPERL_1 ? ['mp1'] : ['mp2']
     )

or use templates:
Apache-Foo/mp1/Makefile.PL.in
Apache-Foo/mp2/Makefile.PL.in

and rename only one of them to Makefile.PL from the top level Makefile.PL.

Or, generate mp1/Makefile.PL or mp2/Makefile.PL on the fly.

If you have only one perl file and may be one XS file. You can use this 
approach (the one I used in Apache::Peek):

Apache-Foo/mp2/Makefile.PL
Apache-Foo/mp2/Foo.pm.mp1
Apache-Foo/mp2/Foo.xs.mp1
Apache-Foo/mp2/Foo.pm.mp2
Apache-Foo/mp2/Foo.xs.mp2

and Makefile.PL at run time copies the right versions of the files to Foo.pm 
and Foo.xs.

If you have only mp2 version, just add a check to Makefile.PL to verify that 
it's not attempted to be built with mp1.

>>You never use both at the same time. Admittedly this is a bit confusing
>>when picking a module from CPAN (since you have Apache-Foo-x.xx and
>>Apache-Foo-y.yy). But once installed there is no longer confusion.
> 
> 
> Making it easy for CPAN.pm to install/upgrade things has been totally 
> ignored here.  

Certainly not ignored. It's just not trivial, because CPAN doesn't provide any 
support for this kind of situations whereas it could. (I know, patches are 
welcome...)

> When Apache-Foo-z.zz is no longer compatible with mp1 
> people are going to be miffed that they've upgraded without any warning.  

No, they won't. You write your Makefile.PL to test that this won't happen. 
I'll give you tools to do it in one line. Just need to polish what I have already.

> I'm managing a number of web servers heavily dependent on a variety of 
> perl modules and using CPAN.pm really helps keep things sane.

Yes, automatic CPAN install will always pick the latest version. That's why I 
suggest to package both versions in one distro.

Also don't forget that it's going to be extremely painful for the programmers 
to remember to type Apache2::Foo when they used to type Apache::Foo for the 
last 7 years (I'm talking about modules which exist in mp1 and mp2 worlds).

Ideally, we shouldn't try to find a workaround for CPAN limitations, but 
remove those limitations. We should be able to tell CPAN that this module is 
for mp2 and CPAN.pm should be able to ask user which mod_perl generation does 
it want, or the user should be able to preconfigure CPAN.pm which generation 
it wants the modules for. Of course this should be done in a non-mod_perl 
specific way, so other projects can benefit from it. It's not the only odd 
case on CPAN, I know quite a few modules which struggle with the same problem.

I'm CC'ing Andreas, perhaps he has some insightful ideas regarding CPAN 
indexer and CPAN.pm to resolve this issue.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic