From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: package-vc support for :files keyword Date: Wed, 20 Sep 2023 07:32:31 +0000 Message-ID: <87y1h18flc.fsf@posteo.net> References: <87ttrshrib.fsf@hyperspace> <871qev6e53.fsf@posteo.net> <87r0mviltd.fsf@hyperspace> <871qevbhru.fsf@posteo.net> <87o7hzi82q.fsf@hyperspace> <87pm2ebldd.fsf@posteo.net> <87o7hyl01m.fsf@hyperspace> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2799"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Tony Zorman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 20 09:33:26 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qiri9-0000Sh-B0 for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Sep 2023 09:33:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qirhP-0006oL-Dh; Wed, 20 Sep 2023 03:32:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qirhO-0006nv-1F for emacs-devel@gnu.org; Wed, 20 Sep 2023 03:32:38 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qirhK-00049K-N9 for emacs-devel@gnu.org; Wed, 20 Sep 2023 03:32:37 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 77C49240029 for ; Wed, 20 Sep 2023 09:32:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1695195152; bh=CbocNiI3GH8IcFVOJq8YNoBIuiLLmJ+/B/MTNcp6SX4=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=Kd97UB8O6V6ZUF/+ylPYme5/U+jHoVbi+9yGlR0kSyCiw0UnBI2neLztprpzHOnab Sh8RmPT2ZYzr6ipEiMbO+ySVxPoTtqthpJUdtzeTxTcdR0lQjLTr6iu1/iIzBfHcdi k9rKH4YxgkaAM66jBTvWKVqMJZuFq56xkg8bV07x27bPjxOaYTYWRLmVqrwxTJ8o10 hRfNv1Ny26xjEYOPKYRJO9sBe/z2R+XPmkj27Z/qCYK+JTW3OlOp+zhAyH9MuQMBnL 9dnrFKcXQoC5jiq4PBzDvjOq2927wlbj7J4a8ZaJ/Cs1ts3VMIMPcRes+z32NQV0jg hzBmARRA/PfGg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rr9Gl756fz6v5k; Wed, 20 Sep 2023 09:32:31 +0200 (CEST) In-Reply-To: <87o7hyl01m.fsf@hyperspace> (Tony Zorman's message of "Tue, 19 Sep 2023 16:17:41 +0200") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310805 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Tony Zorman writes: > On Tue, Sep 19 2023 08:47, Philip Kaludercic wrote: >> Tony Zorman writes: >> >> [=E2=80=A6 42 lines elided =E2=80=A6] >> >>> This is not just for multiple packages in a single repository=E2=80=94a= t least >>> one has to somewhat broaden what "multiple packages" means. Some >>> packages include small shims for bigger projects, and inadvertently >>> require them as dependencies. The original issue[1] on the >>> vc-use-package repo mentions org-ql[2], more specifically its helm >>> integration in the form of helm-org-ql.el. Some people might not want to >>> pull down helm as a dependency just for one file that they are not going >>> to use anyways. >>> >>> I'm not sure how common of a situation this actually is, but at least >>> for the big completion frameworks=E2=80=94helm and ivy=E2=80=94it's not= totally unheard >>> of. >> >> Hmm, this is interesting example that I was not familiar with. As an >> alternative idea, do you think that using `:ignored-files' like >> elpa-admin.el could be useful? You could exclude all the files with >> "soft-dependencies", that wouldn't be scraped in `package-vc--unpack-1' >> when looking for dependency files. > > Overall, I think this would be the better (even best) approach, yes. Here is a sketch of how that could look like. Can you test it to see if it works: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index a8393cb7e75..07e660d9f33 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -213,7 +213,7 @@ package-vc--desc->spec name for PKG-DESC." (alist-get (setq name (or name (package-desc-name pkg-desc))) - (if (and (package-desc-archive pkg-desc) + (if (and pkg-desc (package-desc-archive pkg-desc) (not (alist-get name package-vc-selected-packages nil nil #'string=))) (alist-get (intern (package-desc-archive pkg-desc)) @@ -501,7 +501,8 @@ package-vc--unpack-1 autoloads, generating a package description file (used to identify a package as a VC package later on), building documentation and marking the package as installed." - (let (missing) + (let ((pkg-spec (package-vc--desc->spec pkg-desc)) + missing) ;; Remove any previous instance of PKG-DESC from `package-alist' (let ((pkgs (assq (package-desc-name pkg-desc) package-alist))) (when pkgs @@ -510,17 +511,27 @@ package-vc--unpack-1 ;; In case the package was installed directly from source, the ;; dependency list wasn't know beforehand, and they might have ;; to be installed explicitly. - (let ((deps '())) + (let ((ignored-files + (mapconcat + (lambda (ignore) + (wildcard-to-regexp + (if (string-match-p "\\`/" ignore) + (concat pkg-dir ignore) + (concat "*/" ignore)))) + (plist-get pkg-spec :ignored-files) + "\\|")) + (deps '())) (dolist (file (directory-files pkg-dir t "\\.el\\'" t)) - (with-temp-buffer - (insert-file-contents file) - (when-let* ((require-lines (lm-header-multiline "package-requires"))) - (thread-last - (mapconcat #'identity require-lines " ") - package-read-from-string - package--prepare-dependencies - (nconc deps) - (setq deps))))) + (unless (string-match-p ignored-files file) + (with-temp-buffer + (insert-file-contents file) + (when-let* ((require-lines (lm-header-multiline "package-requires"))) + (thread-last + (mapconcat #'identity require-lines " ") + package-read-from-string + package--prepare-dependencies + (nconc deps) + (setq deps)))))) (dolist (dep deps) (cl-callf version-to-list (cadr dep))) (setf missing (package-vc-install-dependencies (delete-dups deps))) @@ -529,8 +540,7 @@ package-vc--unpack-1 missing))) (let ((default-directory (file-name-as-directory pkg-dir)) - (pkg-file (expand-file-name (package--description-file pkg-dir) pkg-dir)) - (pkg-spec (package-vc--desc->spec pkg-desc))) + (pkg-file (expand-file-name (package--description-file pkg-dir) pkg-dir))) ;; Generate autoloads (let* ((name (package-desc-name pkg-desc)) (auto-name (format "%s-autoloads.el" name)) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > (I also consider executing external shell commands during build-time an > anti pattern, I just got the feeling that making package-vc support > `:ignored-files' wasn't on the table=E2=80=94glad to realise that I was w= rong!) Why did you think so? --=-=-=--