Skip Menu |
 

This queue is for tickets about the PAR-Packer CPAN distribution.

Report information
The Basics
Id: 57494
Status: resolved
Priority: 0/
Queue: PAR-Packer

People
Owner: Nobody in particular
Requestors: thakore.kartik [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: kmx [...] volny.cz
Subject: JSON::Any doesn't package in PAR?
Date: Fri, 14 May 2010 20:31:17 +0000
To: bug-PAR-Packer [...] rt.cpan.org
From: Kartik Thakore <thakore.kartik [...] gmail.com>
Download (untitled) / with headers
text/plain 359b
Hi, PAR::Packer can't seem to handle JSON::Any type packages. Here is a simple why to test this. $ pp -B -M JSON::Any -M JSON::XS -M JSON -e 'use JSON::Any; my $j = JSON::Any->new' $ ./json Couldn't find a JSON package. Need XS, JSON, or DWIW at script/ppXAgmN.pl line 1 BEGIN failed--compilation aborted at script/ppXAgmN.pl line 1. regards, Kartik
CC: par [...] perl.org
Subject: Re: [rt.cpan.org #57494] JSON::Any doesn't package in PAR?
Date: Sat, 15 May 2010 12:45:35 +0200
To: bug-PAR-Packer [...] rt.cpan.org
From: Roderich Schupp <roderich.schupp [...] googlemail.com>
Download (untitled) / with headers
text/plain 2.4k
On Fri, May 14, 2010 at 10:31 PM, Kartik Thakore via RT <bug-PAR-Packer@rt.cpan.org> wrote: Show quoted text
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=57494 > > ... > PAR::Packer can't seem to handle JSON::Any type packages. > > Here is a simple why to test this. > >  $ pp -B -M JSON::Any -M JSON::XS -M JSON -e 'use > JSON::Any; my $j = JSON::Any->new' >  $ ./json > Couldn't find a JSON package. Need XS, JSON, or DWIW at > script/ppXAgmN.pl line 1
(cc'ing to par mailing list) Ouch! There are actually several problems here: (1) Simply $ pp -o json -e 'use JSON::Any; 1;' (when you have actually JSON::XS installed) should have worked - at least it packed JSON/Any.pm and correctly inferred JSON/XS.pm and packed it, too. But JSON::XS (as JSON::Any's first choice) couldn't be loaded (see (2)), so JSON went on looking for JSON which you had also explicitly packed. That couldn't be loaded either (see (3)), so JSON::Any tried JSON::DWIW which wasn't packed. So that's the error message you got. Note that JSON::Any suppresses the actual errors from loading JSON::XS etc (2) If you explicitly tried to pack JSON::XS, e.g. $ pp -o jsonxs -e 'use JSON::XS; 1;' you would have seen: $ ./jsonxs Can't locate attributes.pm in @INC (@INC contains: ...) at /usr/lib/perl/5.12/DynaLoader.pm line 215. BEGIN failed--compilation aborted. But why is attributes.pm required (and hasn't been packed)? Turns out the XS part of JSON::XS (i.e. JSON-XS-2.29/XS.xs) contains SV *incr_text (JSON *self) ATTRS: lvalue CODE: { ... That's XS for Perl sub incr_text : lvalue { .... It's specifying an "lvalue" attribute on a subroutine. Either form causes the Perl runtime to implicitly "require attributes". Of course, this implicit requirement can't be detected by Module::ScanDeps (which is used by PAR::Packer to find recursively all modules used by your script ). As an immediate band-aid for your problem, add "-M attributes" to your pp command line and that should make at least JSON::XS (and thus JSON::Any) work. (3) As for JSON, if you tried $ pp -o jasonpp -e 'use JSON; 1;' you would have got ./jasonpp Can't locate JSON/PP.pm in @INC (@INC contains: ...) at (eval 24) line 2. at script/pp7Jv9C.pl line 1 Compilation failed in require at script/pp7Jv9C.pl line 1. So it's missing JSON/PP. But that in turn requires JSON/PP58 (or some other JSON/PPnn depending on your actual version of perl). This probably warrants a special rule in Module::ScanDeps. Cheers, Roderich
CC: par [...] perl.org
Subject: Re: [rt.cpan.org #57494] JSON::Any doesn't package in PAR?
Date: Sat, 15 May 2010 14:04:47 +0200
To: bug-PAR-Packer [...] rt.cpan.org
From: Roderich Schupp <roderich.schupp [...] googlemail.com>
Download (untitled) / with headers
text/plain 905b
Following up on my previous post: - JSON::XS needs "attributes.pm" which can't be autodetected. We could add a special rule to Module::ScanDeps for this. But as it turns out, "attributes.pm" is another one of those modules that might be implicitly require'd by the Perl runtime itself (like "Errno.pm" or "PerlIO.pm"), I'm inclined to add it to the list of "always pack" modules (cf. sub require_modules in PAR-Packer/script/par.pl). @Steffen: What do you think? - JSON needs a special rule in Module::ScanDeps to add all of JSON/PP.pm JSON/PP5005.pm JSON/PP58.pm JSON/PP JSON/PP/Boolean.pm JSON/PP56.pm This will do the trick: 'JSON.pm' => sub { # ignore other JSON::* modules (e.g. JSON::Syck, JSON::Any), # but accept JSON::XS (because JSON.pm might use it if present) return( grep /^JSON\/(PP|XS)/, _glob_in_inc('JSON', 1) ); }, Cheers, Roderich
Subject: Re: [rt.cpan.org #57494] JSON::Any doesn't package in PAR?
Date: Sun, 16 May 2010 16:22:41 +0200
To: bug-PAR-Packer [...] rt.cpan.org
From: Steffen Mueller <smueller [...] cpan.org>
Download (untitled) / with headers
text/plain 1.2k
Hi Roderich, Roderich Schupp via RT wrote: Show quoted text
> Queue: PAR-Packer > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=57494 > > > Following up on my previous post: > > - JSON::XS needs "attributes.pm" which can't be autodetected. > We could add a special rule to Module::ScanDeps for this.
Ah, another one of those ugly implicit dependencies. Show quoted text
> But as it turns out, "attributes.pm" is another one of those modules > that might be implicitly require'd by the Perl runtime itself > (like "Errno.pm" or "PerlIO.pm"), I'm inclined to add it to the > list of "always pack" modules (cf. sub require_modules > in PAR-Packer/script/par.pl). > > @Steffen: What do you think?
I don't think have have a choice other than to do that. Show quoted text
> - JSON needs a special rule in Module::ScanDeps to add all of > > JSON/PP.pm > JSON/PP5005.pm > JSON/PP58.pm > JSON/PP > JSON/PP/Boolean.pm > JSON/PP56.pm > > This will do the trick: > > 'JSON.pm' => sub { > # ignore other JSON::* modules (e.g. JSON::Syck, JSON::Any), > # but accept JSON::XS (because JSON.pm might use it if present) > return( grep /^JSON\/(PP|XS)/, _glob_in_inc('JSON', 1) ); > },
This looks correct. Best regards, Steffen
Download (untitled) / with headers
text/plain 295b
I'e committed the proposed fixes to Module::ScanDeps and PAR::Packer. The former should make packing JSON work and the latter should make packing JSON::XS work. You need both to make JSON::Any work (if your actually installed JSON modules are either JOSON or JSON::XS or both). Cheers, Roderich


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.