Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtUtils::Installed or ExtUtils::Packlist: add function for direct access of a distribution's packlist #13812

Closed
p5pRT opened this issue May 8, 2014 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented May 8, 2014

Migrated from rt.perl.org#121829 (status was 'open')

Searchable as RT121829$

@p5pRT
Copy link
Author

p5pRT commented May 8, 2014

From @eserte

It would be nice if either ExtUtils​::Installed or ExtUtils​::Packlist had a function for direct access of a packlist. Currently the only way is to use ExtUtils​::Packlist->new->packlist(...), but this may be very slow(*) on large perl installations, because apparently all directories and files are scanned. On the other hand ExtUtils​::Packlist has no functionality to translate a module name to a packlist path. So while using it would be much more efficient than the EU​::I solution, the user has to have knowledge about the internal structure of the perl lib directory.

(*) Once I timed 13 minutes for running ExtUtils​::Installed->new on a perl installation with a ~2.5GB site_perl directory.

@p5pRT
Copy link
Author

p5pRT commented May 8, 2014

From @Leont

On Thu, May 8, 2014 at 10​:06 PM, slaven@​rezic.de
<perlbug-followup@​perl.org>wrote​:

It would be nice if either ExtUtils​::Installed or ExtUtils​::Packlist had a
function for direct access of a packlist. Currently the only way is to use
ExtUtils​::Packlist->new->packlist(...), but this may be very slow(*) on
large perl installations, because apparently all directories and files are
scanned. On the other hand ExtUtils​::Packlist has no functionality to
translate a module name to a packlist path. So while using it would be much
more efficient than the EU​::I solution, the user has to have knowledge
about the internal structure of the perl lib directory.

(*) Once I timed 13 minutes for running ExtUtils​::Installed->new on a perl
installation with a ~2.5GB site_perl directory.

Yes, this behavior is annoying and unnecessary in most cases.

Leon

@p5pRT
Copy link
Author

p5pRT commented May 8, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 23, 2014

From @jkeenan

On Thu May 08 13​:06​:37 2014, slaven@​rezic.de wrote​:

It would be nice if either ExtUtils​::Installed or ExtUtils​::Packlist
had a function for direct access of a packlist.

Slaven, Leon,

Can you be a bit more specific about what you mean by "direct access of a packlist"?

What would that function or method do? Are you referring to a .packlist file or to something like this​:

#####
  'Test​::Script' => {
  'packlist' => bless( {
  '/home/jkeenan/perl5/man/man3/Test​::Script.3' => undef,
  '/home/jkeenan/perl5/lib/perl5/Test/Script.pm' => undef
  }, 'ExtUtils​::Packlist' ),
  'version' => '1.07',
  'packlist_valid' => 1,
  'packlist_file' => '/home/jkeenan/perl5/lib/perl5/x86_64-linux/auto/Test/Script/.packlist',
  'modfile' => 'Test/Script.pm',
  'version_from' => '/home/jkeenan/perl5/lib/perl5/Test/Script.pm',
  'module' => 'Test​::Script'
  },
#####

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Aug 23, 2014

From @eserte

Dana Pet 22. Kol 2014, 17​:56​:37, jkeenan reče​:

On Thu May 08 13​:06​:37 2014, slaven@​rezic.de wrote​:

It would be nice if either ExtUtils​::Installed or ExtUtils​::Packlist
had a function for direct access of a packlist.

Slaven, Leon,

Can you be a bit more specific about what you mean by "direct access
of a packlist"?

What would that function or method do? Are you referring to a
.packlist file or to something like this​:

#####
'Test​::Script' => {
'packlist' => bless( {
'/home/jkeenan/perl5/man/man3/Test​::Script.3' => undef,
'/home/jkeenan/perl5/lib/perl5/Test/Script.pm' => undef
}, 'ExtUtils​::Packlist' ),
'version' => '1.07',
'packlist_valid' => 1,
'packlist_file' => '/home/jkeenan/perl5/lib/perl5/x86_64-
linux/auto/Test/Script/.packlist',
'modfile' => 'Test/Script.pm',
'version_from' => '/home/jkeenan/perl5/lib/perl5/Test/Script.pm',
'module' => 'Test​::Script'
},
#####

Thank you very much.
Jim Keenan

Currently there are the following methods to get the packlist of a module​:

  use ExtUtils​::Installed; $packlist = ExtUtils​::Installed->new->packlist($module);

  use ExtUtils​::Installed; $packlist = ExtUtils​::Installed->packlist($module);

  use ExtUtils​::Packlist; $packlist = ExtUtils​::Packlist->new->packlist("/I/know/where/the/packlist/of/$module/is/located");

The first two may be slow and resource hungry. The third is fast, but one needs the knowledge where the packlist may be found.

I would suggest to add a new method find_packlist which could be used like this​:

  $packlist_path = ExtUtils​::Installed->find_packlist($module);
  $packlist = ExtUtils​::Packlist->new($packlist_path);

find_packlist could look like this (pseudo code)​:

  sub find_packlist {
  my(undef, $module) = @​_;
  (my $path = $module) =~ s{​::}{/}g;
  $path .= "/.packlist";
  for my $incdir (@​INC) {
  my $trypath = "$incdir/auto/$path";
  return $trypath if -e $trypath;
  }
  }

Once find_packlist is there it could be used to re-implement the class method variant of ExtUtils​::Installed​::packlist, so ExtUtils​::Installed->packlist won't construct the "default object" anymore, but fetch the packlist directly. As pseudo code​:

  sub packlist {
  my ($self, $module) = @​_;
  if (!ref $self) {
  my $packlist_path = $self->find_packlist($module);
  Carp​::croak("$module is not installed") if (!$packlist);
  return ExtUtils​::Packlist->new($packlist_path);
  } else {
  Carp​::croak("$module is not installed") if (! exists($self->{$module}));
  return($self->{$module}{packlist});
  }
  }

If needed, there could also be more efficient versions for the validate() and version() methods in ExtUtils​::Installed, too. The first one could also use find_packlist(), the second would use part of the logic of _make_entry().

@jkeenan
Copy link
Contributor

jkeenan commented Oct 29, 2023

@eserte, we should have noted back in 2014 that ExtUtils::Installed and ExtUtils::Packlist are maintained upstream on CPAN as part of the ExtUtils-Install distribution. Can you file an issue at its designated bug-tracker?

Closing this ticket with 'sendToCPAN' label.

@jkeenan jkeenan closed this as completed Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants