mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
build-system/pyproject: Use copy-recursively instead of merge-dirs.
Using rename-file, the destination had to be empty otherwise it would error out. This has been fixed by the use of copy-recursively, really merging them. Changing this makes merge-directories mostly a duplicate of copy-recursively, thus fully switch to copy-recursively. * guix/build/pyproject-build-system.scm (install) <python-hashbang>: Remove it, used only once. <merge-directories>: Remove it, replace its calls by copy-recursively and delete-file-recursively. Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
parent
e927a071cd
commit
74a1e9d543
1 changed files with 15 additions and 36 deletions
|
@ -193,30 +193,6 @@ builder.build_wheel(sys.argv[3], config_settings=config_settings)"
|
||||||
;; Use Python’s zipfile to avoid extra dependency
|
;; Use Python’s zipfile to avoid extra dependency
|
||||||
(invoke "python" "-m" "zipfile" "-e" file site-dir))
|
(invoke "python" "-m" "zipfile" "-e" file site-dir))
|
||||||
|
|
||||||
(define python-hashbang
|
|
||||||
(string-append "#!" python "/bin/python"))
|
|
||||||
|
|
||||||
(define* (merge-directories source destination
|
|
||||||
#:optional (post-move #f))
|
|
||||||
"Move all files in SOURCE into DESTINATION, merging the two directories."
|
|
||||||
(format #t "Merging directory ~a into ~a~%" source destination)
|
|
||||||
(for-each (lambda (file)
|
|
||||||
(format #t "~a/~a -> ~a/~a~%"
|
|
||||||
source file destination file)
|
|
||||||
(mkdir-p destination)
|
|
||||||
;; Use 'copy-recursively' rather than 'rename-file' to guard
|
|
||||||
;; against the odd case where DESTINATION is a non-empty
|
|
||||||
;; directory, which may happen when using hybrid Python
|
|
||||||
;; build systems.
|
|
||||||
(copy-recursively (string-append source "/" file)
|
|
||||||
(string-append destination "/" file))
|
|
||||||
(delete-file-recursively (string-append source "/" file))
|
|
||||||
(when post-move
|
|
||||||
(post-move file)))
|
|
||||||
(scandir source
|
|
||||||
(negate (cut member <> '("." "..")))))
|
|
||||||
(rmdir source))
|
|
||||||
|
|
||||||
(define (expand-data-directory directory)
|
(define (expand-data-directory directory)
|
||||||
"Move files from all .data subdirectories to their respective\ndestinations."
|
"Move files from all .data subdirectories to their respective\ndestinations."
|
||||||
;; Python’s distutils.command.install defines this mapping from source to
|
;; Python’s distutils.command.install defines this mapping from source to
|
||||||
|
@ -224,29 +200,32 @@ builder.build_wheel(sys.argv[3], config_settings=config_settings)"
|
||||||
(let ((source (string-append directory "/scripts"))
|
(let ((source (string-append directory "/scripts"))
|
||||||
(destination (string-append out "/bin")))
|
(destination (string-append out "/bin")))
|
||||||
(when (file-exists? source)
|
(when (file-exists? source)
|
||||||
(merge-directories source destination
|
(copy-recursively source destination)
|
||||||
(lambda (f)
|
(delete-file-recursively source)
|
||||||
(let ((dest-path (string-append destination
|
(for-each
|
||||||
"/" f)))
|
(lambda (file)
|
||||||
(chmod dest-path #o755)
|
(chmod file #o755)
|
||||||
;; PEP 427 recommends that installers rewrite
|
;; PEP 427 recommends that installers rewrite
|
||||||
;; this odd shebang.
|
;; this odd shebang.
|
||||||
(substitute* dest-path
|
(substitute* file
|
||||||
(("#!python")
|
(("#!python")
|
||||||
python-hashbang)))))))
|
(string-append "#!" python "/bin/python"))))
|
||||||
|
(find-files destination))))
|
||||||
;; Data can be contained in arbitrary directory structures. Most
|
;; Data can be contained in arbitrary directory structures. Most
|
||||||
;; commonly it is used for share/.
|
;; commonly it is used for share/.
|
||||||
(let ((source (string-append directory "/data"))
|
(let ((source (string-append directory "/data"))
|
||||||
(destination out))
|
(destination out))
|
||||||
(when (file-exists? source)
|
(when (file-exists? source)
|
||||||
(merge-directories source destination)))
|
(copy-recursively source destination)
|
||||||
|
(delete-file-recursively source)))
|
||||||
(let* ((distribution (car (string-split (basename directory) #\-)))
|
(let* ((distribution (car (string-split (basename directory) #\-)))
|
||||||
(source (string-append directory "/headers"))
|
(source (string-append directory "/headers"))
|
||||||
(destination (string-append out "/include/python"
|
(destination (string-append out "/include/python"
|
||||||
(python-version python)
|
(python-version python)
|
||||||
"/" distribution)))
|
"/" distribution)))
|
||||||
(when (file-exists? source)
|
(when (file-exists? source)
|
||||||
(merge-directories source destination))))
|
(copy-recursively source destination)
|
||||||
|
(delete-file-recursively source))))
|
||||||
|
|
||||||
(define (list-directories base predicate)
|
(define (list-directories base predicate)
|
||||||
;; Cannot use find-files here, because it’s recursive.
|
;; Cannot use find-files here, because it’s recursive.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue