Difference between revisions of "CPAN"

From GnuCash
Jump to: navigation, search
(Other: Expand OSX instructions to include installing a compiler and make facility.)
(Rewrite. The old version was thoroughly out of date.)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[http://cpan.org/ Comprehensive Perl Archive Network] (CPAN) is the default tool to manage perl programs and modules on your computer. Because GnuCash uses the perl module [http://sourceforge.net/projects/finance-quote Finance::Quote] to get online quotes for commodities, it can be useful to have some knowledge of this tool beneath the Gnucash specific gnc-fq-* scripts.
+
[http://cpan.org/ Comprehensive Perl Archive Network] (CPAN) is the standard tool to manage perl programs and modules on your computer. Because GnuCash uses the perl module [https://github.com/finance-quote/finance-quote Finance::Quote] to retrieve prices for securities and exchange rates for currencies, it can be useful to have some knowledge of this tool beneath the Gnucash specific gnc-fq-* scripts.
== Preface ==
 
=== Annotation ===
 
Currently this page shows the typical linux commands. The call or whole proceeding may vary for other OSes. Feel free to add them.
 
  
=== Abbreviations: gnc-fq-* scripts ===
+
Perl includes a <tt>cpan</tt> program to interact with the CPAN database and to download, build, and install modules and programs.
In many cases there is no need to run ''cpan'' directly. GnuCash is shipped with a set of perl scripts, which will do the most usual things for you:
+
=== Administrative Access ===
* Check and update your F::Q installation
+
By default they're installed in system directories so it's necessary to call <tt>cpan</tt> with administrative (a.k.a. root) privileges. On Unix system (including Apple MacOS) one uses the <tt>sudo</tt> ("switch-user-do") command wrapper, as in
** '''gnc-fq-check''': A list of quote sources supported by Finance::Quote, or the single term missing-lib if finance quote could not be executed.
+
  sudo cpan -i Finance::Quote
**  '''gnc-fq-update''': installs or updates Finance::Quote and its dependencies (using cpan)
+
that will install the Finance::Quote module and everything it needs. '''N.B.''' at the time this is written GnuCash also requires the <tt>Date::Manip</tt> module.
* Check your commodities
 
**  '''gnc-fq-dump''': obtains information from Finance::Quote about any specified stock, and then dumps it to the screen in annotated form.
 
*:This will allow someone to see what is returned, and whether it provides all the information needed by Gnucash.
 
** '''gnc-fq-helper''': present a scheme interface to Finance::Quote
 
If they solve your problem, there is no need to read further.
 
== Using CPAN ==
 
=== Caution: Root Access ===
 
Because you usually use this tool to update system libraries, it needs root/superuser/administrator access. So you should prefix the command by the command '''sudo''' which will ask you for the root password - at least on unixoid systems - or run it in a root shell which can be reached by entering '''su''' in a normal shell. (FIXME: and Windows?)
 
  
=== First Run: Configuration ===
+
In general one must have a user id that's authorized to manage the computer's settings in order to use sudo.
On the first run, ''cpan'' needs some configuration
 
<pre>
 
> sudo cpan
 
root's password:
 
  
CPAN.pm requires configuration, but most of it can be done automatically.
+
=== cpan setup ===
If you answer 'no' below, you will enter an interactive dialog for each
+
The first time you run cpan it will need to configure some internal modules, learn about your network, and have you designate the cpan mirrors to use. It runs a script to do this and provides defaults that are nearly always right so you can just run through the script accepting all of the defaults.
configuration option instead.
 
  
Would you like to configure as much as possible automatically? [yes]
+
=== Using cpan to install modules ===
</pre>
+
On Unix systems (including MacOS) cpan retrieves source archives of modules and if necessary compiles them on your system. That means that you will need at least a compiler and the basic development libraries for your system. On Linux and BSD systems you may need to install these with your package manager. On MacOS the system will offer to install the Command Line Developer Tools if you don't already have either them or Xcode installed.
In the following section you can usually just press the <enter> key to get a good result.
 
  
=== Overview ===
+
=== Microsoft Windows ===
cpan --help
+
Unlike Unix-based operating systems Microsoft Windows doesn't include the Perl language, so GnuCash provides a menu item, "Install Online Quote Retrieval" that runs a script to install a Perl package (Strawberry Perl) and all of the Finance::Quote requirements. Strawberry Perl includes all of the components needed for cpan so that there's no need to separately install a compiler. It also doesn't install modules into system directories so administrative privileges are generally not required. The Strawberry Perl Start Menu folder includes a <tt>cpan terminal</tt> item that launches a cpan shell correctly configured for the Strawberry Perl installation.
shows you the usage. For more details run
 
  perldoc -F /usr/bin/cpan
 
  
=== Check your F::Q Installation ===
+
== gnc-fq-update ==
cpan -D Finance::Quote
+
GnuCash provides a Perl program, <tt>gnc-fq-update</tt> that will run cpan for you and install all of the Perl modules currently required. As noted above the first time you do this it will run the setup script in which you can simply accept all of the defaults.
will show you the details of your F::Q module:
 
<pre>
 
Finance::Quote
 
-------------------------------------------------------------------------
 
        Fetch stock prices over the Internet
 
        E/EC/ECOCODE/Finance-Quote-1.17.tar.gz
 
        /usr/lib/perl5/vendor_perl/5.14.2/Finance/Quote.pm
 
        Installed: 1.17
 
        CPAN:      1.17  up to date
 
        David Hampton (HAMPTON)
 
        hampton@employees.org
 
</pre>
 
Now you know the folowing:
 
:* Your version is the latest published.
 
::*If not, you should update it before trying to manually patch something.
 
:* The path to the library, if you need to update single modules.
 
 
 
== Other ==
 
For the ''Quartz'' version of ''OSX' the commands to update fq':
 
sudo perl -MCPAN -e shell
 
sudo /Applications/Gnucash.app/Contents/Resources/bin/gnc-fq-update
 
Or double-click on the "FinanceQuote Update" applet in the Gnucash dmg.
 
 
 
Note that CPAN requires 'make' and a compiler. Depending upon your OSX version, you may need to install some extra software:
 
* On OSX 10.9 (Mavericks), just launch CPAN. When it needs to build something, OSX will prompt you to install the command line tools. You'll need to re-run your cpan command (just push the up-arrow key in Terminal, then <return>) when it finishes.
 
* On OSX 10.6 (Snow Leopard), 10.7 (Lion), and 10.8 (Mountain Lion), install Xcode, a free download from the App Store. In XCode Preferences, select "Downloads" and the "command line tools" component. Once it's installed you can run CPAN.
 
* On OSX 10.5 (Leopard), you'll need to find your distribution DVD and install Xcode from that. Command line tools are installed automatically by default.
 
* Gnucash doesn't support earlier versions of OSX. Sorry.
 

Latest revision as of 03:21, 12 August 2019

Comprehensive Perl Archive Network (CPAN) is the standard tool to manage perl programs and modules on your computer. Because GnuCash uses the perl module Finance::Quote to retrieve prices for securities and exchange rates for currencies, it can be useful to have some knowledge of this tool beneath the Gnucash specific gnc-fq-* scripts.

Perl includes a cpan program to interact with the CPAN database and to download, build, and install modules and programs.

Administrative Access

By default they're installed in system directories so it's necessary to call cpan with administrative (a.k.a. root) privileges. On Unix system (including Apple MacOS) one uses the sudo ("switch-user-do") command wrapper, as in

 sudo cpan -i Finance::Quote

that will install the Finance::Quote module and everything it needs. N.B. at the time this is written GnuCash also requires the Date::Manip module.

In general one must have a user id that's authorized to manage the computer's settings in order to use sudo.

cpan setup

The first time you run cpan it will need to configure some internal modules, learn about your network, and have you designate the cpan mirrors to use. It runs a script to do this and provides defaults that are nearly always right so you can just run through the script accepting all of the defaults.

Using cpan to install modules

On Unix systems (including MacOS) cpan retrieves source archives of modules and if necessary compiles them on your system. That means that you will need at least a compiler and the basic development libraries for your system. On Linux and BSD systems you may need to install these with your package manager. On MacOS the system will offer to install the Command Line Developer Tools if you don't already have either them or Xcode installed.

Microsoft Windows

Unlike Unix-based operating systems Microsoft Windows doesn't include the Perl language, so GnuCash provides a menu item, "Install Online Quote Retrieval" that runs a script to install a Perl package (Strawberry Perl) and all of the Finance::Quote requirements. Strawberry Perl includes all of the components needed for cpan so that there's no need to separately install a compiler. It also doesn't install modules into system directories so administrative privileges are generally not required. The Strawberry Perl Start Menu folder includes a cpan terminal item that launches a cpan shell correctly configured for the Strawberry Perl installation.

gnc-fq-update

GnuCash provides a Perl program, gnc-fq-update that will run cpan for you and install all of the Perl modules currently required. As noted above the first time you do this it will run the setup script in which you can simply accept all of the defaults.