emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: package.el dependencies


From: Thierry Volpiatto
Subject: Re: package.el dependencies
Date: Mon, 02 Feb 2015 16:19:24 +0100

Artur Malabarba <address@hidden> writes:

>>> We have now duplicates with package--get-deps:
>>>
>>> (package--get-deps 'jedi)
>>> =>(epc auto-complete python-environment epc auto-complete
>>> python-environment
>>> concurrent ctable concurrent ctable deferred deferred
>>> popup popup deferred deferred)
>>>
>>> As a workaround, you can use delete-dups, but this need to be
>>> implemented differently IMO.
>>
>> Maybe like this:
>>
>> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
>> index 9a29d63..2157174 100644
>> --- a/lisp/emacs-lisp/package.el
>> +++ b/lisp/emacs-lisp/package.el
>> @@ -1428,9 +1428,8 @@ The file can either be a tar file or an Emacs Lisp 
>> file."
>>                                 when (assq name package-alist)
>>                                 collect name))
>>           (indirect-deps (unless (eq only 'direct)
>> -                          (apply #'append
>> -                            direct-deps
>
> Yes, I made a mistake by adding the `direct-deps' here. I'll remove it.
>
>> -                            (mapcar #'package--get-deps direct-deps)))))
>> +                          (cl-loop for p in direct-deps
>> +                                append (package--get-deps p 'direct)))))
>>      (cl-case only
>>        (direct   direct-deps)
>>        (separate (list direct-deps indirect-deps))
>>
>> (package--get-deps 'jedi)
>> => (epc auto-complete python-environment concurrent ctable popup deferred)
>
> It may have solved this particular example, but if two direct
> dependencies share the same (indirect) dependency then this will still
> lead to duplicates. We could try writting an efficient way of avoiding
> this duplicates, but I'm fine with just using `delete-dups'.

Yes I think using delete-dups is ok for the extras duplicates in this
case, but see below to avoid most of the duplicates.
So it would be:

(cl-loop for p in direct-deps
         append (package--get-deps p 'direct) into deps
         finally return (delete-dups deps))

> And one more thing. Why did you use `(package--get-deps p 'direct)' in
> this snippet? Passing the `direct' argument will cause it to only
> return 2nd level dependencies at most (direct dependencies of the
> direct dependencies).

Don't think so, see below.

> I think it should be just `(package--get-deps p)', shouldn't it?

No, this avoid duplicates and it will in turn recurse in the direct
dependency of the dependency and so on, if you don't specify 'direct you
will have immediately duplicates.

> This way it'll keep searching untill the bottom of the dependency
> tree.

It will with the recursion and the 'direct flag.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]