emacs-devel
[Top][All Lists]
Advanced

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

Re: Obtaining the version of an installed package


From: Philip Kaludercic
Subject: Re: Obtaining the version of an installed package
Date: Mon, 09 Aug 2021 15:35:32 +0000

"Bozhidar Batsov" <bozhidar@batsov.dev> writes:

> I guess that could work, although from what I gathered it operates
> only on the current package. I was hoping to find something like an
> API like `(package-get-version 'package-name)`.

Extracting the code from package-get-version, I would get something
like

        (require 'find-func)
        (require 'lisp-mnt)

        (defun get-library-version (library)
          "Return a version string for LIBRARY."
          (with-temp-buffer
            (insert-file-contents (find-library-name library))
            (or (lm-header "package-version")
                        (lm-header "version"))))

and it seems to work

    (get-library-version "auctex") ;=> "13.0.12"

> On Mon, Aug 9, 2021, at 3:58 PM, Stefan Monnier wrote:
>> > I'm wondering if there's an API for obtaining metadata about installed
>> > packages, in particular the version information.
>> > For years I was using this function from pkg-info
>> > https://github.com/emacsorphanage/pkg-info/blob/master/pkg-info.el#L65, but
>> > I'm wondering if it'd be easy to strip one dependency from my packages. 
>> 
>> Are you looking for `package-get-version`?
>> 
>> 
>>         Stefan
>> 
>> 
>> 

-- 
        Philip Kaludercic



reply via email to

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