Re: shipping extra files in a dist?

2008-04-25 Thread Gabor Szabo
On Fri, Apr 25, 2008 at 6:43 PM, Aristotle Pagaltzis <[EMAIL PROTECTED]> wrote:
> * Jerome Quelin <[EMAIL PROTECTED]> [2008-04-25 09:40]:
>
> > i'm writing a tk app that i'm shipping as a cpan dist. this app
>  > needs some extra resource files (icons, etc) i'd like to know
>  > what's the best method to ship extra data files in a dist.
>
>  Do they need to be physical files or do you just need the data to
>  tag along somewhere? If you just need the data the, you could
>  have a helper script that takes the files in the source tree and
>  sticks them at the bottom of your main module after __DATA__, or
>  in a My::App::Data module after __DATA__, or as string constants,
>  possibly uuencoded (cf. `perldoc pack`), etc.
>
>  Regards,
>  --
>  Aristotle Pagaltzis // 
>

I just wanted to ask the same question for a Gtk2 application I am writing.
It has an  xml file generated by Glade and currently during perl Makefile.PL
I generate a .pm module from the xml file with a single function that returns
the content of the xml file.

It works, but I think including the content of these extra files in
.pm files is not
the right direction.

I think the Perl community should come up with some more-or-less
standard solution supported by Module::Build and MakeMaker that also
plays well with the downstream distributors.

Maybe there should be an extra/ directory defined by perl where each
module can have its own directory to put its extra files to.

regards
   Gabor

-- 
Gabor Szabo
http://www.szabgab.com/


Re: Application Building

2008-04-25 Thread Jonathan Rockway

You really didn't say much about what you're trying to do.  You said you
did some stuff and some other stuff didn't happen.  It's hard to help
you -- what *exactly* is the problem?  (There are plenty of things that
install and run apps on the CPAN.  App::Ack comes to mind.  It Just
Works, there is nothing special you need to do.)

That said, I always do this:

  package MyApp::Script::Whatever;
  use Moose;
  with 'MooseX::Getopt';

  has ...;
  sub run { ... }

Then:

  #!/usr/bin/env perl
  use FindBin qw($Bin);
  use lib "$Bin/../lib";
  use MyApp::Script::Whatever;
  
  MyApp::Script::Whatever->new_with_options->run;

This is similar to your "parse $0" solution.  But of course it won't
work for installed scripts where the library directory isn't in @INC.

>   If I put #!perl at the top of display.pl it will have a path to perl
> (though not the one I specified), but it won't have "use lib $HOME/MyApp/lib"
> at the top of the script, so it can't run.
>   Furthermore, there's no way for the script to know what was used
> for install_base, so there's no way for the script to know where the data
> file is located.
>
>   This must be something people do, right? Currently I hard code paths
> and force the installation to be where I want it, but this seems really
> sub-optimal, doesn't work for having test environments, etc.
>   I've been considering parsing $0 at the top of the script, is that
> what other people do?
>

All I can say about this is ... right.  You need to put the path where
you install stuff into @INC (via PERL5LIB).  See local::lib, for
example.  Module::Build (etc.) isn't going to edit your file to
hard-code the install path... I guess you could do that, but I've never
seen anyone do that.

Perhaps you are worrying a problem that doesn't exists?

Regards,
Jonathan Rockway

-- 
print just => another => perl => hacker => if $,=$"


Re: Application Building

2008-04-25 Thread Austin Schutz
On Fri, Apr 25, 2008 at 11:09:32PM +0300, Burak Gürsoy wrote:
> I think you need PAR

Maybe, but this seems a bit like killing an ant with a nuclear bomb.
It means the app will have to suck everything in memory at compile time.
It will also need to be rewritten to use special PAR methods to access data,
and since data is no longer in files as expected they will have to be copied
out by the user if one wanted to access them via external tools. It also may
make the finished package non-cross-platform. Etc. etc.. It's a solution,
just not a very good one.

Because the "fix_shebang" Module::Build (or the equivalent EU::MM
"fixin") method exists and alters perl scripts to be executable, someone
obviously thought that it should be possible to bundle apps with modules.

It should be completely simple for a brain dead newbie to be able to
write a simple application and just have it work and be distributable without
a bunch of complexity or fooling around. It should be just as easy as
distributing a module. 

..shouldn't it?

Austin

