Skip to content

Commit

Permalink
ISSUE-52 (specify python executable) (#53)
Browse files Browse the repository at this point in the history
* Ability to specify python-executable

* default to "python3"
  • Loading branch information
jjtolton authored and cnuernber committed Jan 21, 2020
1 parent 216adaa commit c17c7a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/libpython_clj/python.clj
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@
[& {:keys [program-name
library-path
python-home
no-io-redirect?]}]
no-io-redirect?
python-executable]}]
(when-not @pyinterp/main-interpreter*
(pyinterp/initialize! :program-name program-name
:library-path library-path
:python-home python-home)
:python-home python-home
:python-executable python-executable)
;;setup bridge mechansim and io redirection
(pyinterop/register-bridge-type!)
(when-not no-io-redirect?
Expand Down
42 changes: 23 additions & 19 deletions src/libpython_clj/python/interpreter.clj
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,32 @@ print(json.dumps(


(defn detect-startup-info
[{:keys [library-path python-home]}]
(let [executable "python3"
system-info (python-system-info executable)
python-home (cond
python-home
python-home
(seq (System/getenv "PYTHONHOME"))
(System/getenv "PYTHONHOME")
:else
(:prefix system-info))
[{:keys [library-path python-home python-executable]}]
(log-info
(str "Detecting startup-info for Python executable: "
python-executable))
(let [executable (or python-executable "python3")
system-info (python-system-info executable)
python-home (cond
python-home
python-home
(seq (System/getenv "PYTHONHOME"))
(System/getenv "PYTHONHOME")
:else
(:prefix system-info))
java-library-path-addendum (when python-home
(-> (Paths/get python-home
(into-array String ["lib"]))
(.toString)))
[ver-maj ver-med _ver-min] (:version system-info)
lib-version (format "%s.%s" ver-maj ver-med)
libname (or library-path
(when (seq lib-version)
(str "python" lib-version "m")))
lib-version (format "%s.%s" ver-maj ver-med)
libname (or library-path
(when (seq lib-version)
(str "python" lib-version "m")))
retval
{:python-home python-home
:lib-version lib-version
:libname libname
{:python-home python-home
:lib-version lib-version
:libname libname
:java-library-path-addendum java-library-path-addendum}]
(log/infof "Startup info detected: %s" retval)
retval))
Expand Down Expand Up @@ -401,10 +404,11 @@ print(json.dumps(

(defn initialize!
[& {:keys [program-name
library-path]
library-path
python-executable]
:as options}]
(when-not (main-interpreter)
(log-info "Executing python initialize!")
(log-info (str "Executing python initialize with options:" options) )
(let [{:keys [python-home libname java-library-path-addendum] :as startup-info}
(detect-startup-info options)
library-names (cond
Expand Down

0 comments on commit c17c7a0

Please sign in to comment.