Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion openc3/lib/openc3/models/plugin_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ def self.install_phase2(plugin_hash, scope:, gem_file_path: nil, validate_only:

if File.exist?(pyproject_path) || File.exist?(requirements_path)
pypi_url = resolve_pypi_url(scope: scope)
unless validate_only
# Skipped for any dry run: diff_only runs inline in an HTTP request, so
# a slow or unreachable PyPI would time it out, and it must not mutate
# the plugin venv.
unless dry_run
pypi_args = build_pypi_args(pypi_url)

# Install Python dependencies into an isolated per-plugin venv when UV
Expand Down
19 changes: 17 additions & 2 deletions openc3/spec/models/plugin_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ module OpenC3
# which Python dependency file it ships and what OPENC3_USE_UV is set
# to, so the shared doubles live here and each example is left with the
# behavior it actually asserts.
def stub_plugin_gem(dep_file: 'pyproject.toml', dep_body: '[project]', use_uv: nil)
def stub_plugin_gem(dep_file: 'pyproject.toml', dep_body: '[project]', use_uv: nil, gem_install: true)
expect(GemModel).to receive(:get).and_return("my_plugin.gem")
gem = double("gem")
expect(gem).to receive(:extract_files) do |path|
Expand All @@ -643,7 +643,11 @@ def stub_plugin_gem(dep_file: 'pyproject.toml', dep_body: '[project]', use_uv: n
end
expect(Gem::Package).to receive(:new).and_return(gem)
allow(gem).to receive(:spec).and_return(spec_double)
expect(GemModel).to receive(:install).and_return(nil)
if gem_install
expect(GemModel).to receive(:install).and_return(nil)
else
expect(GemModel).to_not receive(:install)
end

allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with('OPENC3_USE_UV').and_return(use_uv)
Expand Down Expand Up @@ -740,6 +744,17 @@ def install_plugin

expect(install_plugin['needs_dependencies']).to eql true
end

it "does not install python packages when diff_only" do
stub_plugin_gem(gem_install: false)
stub_uv_on_path(true)

expect(Open3).to_not receive(:capture2e)

result = PluginModel.install_phase2({"name" => "name", "variables" => {}, "plugin_txt_lines" => plugin_txt_lines},
scope: "DEFAULT", diff_only: true)
expect(result).to eql([])
end
end
end

Expand Down
Loading