Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/pythonx.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ defmodule Pythonx do
* `:uv_version` - select the version of the uv package manager to use.
Defaults to `#{inspect(Pythonx.Uv.default_uv_version())}`.

* `:native_tls` - if true, uses the system's native TLS implementation instead
of vendored rustls. This is useful in corporate environments where the system
certificate store must be used. Defaults to `false`.

'''
@spec uv_init(String.t(), keyword()) :: :ok
def uv_init(pyproject_toml, opts \\ []) when is_binary(pyproject_toml) and is_list(opts) do
opts = Keyword.validate!(opts, force: false, uv_version: Pythonx.Uv.default_uv_version())
opts =
Keyword.validate!(opts,
force: false,
uv_version: Pythonx.Uv.default_uv_version(),
native_tls: false
)

Pythonx.Uv.fetch(pyproject_toml, false, opts)
install_paths = Pythonx.Uv.init(pyproject_toml, false, Keyword.take(opts, [:uv_version]))
Expand Down
7 changes: 5 additions & 2 deletions lib/pythonx/uv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Pythonx.Uv do
"""
@spec fetch(String.t(), boolean(), keyword()) :: :ok
def fetch(pyproject_toml, priv?, opts \\ []) do
opts = Keyword.validate!(opts, force: false, uv_version: default_uv_version())
opts = Keyword.validate!(opts, force: false, uv_version: default_uv_version(), native_tls: false)
Comment thread
jonatanklosko marked this conversation as resolved.
Outdated

project_dir = project_dir(pyproject_toml, priv?, opts[:uv_version])
python_install_dir = python_install_dir(priv?, opts[:uv_version])
Expand All @@ -28,7 +28,10 @@ defmodule Pythonx.Uv do
File.write!(Path.join(project_dir, "pyproject.toml"), pyproject_toml)

# We always use uv-managed Python, so the paths are predictable.
if run!(["sync", "--managed-python", "--no-config"],
base_args = ["sync", "--managed-python", "--no-config"]
uv_args = if opts[:native_tls], do: base_args ++ ["--native-tls"], else: base_args

if run!(uv_args,
cd: project_dir,
env: %{"UV_PYTHON_INSTALL_DIR" => python_install_dir},
uv_version: opts[:uv_version]
Expand Down
Loading