Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Makefile.PL Question

by baxy77bax (Deacon)
on Sep 03, 2015 at 22:29 UTC ( [id://1140936]=perlquestion: print w/replies, xml ) Need Help??

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

hi

I was wondering how to change the location where my moduls are when installing them. so far i had my source tree structured like this:

Project -+ |- lib -+ | | -Modul.pm |- t -+ | |- test |-Makefile.PL
now what I would like is to change the source tree to
Project -+ |-src-+ | |- lib -+ | | | -Modul.pm | |- apps -+ | |- test |-Makefile.PL
How to specify this change in my Makefile.pl file. because if i leave it as is no installation is possible.

baxy

Replies are listed 'Best First'.
Re: Makefile.PL Question
by stevieb (Canon) on Sep 03, 2015 at 23:06 UTC

    Update: My solution here is not cross-platform. See AnonyMonk's post Re^2: Makefile.PL Question for details as to why.

    # original post

    This might be very far off, so I'll let other Monks intervene if this is a bad idea, but I just tried adding symlink('apps', 't'); to the top of a Makefile.PL of one of my modules, and things seemed to go ok:

    $ cat Makefile.PL # Note: this file was auto-generated by Module::Build::Compat version +0.4214 require 5.006; use ExtUtils::MakeMaker; symlink('apps', 't'); # <-- *** I added this line *** WriteMakefile ( 'PL_FILES' => {}, 'EXE_FILES' => [], 'NAME' => 'Devel::Examine::Subs', 'INSTALLDIRS' => 'site', 'VERSION_FROM' => 'lib/Devel/Examine/Subs.pm', 'PREREQ_PM' => { 'File::Find' => 0, 'Data::Dumper' => 0, 'Tie::File' => 0, 'Carp' => 0, 'Test::Trap' => 0, 'Test::More' => 0, 'PPI' => 0 } ) ;

    Output:

    steve@spek ~/devel $ hg clone https://spek@bitbucket.org/spek/devel-ex +amine-subs ... steve@spek ~/devel $ cd devel-examine-subs/ steve@spek ~/devel/devel-examine-subs $ mv t apps steve@spek ~/devel/devel-examine-subs $ vi Makefile.PL # added the said symlink code here steve@spek ~/devel/devel-examine-subs $ perl Makefile.PL Checking if your kit is complete... Looks good Generating a Unix-style Makefile Writing Makefile for Devel::Examine::Subs Writing MYMETA.yml and MYMETA.json # make test steve@spek ~/devel/devel-examine-subs $ make && make test cp lib/Devel/Examine/Subs/Preprocessor.pm blib/lib/Devel/Examine/Subs/ +Preprocessor.pm cp lib/Devel/Examine/Subs/Engine.pm blib/lib/Devel/Examine/Subs/Engine +.pm cp lib/Devel/Examine/Subs/Sub.pm blib/lib/Devel/Examine/Subs/Sub.pm cp lib/Devel/Examine/Subs.pm blib/lib/Devel/Examine/Subs.pm cp lib/Devel/Examine/Subs/Prefilter.pm blib/lib/Devel/Examine/Subs/Pre +filter.pm Manifying 4 pod documents PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::H +arness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/l +ib', 'blib/arch')" t/*.t t/00-load.t ................................ 1/20 # Testing Devel::Exa +mine::Subs 1.28, Perl 5.022000, /usr/bin/perl t/00-load.t ................................ ok t/01-internal.t ............................ ok t/02-has.t ................................. 1/26 ^Cmake: *** [test_dy +namic] Interrupt # seems to work

    Is that what you were after?

    -stevieb

      This might be very far off, so I'll let other Monks intervene if this is a bad idea, but I just tried adding symlink...

      See perlport#symlink

        Thanks... I've read the info that you've provided, and point taken. It's not often I have to think cross-platform.

Re: Makefile.PL Question
by Anonymous Monk on Sep 03, 2015 at 23:59 UTC
Re: Makefile.PL Question
by baxy77bax (Deacon) on Sep 04, 2015 at 09:26 UTC
    I appologize for being so cryptic. It is obvoius there was not enoug information in my post. so allow my to start from he top. my Makefile.PL looks like this :
    use ExtUtils::MakeMaker; WriteMakefile( NAME => 'LC::Mod', VERSION_FROM => 'src/lib/LC/Mod.pm', dist => { 'COMPRESS' => 'gzip' }, PREREQ_PM => { # Require Getopt::Long at least 2.42 "Getopt::Long" => '2.42', # Require any version of File::Slurp "File::Slurp" => 0, } );
    if my source tree looks like the first case illustrated in the first figure above, when I execute :
    perl Makefile.PL
    make
    make test
    sudo make install
    everything is installed properly into my
    /usr/local/lib/perl/5.14.2/auto/LC/Mod/...
    directory. but if i set my source tree as in the second figure instalation does not copy my *.pm files into its required folder thus when i execute my application which uses this module i get a classic
    Can't locate LC/Mod.pm in @INC (@INC contains: /etc/perl /usr/local/li +b/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/ +perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_per +l .) at t/LC.pl line 26.
    also if i do the smylinks i run into the same problem. What am I missing??

    baxy

      What am I missing??

      A good reason to use "src" instead of "lib"

      A good reason you're avoiding PMLIBDIRS or PM option?

      Seriously, do you have me on ignore? Allergic to manuals documented solutions?

      :P

      symlink or copying files yourself misses the point of having a toolkit like MakeMaker with conventions

      A try

      Gee, flaunting convention isn't the smartest idea, I end up with SAUCE in the module tree

      Luckily i've read PMLIBDIRS docs and I know what to do, append to Makefile.PL and I get

      convention is convention for a reason, its convenient:D

        I am so sorry.. i have no idea how a mannaged to miss your post.

        "A good reason to use "src" instead of "lib" " ,

        The reason is consistency due to general project requirenmants. so ...

        Thnx ++

      Update: Darn it, I don't think this will work either, because File::Copy::Recursive is not in corelist, and I haven't found anything else in core that can copy/move directories (yet). I'd still like to know if this fixes your issue though, just to satisfy my own curiosity. End update

      I'm only assuming that these issues are related to the t/ directory not being in the right place, but I'm not sure. Instead of my earlier note about using symlink() which is not cross-platform, can you try to copy the directory? (tested on nix and win):

      use ExtUtils::MakeMaker; use File::Copy::Recursive qw(dircopy); dircopy('apps', 't'); WriteMakefile ( 'PL_FILES' => {}, 'EXE_FILES' => [], 'NAME' => 'Devel::Examine::Subs', 'INSTALLDIRS' => 'site', ...

      Does that help?

        Hi stevieb, you can move (rename) directories with File::Copy:

        #!/usr/bin/perl use strict; use warnings; use File::Copy 'mv'; mkdir( 'Project/src' ) or die $!; mv('Project/lib', 'Project/src/lib' ) or die $!; mv('Project/t', 'Project/src/apps' ) or die $!; __END__
        $ ls -lR Project total 0 -rw-r--r-- 1 nick staff 0 Sep 4 09:20 Makefile.PL drwxr-xr-x 3 nick staff 102 Sep 4 09:21 lib drwxr-xr-x 3 nick staff 102 Sep 4 09:21 t Project/lib: total 0 -rw-r--r-- 1 nick staff 0 Sep 4 09:21 Modul.pm Project/t: total 0 -rw-r--r-- 1 nick staff 0 Sep 4 09:21 test $
        $ perl 1141027.pl $
        $ ls -lR Project total 0 -rw-r--r-- 1 nick staff 0 Sep 4 09:20 Makefile.PL drwxr-xr-x 4 nick staff 136 Sep 4 09:26 src Project/src: total 0 drwxr-xr-x 3 nick staff 102 Sep 4 09:21 apps drwxr-xr-x 3 nick staff 102 Sep 4 09:21 lib Project/src/apps: total 0 -rw-r--r-- 1 nick staff 0 Sep 4 09:21 test Project/src/lib: total 0 -rw-r--r-- 1 nick staff 0 Sep 4 09:21 Modul.pm
        The way forward always starts with a minimal test.

      Does the message about missing LC::Mod actually appear duirng "make test"? My guess is so because "t/LC.pl" is mentioned. But that could/should not be if you had replaced "t" with "src/apps"?.

        Ok, perl runs tests in default, implicit "t" directory. Apparently that can be changed by setting TESTS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found