[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with local packages taking precedence over global and (an ap
From: |
Carnë Draug |
Subject: |
Re: problem with local packages taking precedence over global and (an apparent) solution |
Date: |
Mon, 21 May 2012 11:25:09 +0100 |
On 21 May 2012 10:28, Sergei Steshenko <address@hidden> wrote:
> Hello,
>
> this is regarding functionality of 'octave-3.6.1/scripts/pkg/pkg.m' file.
>
> After installing packages both locally and globally I've noticed that both
> global and local packages were listed by 'pkg list', and they were both
> listed as autoloaded.
>
> I did request autoloading in both cases, so it is not a problem, the problem
> is that both local and global - if I understand correctly, local packages
> should take precedence.
>
> Looking into 'octave-3.6.1/scripts/pkg/pkg.m' file contents I came to the
> conclusion (thanks to the comment) I came to the conclusion that the desired
> functionality is supposed to be implemented by line #1988..2004:
>
>
>
> 1972 function [out1, out2] = installed_packages (local_list, global_list)
> 1973 ## Get the list of installed packages.
> 1974 try
> 1975 local_packages = load (local_list).local_packages;
> 1976 catch
> 1977 local_packages = {};
> 1978 end_try_catch
> 1979 try
> 1980 global_packages = load (global_list).global_packages;
> 1981 catch
> 1982 global_packages = {};
> 1983 end_try_catch
> 1984 installed_pkgs_lst = {local_packages{:}, global_packages{:}};
> 1985
> 1986 ## Eliminate duplicates in the installed package list.
> 1987 ## Locally installed packages take precedence.
> 1988 dup = [];
> 1989 for i = 1:length (installed_pkgs_lst)
> 1990 if (find (dup, i))
> 1991 continue;
> 1992 endif
> 1993 for j = (i+1):length (installed_pkgs_lst)
> 1994 if (find (dup, j))
> 1995 continue;
> 1996 endif
> 1997 if (strcmp (installed_pkgs_lst{i}.name,
> installed_pkgs_lst{j}.name))
> 1998 dup = [dup, j];
> 1999 endif
> 2000 endfor
> 2001 endfor
> 2002 if (! isempty(dup))
> 2003 installed_pkgs_lst(dup) = [];
> 2004 endif
>
> .
>
> Alas, inserting diagnostic prints I verified that after the code is executed,
> the duplicates (i.e. local and global packages with the same name) are still
> there.
>
>
> I tried to understand the logic of the code, but failed. So I simply rewrote
> the piece of code, and it seems to work OK now. Here's how the code looks now:
Hi Sergei,
we have been trying to fix many things on the pkg system (one of them
being the code complexity). A few of the subfunctions have already
been removed or simplified and made into separate files in a private
directory. If you update your repository for the default branch, can
you try a fix for those? At the moment it is like this
http://hg.savannah.gnu.org/hgweb/octave/file/1e77f6078692/scripts/pkg
Thanks,
Carnë