unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Efraim Flashner <efraim@flashner.co.il>
To: 44590@debbugs.gnu.org
Cc: Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#44590] [WIP PATCH CORE-UPDATES] build/python: Check for cythonized files.
Date: Thu, 12 Nov 2020 12:16:30 +0200	[thread overview]
Message-ID: <20201112101630.1302-1-efraim@flashner.co.il> (raw)

* guix/build/python-build-system.scm (ensure-no-cythonized-files): New procedure.
(%standard-phases): Add it.
---

This patch only checks if a file exists and suggests it may be
cythonized. It doesn't check the first line for the string "generated by
Cython" in that file or in any file. It also doesn't error when it
thinks it finds a file. It does provide a good visual queue that the
source needs more scrutiny before being added.

---
 guix/build/python-build-system.scm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 4a07496d22..bc34e22df8 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2019, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
+;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -262,6 +263,18 @@ installed with setuptools."
   (setenv "PYTHONHASHSEED" "0")
   #t)
 
+(define* (ensure-no-cythonized-files #:rest _)
+  "Check the source code for @code{.c} files which may have been pre-generated
+by Cython."
+  (for-each
+    (lambda (file)
+      (let ((generated-file
+              (string-append (string-drop-right file 3) "c")))
+        (when (file-exists? generated-file)
+          (warning (G_ "Possible Cythonized file found: ~a~%") generated-file))))
+    (find-files "." "\\.pyx$"))
+  #t)
+
 (define %standard-phases
   ;; The build phase only builds C extensions and copies the Python sources,
   ;; while the install phase copies then byte-compiles the sources to the
@@ -271,6 +284,8 @@ installed with setuptools."
     (add-after 'unpack 'ensure-no-mtimes-pre-1980 ensure-no-mtimes-pre-1980)
     (add-after 'ensure-no-mtimes-pre-1980 'enable-bytecode-determinism
       enable-bytecode-determinism)
+    (add-after 'enable-bytecode-determinism 'ensure-no-cythonized-files
+      ensure-no-cythonized-files)
     (delete 'bootstrap)
     (delete 'configure)                 ;not needed
     (replace 'build build)
-- 
2.29.2





             reply	other threads:[~2020-11-12 10:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 10:16 Efraim Flashner [this message]
2020-12-09  7:28 ` bug#44590: build/python: Check for cythonized files Efraim Flashner
2020-12-13 16:53 ` [bug#44590] [WIP PATCH CORE-UPDATES] " Simon South
2020-12-13 19:42   ` Efraim Flashner
2020-12-13 20:23   ` Efraim Flashner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201112101630.1302-1-efraim@flashner.co.il \
    --to=efraim@flashner.co.il \
    --cc=44590@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).