Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

strawberry par::packer, @INC and the difference between -c and -x

by Boldra (Deacon)
on Nov 26, 2009 at 09:08 UTC ( #809508=perlquestion: print w/ replies, xml ) Need Help??
Boldra has asked for the wisdom of the Perl Monks concerning the following question:

For some reason I'm not getting the libraries in my par exe that I want. I've boiled the problem down to the following test case:

c:\temp\test\lib\strict.pm:

package strict; $VERSION = 1001; 1;
c:\temp\test\test.pl:
use strict 100; print "strict=$INC{'strict.pm'}\n";
Then when packaging I get:
C:\temp\test>c:\strawberry\perl\bin\perl.exe c:\strawberry\perl\bin\pp + -x -I lib test.pl strict=lib/strict.pm Unquoted string "prefork" may clash with future reserved word at c:/st +rawberry/perl/site/lib/PAR.pm line 16, <_FH> chunk 1. C:\temp\test>c:\strawberry\perl\bin\perl.exe c:\strawberry\perl\bin\pp + -c -I lib test.pl strict version 100 required--this is only version 1.04 at GbLRp4 line +4. BEGIN failed--compilation aborted at GbLRp4 line 4. Couldn't open GbLRp4.out at c:/strawberry/perl/site/lib/Module/ScanDep +s.pm line 1266.
The warning about the unquoted string doesn't really interest me. The point is that -x works (finds strict version 1001), but -c (or -o) doesn't work.

What I'm trying to do is create a portable binary, with a different version of a library which is also in core. It seems that when I try to create an exe (with -o or -c), my local strict.pm is ignored in favour of the global one. In reality it's Win32::TieRegistry I'm trying to distribute with my exe (because the cpan version still doesn't include this patch).

I've also tried adding -Ilib to the perl switches (between perl.exe and pp). As a workaround I will update my global version of the module just for compiling :(.

Thanks for any help on this.



- Boldra

Comment on strawberry par::packer, @INC and the difference between -c and -x
Select or Download Code
Re: strawberry par::packer, @INC and the difference between -c and -x
by Anonymous Monk on Nov 26, 2009 at 10:48 UTC
    There is no report about that 64 issue at http://rt.cpan.org/Public/Dist/Display.html?Name=Win32-TieRegistry

    Win32::TieRegistry is not a core module

    It works for me ( just copied strict, changed version to 666)

    $ cat mystrict.pl #!/usr/bin/perl -- use strict; warn $INC{'strict.pm'}; warn $strict::VERSION; $ perl mystrict.pl C:/perl/5.10.1/lib/strict.pm at mystrict.pl line 4. 1.04 at mystrict.pl line 5. $ perl -Ilib mystrict.pl lib/strict.pm at mystrict.pl line 4. 666 at mystrict.pl line 5. $ pp -I lib mystrict.pl $ a.exe /loader/HASH(0xa9428c)/strict.pm at script/mystrict.pl line 4. 666 at script/mystrict.pl line 5. $ pmvers PAR PAR::Packer PAR: 0.994 PAR::Packer: 1.001 $
    update: I didn't use -c, but with -c I get a warning
    $ pp -c -I lib mystrict.pl Different modules for file 'strict.pm' were found. -> Using 'C:/perl/5.10.1/lib/strict.pm'. -> Ignoring 'C:/temp/lib/strict.pm'.
    no issue with -o
    $ pp -o mystrict.exe -I lib mystrict.pl $ mystrict.exe /loader/HASH(0xa942d4)/strict.pm at script/mystrict.pl line 4. 666 at script/mystrict.pl line 5.
    same behaviour with -c even if I load my strict first
    $ perl -Ilib -Mstrict -S pp -c -I lib mystrict.pl Different modules for file 'strict.pm' were found. -> Using 'C:/perl/5.10.1/lib/strict.pm'. -> Ignoring 'C:/temp/lib/strict.pm'.
    The error message comes from Module::ScanDeps. This is probably a bug.
Re: strawberry par::packer, @INC and the difference between -c and -x
by morgon (Deacon) on Nov 27, 2009 at 23:42 UTC
    I am rather new to both Windows and PAR, so maybe I don't really understand what you are trying to achieve, but here are my experiments with Strawberry 5.10.1 on Windows XP (with cygwin):

    In my working directory I have a script "a.pl" that looks like this:

    BEGIN { unshift @INC, "." } use strict; print "I have: $strict::VERSION\n";
    Running it produces "I have: 1.04".

    Now I make a copy of strict.pm to my local directory and change the version number to 3.45 like this:

    cp c:/strawberry/perl/lib/strict.pm . perl -i.old -pe 's/VERSION = .*/VERSION = "3.45";/' strict.pm
    Running a.pl now produces "I have 3.45" - so far so good.
    Now I want to build an exe that contains my modified strict.pm but -x does not do the trick:
    perl C:/strawberry/perl/bin/pp -o a.exe -x a.pl a.exe
    This produces "I have: 1.04" so pp packed the core-lib with surprises me as I thought -x (running the script) would detect that we are picking up our modified strict.pm - so my impression is that -x does not work (or I don't understand what it should do).

    However --lib seems to work fine:

    perl C:/strawberry/perl/bin/pp -o a.exe --lib=. a.pl a.exe
    Now I get "I have: 3.45" as desired.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2015-07-03 13:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls