Skip to content

Commit

Permalink
[int] slightly rewrite config-darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
digikar99 committed May 9, 2024
1 parent a0e015b commit 97d84cc
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions src/config-darwin.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,47 @@
(:documentation "Configures macOS operating systems.")
(:use #:cl
#:cl-ppcre
#:py4cl2-cffi/config))
#:py4cl2-cffi/config)
(:import-from #:py4cl2-cffi/config
#:return-value-as-list))
(in-package #:py4cl2-cffi/config-darwin)

(defun python-system ()
"The path to the Python install or where the virtual environment originates."
(read-from-string
(with-output-to-string (stream)
(uiop:run-program "python3 -c \"
(values-list (return-value-as-list "python3 -c \"
import sys
print(f'(:base-exec-prefix \\\"{sys.base_exec_prefix}\\\"' +
f' :exec-prefix \\\"{sys.exec_prefix}\\\")')\""
:output stream)
stream)))
print(sys.base_exec_prefix)
print(sys.exec_prefix)")))

(defun configure ()
(let* ((ps (python-system))
(prefix (getf ps :base-exec-prefix))
(path (format nil "~A" prefix))
(search-path (getf ps :exec-prefix))
(python-version (ppcre:register-groups-bind (version)
("^.+\/(.+)?$" prefix :sharedp t)
version)))
(setq py4cl2-cffi/config:*python-ldflags*
(list (format nil "-L'~A' -L'lib/~A' -l'~A'"
(make-pathname :name search-path)
path
(format nil "python~A" python-version)))

py4cl2-cffi/config:*python-compile-command*
(concatenate
'string
"gcc ~A -c -Wall -Werror -fpic py4cl-utils.c && "
(format
nil
"gcc -L'~A/lib-dynload' -L'~A/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o -lpython~A"
path path python-version))

py4cl2-cffi/config:*python-numpy-compile-command*
(concatenate
'string
"gcc ~A -I'~A' -c -Wall -Werror -fpic py4cl-numpy-utils.c && "
(format
nil
"gcc -L'~A/lib-dynload' -L'~A/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-numpy-utils.dylib py4cl-numpy-utils.o -lpython~A"
path path python-version)))))
(multiple-value-bind (base-exec-prefix exec-prefix)
(python-system)
(let* ((python-version (ppcre:register-groups-bind (version)
("^.+\/(.+)?$" base-exec-prefix :sharedp t)
version)))
(setq py4cl2-cffi/config:*python-ldflags*
(list (format nil "-L'~A' -L'lib/~A' -l'~A'"
exec-prefix
base-exec-prefix
(format nil "python~A" python-version)))

py4cl2-cffi/config:*python-compile-command*
(concatenate
'string
"gcc ~A -c -Wall -Werror -fpic py4cl-utils.c && "
(format
nil
"gcc -L'~A/lib-dynload' -L'~A/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-utils.dylib py4cl-utils.o -lpython~A"
base-exec-prefix base-exec-prefix python-version))

py4cl2-cffi/config:*python-numpy-compile-command*
(concatenate
'string
"gcc ~A -I'~A' -c -Wall -Werror -fpic py4cl-numpy-utils.c && "
(format
nil
"gcc -L'~A/lib-dynload' -L'~A/lib' -framework CoreFoundation -dynamiclib -o libpy4cl-numpy-utils.dylib py4cl-numpy-utils.o -lpython~A"
base-exec-prefix base-exec-prefix python-version))))))



Expand Down

0 comments on commit 97d84cc

Please sign in to comment.