Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Using PerlApp or PAR with modules with data dependenciess

by Anonymous Monk
on Dec 15, 2017 at 16:59 UTC ( #1205604=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks

I am trying to pack into an executable (exe) a simple perl script containing a module with data dependencies. I am failing. I am working with ActiveState/PerlApp, but I would like to be able to solve the problem even with Strawberryperl/PAR-PP. I am simply trying to pack the following script with one module.

use Lingua::Sentence; my $splitter = Lingua::Sentence->new("en"); my $text = 'This is a paragraph. It contains several sentences +. "But why," you ask?'; print $splitter->split($text);

The problem has to do imho with this line

# Try loading nonbreaking prefix file specified in constructor my $dir = dist_dir('Lingua-Sentence');

Once generated the exe there is no more dist_dir, I guess (?). Of course I can twik this line of the module code (for example setting a $dir of my choice (and give my client both exe and the files upon which the module depends), but I do not thing this is the right way to do it. What do you think? PS: this applies to all other modules using some sort of data/files in their module folder.

Replies are listed 'Best First'.
Re: Using PerlApp or PAR with modules with data dependenciess
by marto (Cardinal) on Dec 15, 2017 at 19:06 UTC

    I've used pp many times over the years, you don't show how you tried to make the exe (see also How do I post a question effectively?), but calling it with the -x option tends to resolve many of these problems:

    pp -x -o package.exe source.pl

    This runs your program to determine any additional run time dependencies. I've tested this with the code above and the exe generated works as expected:

    C:\marto>package.exe This is a paragraph. It contains several sentences. "But why," you ask? C:\marto>perl -v This is perl 5, version 26, subversion 0 (v5.26.0) built for MSWin32-x +64-multi-t hread Copyright 1987-2017, 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.org/, the Perl Home Pa +ge.

      This works. PAR is probably much better than the commercial PerlApp.

        When working on Windows I stick to Strawberry for its sane build environment (C compiler, build tools, many useful modules as standard), and pp for when I have to build executables. It just made life much easier.

Re: Using PerlApp or PAR with modules with data dependenciess
by Marshall (Canon) on Dec 15, 2017 at 22:17 UTC
    I am not completely sure in this particular case, but with PerlApp, often the answer is to add more "use" statements, like this:
    use Lingua; use Lingua::Sentence;
    PerlApp uses the "use" statements to decide what to include into the .exe. If this file is part of the base module's manifest, then this will work. Give it a try and let us know what happens. To force a random file into the .exe with PerlApp like perhaps a .gif that your user code needs, it is easiest to start the GUI version (perlapp with no parameters). If memory serves me correctly, there are some obvious options to select a file. However for the program itself, try the above first.

    Update: here is a node where a similar suggestion worked: PerlApp and Win32::Unicode The OP's question is a bit different, but close enough that an attempt is warranted.

      Thank you for your suggestion. Without adding:

      use Lingua;

      the exe made by PerlApp (standard settings) produces at runtime following error message related to the line of code I pointed to in the OP:

      Failed to find share dir for dist 'Lingua-Sentence' at /<C:\Users\XY\s +plitter.exe>Lingua/Sentence.pm line 24.

      If I add:

      use Lingua;

      PerlApp is not capable of compile the script. Following error message:

      PerlApp is not able to locate Lingua.pm using the current module searc +h path. This module is probably required. If this module is require +d then adjust the module search path on the Main tab so that it can b +e found. Otherwise consider trimming the module in order to hide thi +s error.

      a quick check confirms that there is no Language.pm module in Perl/site/lib/(Language)

        Well, did you use the ActiveState ppm (Perl Package Manager) application to install these modules? I suspect that you don't have a valid ActiveState Perl installation.

        I looked with ppm on my current installation. I think you need to install Lingua-EN-Sentence using ppm. The ActiveState tools do work, but you have to "play by their rules".

Re: Using PerlApp or PAR with modules with File::Sharedir::dir_data dependenciess (try File::ShareDir::PAR)
by beech (Parson) on Dec 16, 2017 at 04:01 UTC

    Hi,

    Try File::ShareDir::PAR - File::ShareDir with PAR support

    So yourprogram.pl becomes

    #!/usr/bin/perl -- use File::ShareDir::PAR 'global'; use Lingua::Sentence; ...

    Then do the regular  pp -x yourprogram.pl

    or maybe even the new(to me ) ppsimple.pl yourprogram.pl

Re: Using PerlApp or PAR with modules with data dependenciess
by salva (Abbot) on Dec 16, 2017 at 10:06 UTC
    Take a look at Win32::Packer. It lets one pack scripts with their dependencies and any additional data files and executables into a standard Windows MSI installer.

    So far I have focused in making it work under Strawberry Perl only, but AFAIK, there is not any reason stopping it for working on Activestate Perl besides the expected common, minor, easy to fix, compatibility issues.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-10-21 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (223 votes). Check out past polls.

    Notices?