File tree Expand file tree Collapse file tree 1 file changed +27
-5
lines changed
src/libpython_clj2/python Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change 5757 (dorun (char-seq err-rdr)))))
5858
5959
60+ (defn- uv-installed? []
61+ (try
62+ (let [p (process/start " uv" " --version" )]
63+ ; ; We only need to know it starts; stop it quickly.
64+ (.destroy ^Process p)
65+ true )
66+ (catch java.io.IOException _
67+ false )
68+ (catch Throwable _
69+ false )))
70+
6071(defn sync-python-setup!
61- " Synchronize python venv at .venv with 'uv sync'."
72+ " Synchronize python venv at .venv with 'uv sync'.
73+ When 'uv' is not available on PATH, throws with guidance to install."
6274 []
6375 (println " Synchronize python venv at .venv with 'uv sync'. This might take a few minutes" )
76+ (when-not (uv-installed? )
77+ (println " The 'uv' tool was not found on your PATH." )
78+ (println " Install uv from https://github.com/astral-sh/uv, e.g.:" )
79+ (println " - curl -LsSf https://astral.sh/uv/install.sh | sh" )
80+ (println " - or: pipx install uv" )
81+ (throw (ex-info " The 'uv' tool is not installed or not on PATH." {:tool " uv" :stage :preflight })))
6482 (let [deps-edn
65- (->
66- (slurp " python.edn" )
67- edn/read-string)]
83+ (try
84+ (-> (slurp " python.edn" ) edn/read-string)
85+ (catch java.io.FileNotFoundException e
86+ (throw (ex-info " Missing python.edn. Copy python.edn.example to python.edn and set :python-version and :python-deps."
87+ {:file " python.edn" :stage :read-config } e))))]
6888 (write-pyproject-toml! deps-edn)
69- (start-and-print! [" uv" " sync" " --python" (-> deps-edn :python-version )])))
89+ (start-and-print! [" uv" " sync" " --python" (-> deps-edn :python-version )])
90+ (println " Python environment synchronized with uv." )
91+ true ))
7092
7193
7294
You can’t perform that action at this time.
0 commit comments