Skip Menu |

This queue is for tickets about the Module-ScanDeps CPAN distribution.

Report information
The Basics
Id: 55923
Status: resolved
Priority: 0/
Queue: Module-ScanDeps

People
Owner: Nobody in particular
Requestors: kmx [...] cpan.org
Cc:
AdminCc:

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



Subject: pp not packing distribution share dir contents
Hi,

I have tried to create a PAR archive from a perl script using a module with so called share dir (see http://search.cpan.org/dist/Module-Install/lib/Module/Install/Share.pm or http://search.cpan.org/dist/File-ShareDir/lib/File/ShareDir.pm).

What I have expected is that in my_perl_script.pl does "use MyModule::WithShare;" that PAR packer will also include the content of distribution share dir of the distribution containing MyModule::WithShare. However the resulting PAR file does not seem to contain files installed into dist share dir.

I am not saying this is a bug; maybe I have not specified some necessary parameter when running pp command (I simply run: pp -o test.par my_perl_script.pl) or perhaps this issue should be discussed somewhere else (Module::ScanDeps?).

Some details about my test environment:
- Win32 Strawberry Perl 5.10.1
- PAR::Packer 1.002
- Module::ScanDeps 0.96

Could you please give me some hint on how to get share dir content into a PAR archive? I gues that it should be possible as there exists File::ShareDir::PAR that solves a problem how to find share dir inside PAR (I am currently not even able to create such a PAR).

Thanks in advance for any feedback.

--
kmx

CC: par [...] perl.org
Subject: Re: [rt.cpan.org #55923] pp not packing distribution share dir contents
Date: Thu, 25 Mar 2010 14:52:29 +0100
To: bug-PAR-Packer [...] rt.cpan.org
From: Steffen Mueller <smueller [...] cpan.org>
Hi there, kmx via RT wrote: Show quoted text
> I have tried to create a PAR archive from a perl script using a module with so > called share dir (see > http://search.cpan.org/dist/Module-Install/lib/Module/Install/Share.pm or > http://search.cpan.org/dist/File-ShareDir/lib/File/ShareDir.pm). > > What I have expected is that in my_perl_script.pl does "use > MyModule::WithShare;" that PAR packer will also include the content of > distribution share dir of the distribution containing MyModule::WithShare. > However the resulting PAR file does not seem to contain files installed into > dist share dir. > > I am not saying this is a bug; maybe I have not specified some necessary > parameter when running pp command (I simply run: pp -o test.par > my_perl_script.pl) or perhaps this issue should be discussed somewhere else > (Module::ScanDeps?). > > Some details about my test environment: > - Win32 Strawberry Perl 5.10.1 > - PAR::Packer 1.002 > - Module::ScanDeps 0.96 > > Could you please give me some hint on how to get share dir content into a PAR > archive? I gues that it should be possible as there exists File::ShareDir::PAR > that solves a problem how to find share dir inside PAR (I am currently not even > able to create such a PAR). > > Thanks in advance for any feedback.
Essentially, you'll have to use the -a (or -A) option of pp to manually add files to the .par file. Module::ScanDeps has no way to determine that/whether a given module has "share"-like data attached. Or maybe it could find out, but I don't think it does. (Patches welcome!) Cheers, Steffen
Subject: Re: [rt.cpan.org #55923] pp not packing distribution share dir contents
Date: Thu, 25 Mar 2010 15:31:15 +0100
To: bug-PAR-Packer [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
Dne 25.3.2010 14:52, Steffen Mueller via RT napsal(a): Show quoted text
> ... > > Essentially, you'll have to use the -a (or -A) option of pp to manually > add files to the .par file. Module::ScanDeps has no way to determine > that/whether a given module has "share"-like data attached. Or maybe it > could find out, but I don't think it does. (Patches welcome!) >
Well, let us say at some point we know that we need to bundle Some::Module IMHO it is quite straightforward to determine where is the sharedir corresponding to Some::Module - something like this: $dir = module_dir('File::ShareDir'); - via Find::ShareDir. Then we have just to decide where in PAR structure should the content of sharedir has to be copied (perhaps somewhere under lib/auto/share/...). Do I understand that it is more a question on Module::ScanDeps than PAR::Packer? -- kmx
Subject: Re: [rt.cpan.org #55923] pp not packing distribution share dir contents
Date: Thu, 25 Mar 2010 15:53:52 +0100
To: bug-PAR-Packer [...] rt.cpan.org
From: Steffen Mueller <smueller [...] cpan.org>
Hi, kmx via RT wrote: Show quoted text
> Well, let us say at some point we know that we need to bundle > Some::Module IMHO it is quite straightforward to determine where is the > sharedir corresponding to Some::Module - something like this: $dir = > module_dir('File::ShareDir'); - via Find::ShareDir. Then we have just to > decide where in PAR structure should the content of sharedir has to be > copied (perhaps somewhere under lib/auto/share/...). > > Do I understand that it is more a question on Module::ScanDeps than > PAR::Packer?
Hmm. Not really, it's both. IMHO M::SD should flag a module as "this has share-type data!" and PAR::Packer needs to recognize that and pack it. Maybe it should do so only if a specific option is present, but I think it's a reasonable default. Regarding the location inside the PAR: A .par is more or less the same as a blib/ directory of a freshly-built CPAN distribution. If you run "perl Makefile.PL && make" for something that uses, eg., Module::Install::Share to handle share-type data, this will tell you where the stuff should go in the PAR file. I believe it's the same location as in the installed case. Best regards, Steffen
Subject: Re: [rt.cpan.org #55923] pp not packing distribution share dir contents
Date: Thu, 25 Mar 2010 16:00:46 +0100
To: bug-PAR-Packer [...] rt.cpan.org
From: Roderich Schupp <schupp [...] argumentum.de>
On Thu, Mar 25, 2010 at 3:31 PM, kmx via RT <bug-PAR-Packer@rt.cpan.org> wrote: Show quoted text
> sharedir corresponding to Some::Module - something like this: $dir = > module_dir('File::ShareDir'); - via Find::ShareDir. Then we have just to > decide where in PAR structure should the content of sharedir has to be > copied (perhaps somewhere under lib/auto/share/...). > > Do I understand that it is more a question on Module::ScanDeps than > PAR::Packer?
That depends where you want to implement it: Module::ScanDeps already contains special rules for certain "pathologic" modules where the simple rule: If we see "use Foo" then (a) add Foo.pm as a dependency and (b) add Foo.pm to the list of files to be scanned. isn't enough. IMHO it would be better to implement it as just another option for pp, similar to -MFoo that says: Add Foo.pm (and all its dependencies) in addition to what Module::ScanDeps determines from the script to pack. As Steffen already wrote: patches welcome. Cheers, Roderich
RT-Send-CC: schupp [...] argumentum.de, smueller [...] cpan.org
Show quoted text
> As Steffen already wrote: patches welcome.

OK, so I have done more investigation and come to the enclosed patch (it is a patch for Module::ScanDeps, sorry for posting it here).

With the enclosed patch the content of module/distribution sharedirs is automatically packed into PAR archive. As far as I was able to test the usage of File::Sharedir works - there is no need for the special File::Sharedir::PAR.

My patch is just an idea that seems to work splendid for my test cases, however I do know just a very little about pp / PAR / ScanDeps guts so my patch might be totally out of concept.

Note1: the patch is against latest SVN trunk

Note2: small testing sample_script.pl

use File::ShareDir 'dist_file';
my $f = dist_file('File-ShareDir', 'sample.txt');
print "FILE=$f\n\n";
print "RESULT=" . ((-f $f) ? "OK" : "FAILED!!!") . "\n\n";

just try (on Win box): pp -o sample_script.exe sample_script.pl

--
kmx
Subject: scandeps-sharedir-support.patch
Index: lib/Module/ScanDeps.pm =================================================================== --- lib/Module/ScanDeps.pm (revision 1150) +++ lib/Module/ScanDeps.pm (working copy) @@ -1026,6 +1026,23 @@ file => $_->{file}, used_by => $module, type => $type ); } + + ### Now, handle module and distribudion share dirs + # convert 'Module/Name' to 'Module-Name' + my $modname = $path; + $modname =~ s|/|-|g; + # TODO: get real distribution name related to module name + my $distname = $modname; + foreach (_glob_in_inc("auto/share/module/$modname")) { + _add_info( rv => $rv, module => "auto/share/module/$modname/$_->{name}", + file => $_->{file}, used_by => $module, + type => 'data' ); + } + foreach (_glob_in_inc("auto/share/dist/$distname")) { + _add_info( rv => $rv, module => "auto/share/dist/$distname/$_->{name}", + file => $_->{file}, used_by => $module, + type => 'data' ); + } } } # end for modules return $rv;
Thanks applied. Will be in the next Module::ScanDeps release! --Steffen