首页
登录 | 注册

A guide to installing perl modules for Win32(ZT)

Welcome to the Monastery
 
PerlMonks

A guide to installing modules for Win32

by holli
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | Snippets | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Code | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Feb 26, 2005 at 20:15 UTC ( #434813=perltutorial: print w/ replies, xml ) Need Help??

This article is meant as an extension to tachyon's well written A Guide to Installing Modules. But this one focuses on the peculiarites of installation on Windows machines.

Why ppm?
Invoking ppm
Installing modules
What is a repository?
Adding a repository
Repositories.pm
Getting around the proxy
Creating a local repository
Manual installation
Resources

Why ppm?

Installing modules directly from CPAN is easy, as long as the module contains no XS-extensions (C-code). Most Windows installations don't have a C-compiler, and even if there is one, the compilation of the XS-extensions is a tricky thingy, that can easily fail. So what can you do if you can't compile? The answer is: use a precompiled version.

The probably most popular port of Perl for Win32 is ActivePerl from ActiveState. It ships with a tool named ppm, aka the Programmer's Package Manager. ppm is a tool for installing modules, similar to the CPAN-shell. With it you can download and install modules, with or without XS-Extensions, with a few keystrokes.

The following describes the ppm Version that comes with Perl 5.8.0 and above. It differs slightly from the pppm that came with Perl 5.6

Sidenote:
Perl modules built for Perl 5.8 are not binary compatible with modules build for Perl 5.6! That means they are not interchangeable.

Advantages and features of ppm

  • No need for a C/C++ compiler and 'make' utility
  • Automatic installation and deinstallation of modules
  • Automatic resolution of module dependencies
  • Automatic integration of module documentation into the html-documentation that comes with ActivePerl.
  • Maintainance of a database of installed modules and module versions.
  • An easy-to-use shell

As always, there are some tripwires and things you should know.

Disadvantages

  • Core modules are not part of ppm's database
  • Less security. You cannot tell if the supplier added evil code to the XS-part of a module.

Invoking ppm

To invoke ppm, simply type ppm at the Windows console ("DOS") command line. The result will look similar to this:

C:\>ppm
PPM - Programmer's Package Manager version 3.1.
Copyright (c) 2001 ActiveState Corp. All Rights Reserved.
ActiveState is a devision of Sophos.

Entering interactive shell. Using Term::ReadLine::Stub as readline lib
+rary.

Type 'help' to get started.

ppm>

To get immediate help in the ppm-shell, type help or help .

Installing modules

In order to install a module you have basically two possibilities.

  • Specify a module to install directly
  • Search for a module and choose a one from the results shown

Direct install

To install a module (here: Death::Star) directly, simply type

ppm> install Death::Star

There is a drawback to using this method. If ppm finds more than one version of a module, you cannot choose which one gets installed. Naturally the most recent version gets installed, but there may be a case when you need to install another version. E.g. the most recent version can be buggy, or incompatible with another module you use.

You don't neccessarily need to use the ppm-shell to install a module. You can also use the following command to install a module directly from the command line.

C:\> ppm install Death::Star

Search-and-Install

To search for a module you use the search -command. The parameter for search is a case insensitive regex, thus if you don't know the module's full name, you can also search for pieces of it and you will get a list to choose from.

ppm> search Death::Star
Searching in Active Repositories
1. Death::Star [1.0] a module to kill planets
2. Death::Star [2.0] kill planets with more firepower
ppm>

You can find out more about a module by using the desc -command.

ppm> desc 2
====================
Package 2:
Name: Death::Star
Version: 2.0
Author: Darth Vader (anakin@the-empire.com)
Title: The Deathstar
Abstract: a planet killing module
Location: ActiveState PPM2 Repository
Available Platforms:
1. MSWin32-x86-multi-thread-5.8
====================

To install a module from the list, type install, followed by the module's number.

ppm> install 2

Regardless which method you choose, ppm will start to install the module and produce output like this:

Package 2:
====================
Install 'Death::Star' version 2.0 in ActivePerl 5.8.6.811.
====================
Downloaded 4657 bytes.
Installing C:\Perl\html\site\lib\Death\Star.html
Installing C:\Perl\site\lib\Death\Star.pm
Successfully installed Death::Star version 2.0 in ActivePerl 5.8.6.811
+.

ppm>

If the module has dependencies (that is, it requires another module to work correctly) the dependencies are installed first.

What is a repository?

From above, you may have noticed the term Active Repositories. ppm downloads the modules from special websites that are called repositories. A repository is a just a directory or a script that serves a list of ppd files to ppm. From these ppd files, ppm gets the actual location of the module's tarball. A freshly installed ActivePerl will come with two repositories. To find out about them, type rep.

ppm> rep
Repositories:
[ 1] ActiveState PPM2 Repository
[ 2] ActiveState Package Repository
ppm>

In order to find out, which url a repository points to, you can use the rep desc -command.

ppm> rep desc 1
Describing Active Repository 1:
Name: ActiveState PPM2 Repository
Location:
http://ppm.ActiveState.com/cgibin/PPM/ppmserver-5.8-windows.pl?urn:/PP
+MServer
Type: PPMServer 2.0
ppm>

Adding a repository

A lot of modules are not available from the standard repositories. Thank crunchy, the community provides a lot of alternative repositories that offer the missing modules. For example our fellow brother jenda hosts a repository at http://jenda.krynicky.cz/perl.

If you want to add such a repository to ppm you will have to use the rep add -command.

ppm> rep add jenda http://jenda.krynicky.cz/perl
Repositories:
[ 1] ActiveState PPM2 Repository
[ 2] ActiveState Package Repository
[ 3] jenda
ppm>

From there on, the repository is known to ppm and will be used for future searches.

You don't need to permanently add a repository to install a module from it. You can specify the repository from the command line.

C:\> ppm install http://the.empire-rules.com/ppm/Death-Star.ppd

Repositories.pm

So how, you might ask, do I find out where these repositories are? The answer to this question is PPM::Repositories.pm. That's a module that basically consists of a list of all known repositories. The, at the time of this writing, most recent version (0.9) is available at bribe's repository at http://www.bribes.org/perl/ppm/

With the following script, you can use PPM::Repositories.pm to add all known repositories to your ppm.
use PPM::Repositories;

for ( keys %Repositories )
{
print `ppm repository add $_ $Repositories{$_}->{location}`;
}

You should be aware that the more repositories you add, the longer it takes for a search to finish.

Getting around the proxy

If you are behind a proxy, you will notice that ppm cannot connect to the internet. To make it work, you will have to set a bunch of environment-variables, where xxx.xxx.xxx.x is the ip-address of the proxy, and y the port:

c:\> set http_proxy=http://xxx.xxx.xxx.x:yyyy
c:\> set http_proxy_user=username
c:\> set http_proxy_pass=password

Instead of entering the variables each time you before you start ppm, you have other possibilities to set them:

  • Click Start->Settings->Control Panel->System. Select the Expanded Tab, Click Environment. Click New, enter the appropriate values and click Ok.
  • Edit /perl/bin/ppm.bat and insert above lines right after @echo off

Creating a local repository

Still there may be some environments where that fails. But don't worry, there is an alternative, namely creating a local repository.

The first step doing so is to create a directory on your system that serves as the repository. Name and position of that directory is not important, I use /perl/ppm/repository as an example.

Then add that directory to your ppm using the command described in adding a repository.

ppm> rep add myRepository /perl/ppm/repository
The next step is to download the ppd file of the module and save it to your repository. A ppd file is a xml file that contains information about the module's position, version, etc. It looks like

The Deathstar
a planet killing module
Darth Vader (anakin@the-empire.com)






Identify the line that says . It informs you about the relative position of the module's tar.gz-file, aka tarball. Now download that tarball and save it into the same relative postion. In this example that would be /perl/ppm/repository/x86/Death-Star-2.0.tar.gz.

Now you can use ppm to install the module from your local repository.

Manual installation

You also have the choice to install the module manually. To do so, simply download the tarball and extract it with WinZip or a similar program.

A typical ppm-distribution looks like this:

C:/blib/
+---arch/
¦ +---auto/
¦ +---Death/
¦ +---Star/
¦ #Star.dll
+---html/
¦ +---site/
¦ +---lib/
¦ +--Death/
¦ #Star.html
+---lib/
+---Death/
#Star.pm

Now you can copy the files manually into your Perl's library tree, namely

C:\> copy \blib\lib\Death\Star.pm \Perl\site\lib\Death\Star.pm
C:\> copy \blib\arch\auto\Death\Star\Star.dll \Perl\site\lib\auto\Deat
+h\Star\Star.pm
C:\> copy \blib\html\site\lib\Death\Star.html \Perl\html\site\lib\Deat
+h\Star.html

Be aware that the module's html-documentation will not be integrated into the ActiveState-docs automatically. But if you do a complete rebuild of the HTML documentation, it will be added:

perl -MActivePerl::DocTools -e "UpdateHTML(1)"

Resources

Using PPM to install modules
PPM::Make - Make a ppm package from a CPAN distribution
ppm3 - Programmer's Package Manager, version 3.1
how to create a ppm-distribution
HowTo build and distribute a PPMed module for Win32

I hope this article can make its way into the tutorials section. I hereby invite every monk to improve this document.

Update: Corrected error concerning "Getting around the proxy"
Update: Included thundergnat's tip in the text, as suggested by GrandFather.


holli, /regexed monk/

Comment on A guide to installing modules for Win32
Select or Download Code
Re: A guide to installing modules for Win32
by jZed on Feb 26, 2005 at 20:32 UTC
    Well done! holli++
[reply]
Re: A guide to installing modules for Win32
by ww on Feb 28, 2005 at 02:06 UTC
    Excellent! holli++
[reply]
Re: A guide to installing modules for Win32
by mkirank on Mar 02, 2005 at 08:55 UTC
    You could also mention about Nmake and how to Install using Nmake
[reply]
    Re^2: A guide to installing modules for Win32
    by holli on Mar 02, 2005 at 09:09 UTC
      That is covered in A Guide to Installing Modules.


      holli, /regexed monk/
[reply]
      Re^3: A guide to installing modules for Win32
      by ysth on Sep 14, 2006 at 07:47 UTC
        Yes, but this purports to cover installing on Win32; how to get nmake and install a non-XS module from CPAN is a part of that. Though perhaps it would be sufficient to change:
        Installing modules directly from CPAN is easy, as long as the module contains no XS-extensions (C-code).
        to
        [id://435732|Installing modules directly from CPAN] is easy, as long as the module contains no XS-extensions (C-code).
[reply]
Re: A guide to installing modules for Win32
by thundergnat on May 06, 2005 at 14:35 UTC

    Be aware that the module's html-documentation will not be integrated into the ActiveState-docs.

    Not automatically, but if you do a complete rebuild of the HTML documentation, it will be added.

    perl -MActivePerl::DocTools -e "UpdateHTML(1)"

    Works quite nicely for manual installations.

[reply]
[d/l]
    Re^2: A guide to installing modules for Win32
    by bparent on May 09, 2005 at 20:31 UTC
      Slight change of topic, but I believe related. Installing ppm modules doesn't install the test files either. Is there a way like above with updatehtml to install tests?
[reply]
      Re^3: A guide to installing modules for Win32
      by holli on Jul 08, 2005 at 07:46 UTC
        Test files aren't installed, because they are not part of the ppm-package. You cannot install what isn't there ;-)


        holli, /regexed monk/
[reply]
    Re^2: A guide to installing modules for Win32
    by holli on Jul 08, 2005 at 07:44 UTC
      Very nice tip! ++ It was very handy for me today.


      holli, /regexed monk/
[reply]
Re: A guide to installing modules for Win32
by tphyahoo on May 09, 2005 at 13:47 UTC
    Thanks Holli, this was excellent.

    Jenda's repository appears to be down at the moment. This caused ppm to "sit and wait" for an awfully long time, with no feedback for several minutes, until it finally failed for me.

    So, obvious point, but you might want to mention that it's worth checking a repository with your web browser, or pinging it, before adding it, since ppm is so slow for this.

    UPDATE: So, I wrote a Script to update your PPM Repositories

[reply]
Re: A guide to installing modules for Win32
by greenFox on Jul 08, 2005 at 04:39 UTC

    Great tutorial, thanks. One small suggestion (because it took me a little while to work it out...) in the section "Creating a local repository" where you talk about downloading the ppd file and tarball it would probably help to mention that these files are downloaded from an existing repository. On that matter, is there a list of repositories available?

    --
    Murray Barton
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

[reply]
    Re^2: A guide to installing modules for Win32
    by holli on Jul 08, 2005 at 07:41 UTC
      The only list I know of is in Repositories.pm as mentioned here


      holli, /regexed monk/
[reply]
Re: A guide to installing modules for Win32
by tphyahoo on Aug 16, 2005 at 09:58 UTC
    Followup at PPM Hell: "PPM::PPD::init: not a PPD and not a file"
[reply]
Re: A guide to installing modules for Win32
by runrig on Jun 07, 2006 at 18:41 UTC
    I just wanted to mention that in general, it's better to specify the distribution name rather than the module name when using ppm install or ppm search. When you just specify the module name, ppm has to search for and guess which distribution the module is in. Once in a great while it gets it wrong or doesn't find the module. For modules with the same name as their distribution, this just involves s/::/-/g on the module name in the ppm install command.
[reply]
[d/l]
[select]
    Re^2: A guide to installing modules for Win32
    by QM on Jun 07, 2006 at 23:09 UTC
      I find that in many cases ppm can't find the module at all, and I have to go find the distribution name manually, guess (s/::/-/g), or give a too-general wildcard.

      So unless someone gives me a distribution name, I expect a headache.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

[reply]
[d/l]
Re: A guide to installing modules for Win32
by Anonymous Monk on Nov 23, 2006 at 09:06 UTC
    Hi Holli, Good tutorial. It really help me a lot.
[reply]
Re: A guide to installing modules for Win32
by culix on Jun 22, 2007 at 19:53 UTC
    Hi Holli,

    I'd like to share one other PPM quirk, as it took me a few hours to figure out. If the .tar.gz filename does not include the version number, PPM will not actually install the file when downloading from a local repository. I created a local repository on a network drive and copied over "Foo-Bar.ppd" and "Foo-Bar.tar.gz". When I told PPM to install the module it claimed success, but wouldn't actually copy the files to the local machine. Once I renamed the files to "Foo-Bar-0.1.ppd" and "Foo-Bar-0.1.tar.gz" they were installed correctly.

    Sorry if this is a rookie mistake, but I didn't see it mentioned here so I thought I would post.

    Thanks for writing the article, it was helpful.

[reply]

Back to Tutorials

Login:
Password
remember me
password reminder
Create A New User

Node Status
node history
Node Type: perltutorial [id://434813]
help
Chatterbox

[clinton]: dhoss when you talk about facing a problem, are you talking about planetscape?
[dhoss]: clinton: more like my own insecurities about penis size, my mother beating me, wearing women's clothing, etc.

How do I use this? | Other CB clients
Other Users
Others wandering the Monastery: (20)
Corion
GrandFather
diotalevi
mirod
ysth
jdporter
wfsp
atcroft
castaway
blue_cowdawg
RMGir
dhoss
Mutant
clinton
szbalint
cmeyer
Hansen
regexes
casiano
pss
As of 2007-07-18 08:46 GMT
Sections
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Snippets Section
Code Catacombs
Perl News
Information
PerlMonks FAQ
What's New at PerlMonks
Guide to the Monastery
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Outside Links
Find Nodes
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Perl.com
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth

The best Doctor:

William Hartnell
Patrick Troughton
Jon Pertwee
Tom Baker
Peter Davidson
Colin Baker
Sylvester McCoy
Paul McGann
Christopher Eccleston
David Tennant
Doctor Who?

Results (485 votes), past polls




相关文章

  • nginx编译参数
    http://nginx.org/en/docs/configure.html ########################## NGINX to Join F5; Announces Increased Commitment to O ...
  • 公司最近在做电子标签的项目在选择技术方案时用到了snmp服务功能故产生了该文档关于net-snmp维基百科简介:http://zh.wikipedia.org/zh/NET-SNMP安装配置共分以下几步1.获取源文件2.解压缩3.配置con ...
  • 1.首先要有个c编译器,推荐dev-cpp(开源免费的,网上自己搜索),记得要下含有mingw的就是了(不懂c,下载含有mingw的因为这个版本的bin目录里有gcc.exe等工具). 1.1安装好了编译器之后,要能在cmd中以命令方式运行 ...
  • apache的错误日志:Can't locate Net/Telnet.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at e:\proj\php\san2\SOURC ...
  • 笔记之一       Ruby之所以设计模块的概念,在于弥补传统的C之类语言的模块概念的缺失.在软件设计中,模块化体现很多很有用,它直接关系到软件设计的效率和灵活性.C中没有明显的模块的概念,就要由程序员自己通过软件的手段来强化模块概念,通 ...
  • 作为网络工程师,日常工作大多数时间都是在用telnet同交换机.路由器等网络设备打交道.如果说perl中有什么好用的模块,当然得提Net::Telnet.Net::Telnet功能全面,对于日常管理写个针对几台.几十台交换机的小程序还是不错 ...

2020 unjeep.com webmaster#unjeep.com
12 q. 0.012 s.
京ICP备10005923号