emacs-eldev / eldev

Elisp development tool
https://emacs-eldev.github.io/eldev/
GNU General Public License v3.0
226 stars 17 forks source link

Fetching dependencies from git #91

Open danlamanna opened 1 year ago

danlamanna commented 1 year ago

I have a fairly simple project that I would like to set up that requires a dependency that isn't hosted on a package manager. It seems this is becoming more common as people use straight and package-vc-install to install directly. Is it possible to declare such a dependency in eldev given that it's not on a package manager or on a local path?

doublep commented 1 year ago

No, it's currently not possible, but I long have thought about adding a plugin (i.e. optional extension) to Eldev that would do just this, probably using straight. If you could specify in more details what you'd need, I could have a look and maybe implement this in 1.5, the next version.

danlamanna commented 1 year ago

I'd like the functionality and bootstrapping that's available to eldev-use-local-dependency but with an external git repo that can be pulled from a host. Whether it uses the spec format from package-vc.el or straight.el doesn't make a big difference to me.

doublep commented 1 year ago

A problem here is that I have never used such functionality. I basically understand what you need and why, and I see how it would be a useful addition to Eldev too. But to design a good and usable interface I'd rather first see some real-world examples. If possible (i.e. not a private project), please provide a link to the outer project and the dependency. If not, at least show some code how you would use it, especially how you autofetch it from Git it in your normal Emacs — I assume you already do that.

suhail-singh commented 7 months ago

... especially how you autofetch it from Git it in your normal Emacs

FWIW, for the package doctest this is what my init.el configuration looks like in Emacs 29.1:

(use-package doctest :ensure nil
  :vc (doctest :url "https://github.com/ag91/doctest.git"
               :branch "master"
               :rev :newest))

The :ensure nil prevents use-package from trying to fetch it from the package-archives.

doublep commented 7 months ago

Hm, I just looked at the docstring of use-package and it doesn't mention :vc, at least in the version I have (2.4.5). Is it new? Is it built-in in use-package, or does it need something else?

suhail-singh commented 7 months ago

My bad! I'm using a not-yet-available-via-upstream-use-package extension called vc-use-package. Earlier in my init.el I have:

(unless (package-installed-p 'vc-use-package)
  (package-vc-install "https://github.com/slotThe/vc-use-package" :newest))

Of course, instead of first installing vc-use-package and then using that extension via the :vc keyword in use-package, you may want to directly use package-vc-install to install.

doublep commented 7 months ago

I see. So, basically, if Eldev was to support this, in project's file Eldev you would somehow specify where (and maybe how) to get certain dependencies. Something like:

(eldev-fetch-package-from 'abc                             ; dependency package name
                          "https://github.com/abc.el/abc"  ; the URL
                          ; possible additional options, e.g. :fetcher 'git
                          )

And then when it needs to install dependency X, it first checks if it has a URL for it. If it does, fetch (via Git or whatever) from that URL, else fall back to the usual PA lookup. (Internally this could be implemented via some existing tool or not, don't know yet.)

Is that the desired mechanism? This means you'd have to enumerate all dependencies not available in package archives (MELPA or something) together with their URL. On the other hand, there is probably no way to look up "canonical repository URL for Elisp package named X", so you do have to specify it manually...

suhail-singh commented 7 months ago

in project's file Eldev you would somehow specify where (and maybe how) to get certain dependencies

The simplest implementation I can imagine would be one where in the Eldev file one would note for each dependency the arguments that would be needed to install said dependency via package-vc-install. And then eldev would take care of invoking package-vc-install for each of those.

A more generalized approach would be one which parameterizes over the installation mechanism (e.g. package-vc-install vs straight.el etc). Having never used straight.el, I'm not sure what advantage having the option to use it would confer over being restricted to package-vc-install.

... you'd have to enumerate all dependencies not available in package archives (MELPA or something) together with their URL.

Yes, I believe that that's unavoidable (and that's okay).