Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

HowTo build and distribute a PPMed module for Win32

by idnopheq (Chaplain)
on Sep 19, 2001 at 23:17 UTC ( #113448=perltutorial: print w/ replies, xml ) Need Help??

UPDATE: this Tutorial is geared toward the ActiveState ActivePerl for Win32. THX ybiC! Added a dropped <READMORE> tag. Added lots 'o stuff from $code or die and ybiC. This will continue to grow and change.

WARNING: my ispell failed and I need to fix it ... if I offend anyone with my poor typing or spelling, consider them manners. I don't mind if you don't like my manners. I don't like 'em myself. They're pretty bad. I grieve over them on long winter evenings. <- The Big Sleep ... gawd I * L O V E * that line!

Problem

You want to make a Perl Package Manager ( PPM ) package but every time you try to make the module, it fails. Or the resulting package isn't quite right. Or you missed something, like the pod 2 html files and their introduction into the ActiveState ActivePerl Documentation index.

Discussion

Being a good monk, you have read How do I make a PPM package? and followed the instructions verbatim. Maybe you even read perlwin32 - Perl under Win32 - Usage Hints. But things still don't DWIM.

So what now? Well, there are several catches to building a module under Win32. Some can be overcome freely. Some may cost money. Some may be unattainable at this time. Here are some things I've found so far.

Solutions!

  1. nmake complains about something called cl.exe

  2. Well, you may be trying to compile an XS module. These are modules that require some kind of external library and need a full-blown C compiler to build the dll ( dynamic link library ). nmake looks for cl.exe because that is M$ VC++'s compiler. One might try running to CygWin, "a UNIX environment for Windows". Another might try MingW, "a collection of header files and import libraries that allow one to use GCC and produce native Windows32 programs that do not rely on any 3rd-party DLLs".

    IMHO, stick with the compiler used for your perl distribution. ActiveState uses Micro$oft VisualC++. One can find "Eductational" versions that may work, but I went with the "Standard Edition". Unless you have a lot of $$$, I don't advocate getting the "Professional" or "Enterprise" editions. I think I paid $79 USD for my copy.

    When you install it, have it update your environment variables ( %ENV for the perl-ers ). You can do what you want with the IDE ( Integrated Development Environment - I use NT Emacs myself ).

    If you want to use CPAN to get and build your modules not found in the usual places ( see my home node for a small list ) for PPM, you'll need a few other tools ...

    Get these installed and run perl -MCPAN -e shell because that's how one runs CPAN! Point all the questions to your downloaded files from above. I advocate implementing a /usr-type layout similar to *nix and adding it to your %PATH%.

    Go grab your favorite modules via the install package nomenclature. Of course, one can use the old fashioned "ftp it to my disk, un-tar-gzip it and run nmake" style, too.

    What will result is a directory in which the module's source resides within. If one uses CPAN's install, it will go through the make process, sometimes failing. If one decides to follow the manual path, follow the README or INSTALL directions.

    Many modules engineered with Win32 in mind have a makefile.msc file. If CPAN fails, look for this. If it exists, do a nmake /f makefile.msc. This can be especially important if the module contains some XS. Modify the module's provided instructions to include this /f maskefile.msc bit through out.

  3. Great! But no matter what I do, the tests fail!

  4. Well, that might happen, especially of the test scripts are xenophobically aligned with *nix. Try running the test scripts the long way ( perl testscript which should not make a difference but occasionally do ).

  5. I nmaked it fine; it tested fine. Now what?

  6. Well, in that directory where the source resides and the namake was performed, there should be a blib directory. From the doc listed above:

    "The resulting files are placed in the blib directory that is created when you run nmake. These files should be packed into an archive like this:

    tar cvf package.tar blib
    gzip --best package.tar

    You now have an archive called package.tar.gz. Then you generate the PPD file by:

    nmake ppd

    You have to edit the resulting PPD file and add the location of the package archive into <CODEBASE HREF="" />. The location is relative to the PPD file."

    Note that other modifications may need to be made to the resulting ppd file.

  7. What about the perldocs in the ActiveState ActivePerl Documentation html index?

  8. Well, use pod2html module.pm against all the peritent pm files. As all modules differ in this, you'll have to figure out for yourself which ones are "pertinent".

    Before one does the previous step ( OOOPPPSSSS! ), create a directory structure under blib like html\site\lib\Compress, where one replaces the Compress with the "master" level ... i.e. Win32 for a standard Win32 module. Move the html file(s) from above into this "master" level directory.

    Now goto ( I know there's no goto in perl! ) to the previous step. Refresh or reload your "ActiveState ActivePerl Documentation" Start menu item. Voila!

  9. Well done! But how do I distribute this to the masses that continually create a massive din in eager anticipation for this module!

  10. Easy, now! Getting a little extra ego with your Wheaties, ain't-cha! Hmmm ... I know little about din-producing masses. But setting up a PPM distribution point is, perhaps, the easiest part of the whole endeavor. Remember before when I quoted about the ppd file? That path entered in the CODEBASE HREF portion is critial. Also, find a place to house it. But, with my own humble PPM respository as an example:

    The 'root' is http://idnopheq.perlmonk.org. The ppd files shall reside in http://idnopheq.perlmonk.org/perl/packages. In the ppd file's CODEBASE HREF, I have a relative path to this of x86/Win32/package.tar.gz. The tar.gz file is placed in http://idnopheq.perlmonk.org/perl/packages/x86/Win32/, a la CODEBASE HREF. One can freely follow my lead here, or come up with something more to their aesthetical testes.

    UPDATE: Thanks to $code or die!!!!

    See ($code or die) Re: Repository code (HowTo build and distribute a PPMed module for Win32) about setting your new repository up for search capabilities. Aw, heck! I'll just quote it, but don't forget to ++ the node!

    <cite> Right, I have been re-reading PPM.pm and understand how the search command works.

    When you do search Module-Name, it run's the function list_available(). This function returns a list of .ppd files in the repository. It does it differently depending on what type of repository it is, e.g.: file://, UNC, SOAP, or http://. We're interested in the last bit of the function concerning http.

    If the repository is an http:// repository (not soap), then it calls the function read_href() which returns the text on the page. list_available() expects either a directory listing (Apache or IIS format) or a default.prk format file - ActiveState's Visual Package Manager that's part of the Perl Dev Kit.

    For the search to work properly (without implimenting a SOAP interface or .prk) your repository must return something that resembles a directory listing, which PPM.pm parses.

    Thankfully, PPM.pm keeps the "libwww-perl/" part of the user agent. So we can write a small script that will return a directory listing for ppm and a nicely formatted page for regular browsers. This is a small working example of what to do:

    use strict; use CGI qw( :all ); my $user_agent = user_agent(); my $html_redirection = 'http://127.0.0.1/index.htm'; if ($user_agent =~ m#libwww-perl/#) { # it's a perl bot - probably ppm, so return a # compatible directory listing print_dir_listing(); } else { # it's probably a regular browser, redirect... print redirect(-uri => $html_redirection); } sub print_dir_listing { # Get the current directory, (cwd doesn't necessarily work in IIS) (my $cwd = $0) =~ s[\\][/]g; $cwd =~ s[/([^/]*)$][]; print header({-type => "text/plain"}); opendir FOLDER, $cwd or die "I don't have permission $!"; print a({-href => $_}, $_ ), "\n" for grep { /\.ppd$/ } readdir FO +LDER; closedir FOLDER; }

    Save this to index.pl or something and make sure it's the default document. Then change $html_redirection variable to the URL where you want your actual users to go to and you're set. You can of course do something more dynamic for the actual users page, such as parse the XML in the PPD files to give user's full information on the modules (version, description, author etc) without having to edit an html file every time you change a package or add a new one. I leave that as an exercise for the reader :) </cite>

    Many THX to $code or die for this information. HAVE YOU ++ IT YET?

  11. But the $%^&ing thing still doesn't work or the tests fail!

  12. Well, one may look to overloading functions to meet Win32's oddities. But sometimes that doesn't work. Like fork doesn't always work. These are the items that cannot necessarily be overcomed. explitive happens. And, anyway, why aren't you running an *nix or BSD derivative?

  13. I fear *nix and all that it implies! That's why!

  14. As with so many things, TIMTOWTDI and YMMV.

  15. I can't afford the $$$ for the C compiler, and the free ones fail me. What do I do?

  16. Fear not! I've been there; done that. Email me at idnopheq at permonk.org or drop me a /msg in the chatterbox, and I'll see what I can do! Failing that, post a request in the Monastary. If my lurid and sordid personal and/or professional life precludes me from helping, the other fine monks in this fine establishment may be able to help.

UPDATE: the below is based off of subsequent posts and other information I found ... THX to all for their recommendations!

Further Reading

HTH

Comment on HowTo build and distribute a PPMed module for Win32
Download Code
Re: ...PPMed module for Win32 (ancient diary of Sieperl woes)
by ybiC (Prior) on Sep 19, 2001 at 23:41 UTC
    The following blatherings have been on my homenode a while, for lack of a better place to put them.   This thread looks like a good home.   8^P
        cheers,
        Don
        striving toward Perl Adept
        (it's pronounced "why-bick")

    Diary of a frustrated !(AS|PPM) Perl install on Win2k

    1. Retrieve and install Siemens' precompiled 5.00503 binary for win32.
    2. Edit d:\perl\5.00503\lib\MSWin32-x86\Config.pm to reflect installed drive letter if not default "C" (thanks to OeufMayo, Yohimbe)
    3. Retrieve and install pmake.
      • perl Makefile.PL
      • perl -I. pmake
      • perl -Mblib pmake test
      • perl -Mblib pmake install
    4. Copy Make.pm to d:\perl\site\500503\lib\
    5. Install pure-Perl CPAN modules.
      • perl Makefile.PL
      • pmake.bat
      • pmake.bat test
      • pmake.bat install

      • Tie::IxHash - succeed
      • Net::Telnet - succeed
      • Term::ReadKey - <font size="-1">fail
      • Net::Telnet::Cisco - fail
    6. Keep digging - shouldn't have to manually copy .pm files to d:\perl\site\500503\lib\ ?!
    7. Continue pondering free(beer|speech) compilers for modules containing C/C++.
    8. from crazyinsomniac, but I've not got this far:
      • MM_Win32 UNINSTALL= $(Perl)... line doesn't appear to be valid perl syntaxt...
      • The \"\" stuff and also multiple -e switches...
      • Replace the \"\" with qq()...
      • Make needs the \ at the end of the line...
    9. Give up.   Install ActivePerl instead.
    10. Try again later.   Maybe.   If I get bored and ambitious
    Resources for compiling Perl from source on Win32. Relevant nodes
      Wow!

      Figures! I go to your home node often, yet managed to miss this somehow ... prob. in a fit of self-imporance ... ~sigh~

      I've never played w/ the Siemens' precompiled 5.00503 binary. In spite of my problems in the past with AS, it's still my Win32 perl of choice - at least since core perl merged into AS ... or the other way around ...

      Anywho, good to know. If Tutorials allows editing of root nodes, I'd like to modify mine post to specify AS better.

      HTH
      --
      idnopheq
      Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

Re: HowTo build and distribute a PPMed module for Win32
by $code or die (Deacon) on Sep 20, 2001 at 02:24 UTC
    ++. Great tutorial. Thanks!

    Unfortunately if you do a...
    ppm> set repository idnopheq http://idnopheq.perlmonk.org/perl/packag +es ppm> set save
    You cannot use the ppm search facility. The install ModuleName works great though. That's how far I got last time I did a PPM. It's a bit frustrating! It looks like you need to use PPM::SOAPServer to enable this. Unfortunately, I don't think this runs on Windows.

    The way that I got around using MSVC was to compile ActivePerl from source. You don't get the html docs or ppm, but if you compile Activeperl over an existing copy of ActivePerl, ppm and the html docs still work.

    Simon Flack ($code or die)
    $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
    =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
      What version of AS perl and ppm are you running? When I do a search in PPM, I get the ppds in my repository. Maybe mine's a fluke tho, as I have had the same AS distribution on multiple machines and received varying results. Eh, ~sigh~, YMMV! :-)

      I do like the idea of PPM and the flexibility/raw power of CPAN. I wish the two could come together. i.e. CPAN checking to see if there's a ppd for a module; installing that versus making/compiling the source; building dependencies ( which PPM does not do ); etc.

      Maybe someday ...

      HTH
      --
      idnopheq
      Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

        I have ActivePerl 629 - which I compiled, so PPM would be the one that comes with build 628.

        I'll try on some other machines and see what happens. But I was looking through the PPM.pm source and it implies that repositories can have "Summary" files. These summaries somehow aid the search routines. I am guessing that PPM::SOAPServer is a SOAP service that acts as the repository and searches the PPD files returning descriptions etc that match the search. But maybe I have the wrong end of the stick!

        Simon Flack ($code or die)
        $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
        =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
Re: HowTo build and distribute a PPMed module for Win32
by $code or die (Deacon) on Sep 25, 2001 at 15:29 UTC
    Just want to add this link to your already great tutorial:

    How2 create a PPM distribution by Jan Krynicky.

    Update: changed from "Just want to add a link to this already great tutorial" which was not clear

    Simon Flack ($code or die)
    $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
    =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
Re: HowTo build and distribute a PPMed module for Win32
by PodMaster (Abbot) on Sep 21, 2002 at 22:47 UTC

    PPM::Make ~ get it while it's hot


    I take requests (got a module that could be compiled under win32 but is not on any ppm repositories, I'll give it a shot given you read my readme and comply).

    http://crazyinsomniac.perlmonk.org/perl/ppm

    My repository is about to undergo a rehaul, as I'm beginning to compile modules under perl5.8. By the way, you can get a binary version of perl5.8 built by me at my repository. The only thing I changed is what perl -v spits out:
    G:\>perl -v This is perl, v5.8.0 built for MSWin32-x86-multi-thread by a crazy ins +omniac Copyright 1987-2002, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at http://www.perl.com/, the Perl Home Pa +ge.
    I provide a PPM version of BerkeleyDB, which nobody else does AFAIK. So far I've taken maybe 5 requests.

    When you don't use `ppm3' to install modules (you just do a make install), You may find it useful to update your ActivePerl html docs. I do this practically every other day ;)

    perl -MFile::Path -MConfig -e" rmtree(qq[$Config{installhtmldir}\\bin] +) " perl -MFile::Path -MConfig -e" rmtree(qq[$Config{installhtmldir}\\site +\\lib]) " perl -MActivePerl::DocTools -e ActivePerl::DocTools::UpdateHTML() perl -MActivePerl::DocTools -e ActivePerl::DocTools::WriteTOC()
    perl -MPod::Master -e Update()

    ____________________________________________________
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://113448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-09-22 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (188 votes), past polls