Skip to content

Commit 6b682af

Browse files
committed
cleaned up
1 parent 2747227 commit 6b682af

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed
File renamed without changes.

src/libpython_clj2/python.clj

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,8 @@ user> (py/py. np linspace 2 3 :num 10)
113113
(let [python-edn-opts (-> (try (slurp "python.edn")
114114
(catch java.io.FileNotFoundException _ "{}"))
115115
clojure.edn/read-string)
116-
_ (log/infof "Pre-initialize-fn %s" (some-> python-edn-opts :pre-initialize-fn))
117-
_ (def python-edn-opts python-edn-opts)
116+
_ (log/debugf "Pre-initialize-fn %s" (some-> python-edn-opts :pre-initialize-fn))
118117
_ (some-> python-edn-opts :pre-initialize-fn requiring-resolve (apply []))
119-
_ (some-> python-edn-opts :pre-initialize-fn)
120-
;_ ( (requiring-resolve 'libpython-clj2.python.uv/sync-python-setup))
121-
122-
;(require 'libpython-clj2.python.uv)
123-
124-
;(requiring-resolve )
125-
126-
;(-> 'libpython-clj2.python.uv/char-seq namespace symbol require)
127-
;(resolve 'libpython-clj2.python.uv/char-seq)
128118
options (merge python-edn-opts options)
129119
info (py-info/detect-startup-info options)
130120
_ (log/infof "Startup info %s" info)
@@ -832,15 +822,3 @@ user> c
832822
~@(for [s symbols] `(def ~s ~s))))
833823

834824

835-
(comment
836-
(require 'libpython-clj2.python)
837-
(require 'libpython-clj2.python.uv)
838-
839-
(libpython-clj2.python/initialize!)
840-
(libpython-clj2.python/run-simple-string "import sys; sys.path.append('.venv/Lib/site-packages')")
841-
(libpython-clj2.python/run-simple-string "import sys; print(sys.path)")
842-
(libpython-clj2.python/run-simple-string "import sys; print(sys.prefix)")
843-
(libpython-clj2.python/run-simple-string "import sys; print(sys.base_prefix)")
844-
(libpython-clj2.python/import-module "openai")
845-
(libpython-clj2.python/import-module "langextract")
846-
)

src/libpython_clj2/python/uv.clj

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
[clojure.edn :as edn]
44
[clojure.java.process :as process]
55
[clojure.string :as str]
6-
[cheshire.core :as json]))
6+
[cheshire.core :as json]
7+
[clojure.java.process :as proc]))
78

8-
(defn write-pyproject-toml! [deps-edn]
9+
(defn- write-pyproject-toml! [deps-edn]
910

1011
(let [python-deps
1112
(:python-deps deps-edn)
@@ -33,7 +34,7 @@
3334
(spit "pyproject.toml"
3435
(str/join "\n" py-project-lines))))
3536

36-
(defn char-seq
37+
(defn- char-seq
3738
[^java.io.Reader rdr]
3839
(let [chr (.read rdr)]
3940
(when (>= chr 0)
@@ -44,12 +45,8 @@
4445
(cons chr (lazy-seq (char-seq rdr)))))))
4546

4647

47-
(defn start-and-print! [process-args]
48-
(let [args
49-
(concat [{:env {"RENV_CONFIG_INSTALL_VERBOSE" "TRUE"}}]
50-
process-args)
51-
p
52-
(apply process/start args)]
48+
(defn- start-and-print! [process-args]
49+
(let [p(apply process/start process-args)]
5350

5451
(with-open [in-rdr (java.io.InputStreamReader. (.getInputStream p))
5552
err-rdr (java.io.InputStreamReader. (.getErrorStream p))]
@@ -60,7 +57,9 @@
6057
(dorun (char-seq err-rdr)))))
6158

6259

63-
(defn sync-python-setup! []
60+
(defn sync-python-setup!
61+
"Synchronize python venv at .venv with 'uv sync'."
62+
[]
6463
(println "Synchronize python venv at .venv with 'uv sync'. This might take a few minutes")
6564
(let [deps-edn
6665
(->

0 commit comments

Comments
 (0)