> 
> -Original Message-
> From: Austin Schutz [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 25, 2008 10:43 PM
> To: module-authors@perl.org
> Subject: Application Building
> 
>   Ok, so here's what must be a question with a really simple answer:
> how do I write a perl app?
> 
>   For example: I want to display a jpeg.
> 
> 
> MyApp/script/display.pl:
> 
> #!/path/to/perl
> use Myapp::Display;
> Myapp::Diplay->new()->display('example.jpg');
> __END__
> 
> MyApp/lib/Myapp/Display.pm
>   ...
> 
> MyApp/share/example.jpg
>   ...
> 
> MyApp/Build.PL:
> my $build = new Module::Build (
>script_files => [ 'script/display.pl' ],
>jpeg_files => { 'share/example.jpg' => 'share/example.jpg' }
> );
> $build->add_build_element('jpeg');
> $build->create_build_script;
> 
>
> 
>   Ok, so now I do:
> 
> /path/to/perl ./Build.PL install_base=$HOME/MyApp
> ./Build install
> 
> ...
> ...
> 
> 
>   If I put #!perl at the top of display.pl it will have a path to perl
> (though not the one I specified), but it won't have "use lib
> $HOME/MyApp/lib"
> at the top of the script, so it can't run.
>   Furthermore, there's no way for the script to know what was used
> for install_base, so there's no way for the script to know where the data
> file is located.
> 
>   This must be something people do, right? Currently I hard code paths
> and force the installation to be where I want it, but this seems really
> sub-optimal, doesn't work for having test environments, etc.
>   I've been considering parsing $0 at the top of the script, is that
> what other people do?
> 
>   Austin
> 
> 
> 
> !DSPAM:48123a8b186984550419146!


RE: Application Building

2008-04-25 Thread Burak Gürsoy
I think you need PAR

-Original Message-
From: Austin Schutz [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 25, 2008 10:43 PM
To: module-authors@perl.org
Subject: Application Building

Ok, so here's what must be a question with a really simple answer:
how do I write a perl app?

For example: I want to display a jpeg.


MyApp/script/display.pl:

#!/path/to/perl
use Myapp::Display;
Myapp::Diplay->new()->display('example.jpg');
__END__

MyApp/lib/Myapp/Display.pm
  ...

MyApp/share/example.jpg
  ...

MyApp/Build.PL:
my $build = new Module::Build (
   script_files => [ 'script/display.pl' ],
   jpeg_files => { 'share/example.jpg' => 'share/example.jpg' }
);
$build->add_build_element('jpeg');
$build->create_build_script;

   

Ok, so now I do:

/path/to/perl ./Build.PL install_base=$HOME/MyApp
./Build install

...
...


If I put #!perl at the top of display.pl it will have a path to perl
(though not the one I specified), but it won't have "use lib
$HOME/MyApp/lib"
at the top of the script, so it can't run.
Furthermore, there's no way for the script to know what was used
for install_base, so there's no way for the script to know where the data
file is located.

This must be something people do, right? Currently I hard code paths
and force the installation to be where I want it, but this seems really
sub-optimal, doesn't work for having test environments, etc.
I've been considering parsing $0 at the top of the script, is that
what other people do?

Austin




Application Building

2008-04-25 Thread Austin Schutz
Ok, so here's what must be a question with a really simple answer:
how do I write a perl app?

For example: I want to display a jpeg.


MyApp/script/display.pl:

#!/path/to/perl
use Myapp::Display;
Myapp::Diplay->new()->display('example.jpg');
__END__

MyApp/lib/Myapp/Display.pm
  ...

MyApp/share/example.jpg
  ...

MyApp/Build.PL:
my $build = new Module::Build (
   script_files => [ 'script/display.pl' ],
   jpeg_files => { 'share/example.jpg' => 'share/example.jpg' }
);
$build->add_build_element('jpeg');
$build->create_build_script;

   

Ok, so now I do:

/path/to/perl ./Build.PL install_base=$HOME/MyApp
./Build install

...
...


If I put #!perl at the top of display.pl it will have a path to perl
(though not the one I specified), but it won't have "use lib $HOME/MyApp/lib"
at the top of the script, so it can't run.
Furthermore, there's no way for the script to know what was used
for install_base, so there's no way for the script to know where the data
file is located.

This must be something people do, right? Currently I hard code paths
and force the installation to be where I want it, but this seems really
sub-optimal, doesn't work for having test environments, etc.
I've been considering parsing $0 at the top of the script, is that
what other people do?

Austin


Re: shipping extra files in a dist?

2008-04-25 Thread Aristotle Pagaltzis
* Jerome Quelin <[EMAIL PROTECTED]> [2008-04-25 09:40]:
> i'm writing a tk app that i'm shipping as a cpan dist. this app
> needs some extra resource files (icons, etc) i'd like to know
> what's the best method to ship extra data files in a dist.

Do they need to be physical files or do you just need the data to
tag along somewhere? If you just need the data the, you could
have a helper script that takes the files in the source tree and
sticks them at the bottom of your main module after __DATA__, or
in a My::App::Data module after __DATA__, or as string constants,
possibly uuencoded (cf. `perldoc pack`), etc.

Regards,
-- 
Aristotle Pagaltzis // 


Re: shipping extra files in a dist?

2008-04-25 Thread Jonathan Rockway
* On Fri, Apr 25 2008, Sébastien Aperghis-Tramoni wrote:
> Jerome Quelin wrote:
>
>> hi there,
>>
>> i'm writing a tk app that i'm shipping as a cpan dist. this app needs
>> some extra resource files (icons, etc) i'd like to know what's the best
>> method to ship extra data files in a dist.
>>
>> where to put them in the dist tar file:
>>  - create a data subdir under lib/Foo/Bar (assuming it's dist Foo::Bar).
>>in that case, do they get installed automatically, even if not pm
>>files?
>>  - create a data subdir at the top level, and use sthg like this in
>>Makefile.PL:
>> PM => {
>> 'data/foo.data'  => '$(INST_LIB)/Foo/Bar/foo.data',
>> ...
>> },
>>  - anything else?
>
> You can also define a MY::postamble() for this task:
>   » http://use.perl.org/~Maddingue/journal/34682
>
> Of course, Michael Schwern doesn't like such extensions for obvious
> reasons ;-)

There is also File::ShareDir which completely automates both installing
extra files and then finding them once installed.

(manually scanning @INC)--

Regards,
Jonathan Rockway

-- 
print just => another => perl => hacker => if $,=$"


Re: shipping extra files in a dist?

2008-04-25 Thread Ricardo SIGNES
* Jerome Quelin <[EMAIL PROTECTED]> [2008-04-25T03:36:25]
> i'm writing a tk app that i'm shipping as a cpan dist. this app needs
> some extra resource files (icons, etc) i'd like to know what's the best
> method to ship extra data files in a dist.

For this, I have sometimes used Module::Install::ShareDir.

-- 
rjbs


Re: shipping extra files in a dist?

2008-04-25 Thread Sébastien Aperghis-Tramoni
Jerome Quelin wrote:

> hi there,
>
> i'm writing a tk app that i'm shipping as a cpan dist. this app needs
> some extra resource files (icons, etc) i'd like to know what's the best
> method to ship extra data files in a dist.
>
> where to put them in the dist tar file:
>  - create a data subdir under lib/Foo/Bar (assuming it's dist Foo::Bar).
>in that case, do they get installed automatically, even if not pm
>files?
>  - create a data subdir at the top level, and use sthg like this in
>Makefile.PL:
> PM => {
> 'data/foo.data'  => '$(INST_LIB)/Foo/Bar/foo.data',
> ...
> },
>  - anything else?

You can also define a MY::postamble() for this task:
  » http://use.perl.org/~Maddingue/journal/34682

Of course, Michael Schwern doesn't like such extensions for obvious
reasons ;-)


-- 
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.


shipping extra files in a dist?

2008-04-25 Thread Jerome Quelin
hi there,

i'm writing a tk app that i'm shipping as a cpan dist. this app needs
some extra resource files (icons, etc) i'd like to know what's the best
method to ship extra data files in a dist.

where to put them in the dist tar file:
 - create a data subdir under lib/Foo/Bar (assuming it's dist Foo::Bar).
   in that case, do they get installed automatically, even if not pm
   files?
 - create a data subdir at the top level, and use sthg like this in
   Makefile.PL:
PM => {
'data/foo.data'  => '$(INST_LIB)/Foo/Bar/foo.data',
...
},
 - anything else?


thanks for your help,
jérôme 
-- 
[EMAIL PROTECTED]