@@ -66,7 +66,7 @@ defmodule Pythonx.Uv do
6666 Initializes the interpreter using Python and dependencies previously
6767 fetched by `fetch/3`.
6868 """
69- @ spec init ( String . t ( ) , boolean ( ) ) :: :ok
69+ @ spec init ( String . t ( ) , boolean ( ) ) :: Pythonx . python_config ( )
7070 def init ( pyproject_toml , priv? , opts \\ [ ] ) do
7171 opts = Keyword . validate! ( opts , uv_version: default_uv_version ( ) )
7272 project_dir = project_dir ( pyproject_toml , priv? , opts [ :uv_version ] )
@@ -95,59 +95,69 @@ defmodule Pythonx.Uv do
9595
9696 root_dir = Path . join ( python_install_dir ( priv? , opts [ :uv_version ] ) , versioned_dir_name )
9797
98- case :os . type ( ) do
99- { :win32 , _osname } ->
100- # Note that we want the version-specific DLL, rather than the
101- # "forwarder DLL" python3.dll, otherwise symbols cannot be
102- # found directly.
103- python_dl_path =
104- root_dir
105- |> Path . join ( "python3?*.dll" )
106- |> wildcard_one! ( )
107- |> make_windows_slashes ( )
108-
109- python_home_path = make_windows_slashes ( root_dir )
110-
111- python_executable_path =
112- project_dir
113- |> Path . join ( ".venv/Scripts/python.exe" )
114- |> make_windows_slashes ( )
115-
116- venv_packages_path =
117- project_dir
118- |> Path . join ( ".venv/Lib/site-packages" )
119- |> make_windows_slashes ( )
120-
121- Pythonx . init ( python_dl_path , python_home_path , python_executable_path ,
122- sys_paths: [ venv_packages_path ]
123- )
124-
125- { :unix , osname } ->
126- dl_extension =
127- case osname do
128- :darwin -> ".dylib"
129- :linux -> ".so"
130- end
131-
132- python_dl_path =
133- root_dir
134- |> Path . join ( "lib/libpython3.*" <> dl_extension )
135- |> wildcard_one! ( )
136- |> Path . expand ( )
137-
138- python_home_path = root_dir
139-
140- python_executable_path = Path . join ( project_dir , ".venv/bin/python" )
141-
142- venv_packages_path =
143- project_dir
144- |> Path . join ( ".venv/lib/python3*/site-packages" )
145- |> wildcard_one! ( )
146-
147- Pythonx . init ( python_dl_path , python_home_path , python_executable_path ,
148- sys_paths: [ venv_packages_path ]
149- )
150- end
98+ python_config =
99+ case :os . type ( ) do
100+ { :win32 , _osname } ->
101+ # Note that we want the version-specific DLL, rather than the
102+ # "forwarder DLL" python3.dll, otherwise symbols cannot be
103+ # found directly.
104+ python_dl_path =
105+ root_dir
106+ |> Path . join ( "python3?*.dll" )
107+ |> wildcard_one! ( )
108+ |> make_windows_slashes ( )
109+
110+ python_home_path = make_windows_slashes ( root_dir )
111+
112+ python_executable_path =
113+ project_dir
114+ |> Path . join ( ".venv/Scripts/python.exe" )
115+ |> make_windows_slashes ( )
116+
117+ venv_packages_path =
118+ project_dir
119+ |> Path . join ( ".venv/Lib/site-packages" )
120+ |> make_windows_slashes ( )
121+
122+ % Pythonx {
123+ python_dl_path: python_dl_path ,
124+ python_home_path: python_home_path ,
125+ python_executable_path: python_executable_path ,
126+ sys_paths: [ venv_packages_path ]
127+ }
128+
129+ { :unix , osname } ->
130+ dl_extension =
131+ case osname do
132+ :darwin -> ".dylib"
133+ :linux -> ".so"
134+ end
135+
136+ python_dl_path =
137+ root_dir
138+ |> Path . join ( "lib/libpython3.*" <> dl_extension )
139+ |> wildcard_one! ( )
140+ |> Path . expand ( )
141+
142+ python_home_path = root_dir
143+
144+ python_executable_path = Path . join ( project_dir , ".venv/bin/python" )
145+
146+ venv_packages_path =
147+ project_dir
148+ |> Path . join ( ".venv/lib/python3*/site-packages" )
149+ |> wildcard_one! ( )
150+
151+ % Pythonx {
152+ python_dl_path: python_dl_path ,
153+ python_home_path: python_home_path ,
154+ python_executable_path: python_executable_path ,
155+ sys_paths: [ venv_packages_path ]
156+ }
157+ end
158+
159+ Pythonx . init ( python_config )
160+ python_config
151161 end
152162
153163 defp wildcard_one! ( path ) do
0 commit comments