It is perfectly possible to have packages.el put byte-compiled code into versioned subdirectories of the elpa package. This gives a structure like this:
┌ elpa
└┬ the-package-date.time
├─ the-package.el
├┬ 23.4
│└─ the-package.elc
├┬ 26.3
│└─ the-package.elc
└┬ 27.1
└─ the-package.elc
The load path is constructed in such a fashion, that the versioned directory appears before the source directory, e.g.:
'(
"/home/../.emacs.d/elpa/the-package-date.time/27.1"
"/home/../.emacs.d/elpa/the-package-date.time"
;; ...
)
To accomplish all of this, I have just written the package package-compat, which uses mostly adviced functions to provide that feature for Emacs 23 to Emacs 27.
The package mechanism is just used for distribution in this case, since the code must be loaded before any packages are activated and/or installed.
Either add "https://almost-un.org/selpa/packages"
to the variable package-archives
(add-to-list 'package-archives ("almost-un.org" . "https://almost-un.org/selpa/packages/") t)
and download the package with (package-install 'package-compat)
or download the tar(1) archive from the above page.
Then follow the instructions in any of the Emacs lisp files.
package-user-dir
and few other dirs and files based on emacs version. I can write a detailed answer when I am at a computer.init.el
and all those packages are auto-installed on emacs startup (if not already installed). You can even use the:ensure
keyword ofuse-package
to auto-install packages.