emacs-devel
[Top][All Lists]
Advanced

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

Re: package.el dependencies


From: Artur Malabarba
Subject: Re: package.el dependencies
Date: Mon, 2 Feb 2015 15:50:54 +0000

2015-02-02 15:33 GMT+00:00 Thierry Volpiatto <address@hidden>:
>
> Thierry Volpiatto <address@hidden> writes:
>
>>> 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).
>
> Consider following example using this definition of package--get-deps:
>
> --8<---------------cut here---------------start------------->8---
> (defun package--get-deps (pkg &optional only)
>   (let* ((pkg-desc (cadr (assq pkg package-alist)))
>          (direct-deps (cl-loop for p in (package-desc-reqs pkg-desc)
>                                for name = (car p)
>                                when (assq name package-alist)
>                                collect name))
>          (indirect-deps (unless (eq only 'direct)
>                           (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))
>       (indirect indirect-deps)
>       (t        (append direct-deps indirect-deps)))))
> --8<---------------cut here---------------end--------------->8---

I think the snippet you suggest lists 1st and 2nd order dependencies.
It does not, in general, list all dependencies without duplicates.

> Here the dependencies of the package "jedi":
> [...]
> As you can see all the dependencies are here and there is no duplicates.

In this particular case, yes, but that's just a coincidence. What the
function is actually doing, is to return 1st and 2nd order
dependencies.
I explain below:

1st order dependencies
> (package--get-deps 'jedi 'direct)
> =>(epc auto-complete python-environment)

2nd order dependencies
> (package--get-deps 'epc 'direct)
> =>(concurrent ctable)
> (package--get-deps 'auto-complete 'direct)
> =>(popup)
> (package--get-deps 'python-environment 'direct)
> =>(deferred)

3rd order dependencies:
> (package--get-deps 'concurrent 'direct)
> =>(deferred)
> (package--get-deps 'ctable 'direct)
> =>nil

Union of the 1st and 2nd order:
> (package--get-deps 'jedi)
> =>(epc auto-complete python-environment concurrent ctable popup deferred)

1. The only reason you don't get duplicates there, is because the
dependencies of the concurrent and ctable packages are not even being
looked at.

2. Similarly, the only reason you don't have omissions in the
resulting list, is because these two packages don't depend on anything
different from the other packages. If 'ctable or 'concurrent happened
to depend on X, then X would not show up on your returned list.



reply via email to

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