Skip to content

Commit

Permalink
Merge pull request #1690 from stephen-ritter/feature/configurable-dep…
Browse files Browse the repository at this point in the history
…endency-repo-urls

Configurable Default Repository URLs for Ruby Gems and Python Packages
  • Loading branch information
ryanmelt authored Nov 8, 2024
2 parents 500f7db + ce2b98e commit 76a49b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ OPENC3_AWS_ARN_PREFIX=arn:aws
# OPENC3_NO_TOOLADMIN=1
# OPENC3_NO_BUCKETEXPLORER=1
# OPENC3_NO_DOCS=1

# Enables the --trusted-host flag when downloading python package from the PYPI_URL
# PIP_ENABLE_TRUSTED_HOST=1
7 changes: 6 additions & 1 deletion openc3/lib/openc3/models/plugin_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ def self.install_phase2(plugin_hash, scope:, gem_file_path: nil, validate_only:
end
unless validate_only
Logger.info "Installing python packages from requirements.txt with pypi_url=#{pypi_url}"
puts `/openc3/bin/pipinstall --no-warn-script-location -i #{pypi_url} -r #{File.join(gem_path, 'requirements.txt')}`
if ENV['PIP_ENABLE_TRUSTED_HOST'].nil?
pip_args = "--no-warn-script-location -i #{pypi_url} -r #{File.join(gem_path, 'requirements.txt')}"
else
pip_args = "--no-warn-script-location -i #{pypi_url} --trusted-host #{URI.parse(pypi_url).host} -r #{File.join(gem_path, 'requirements.txt')}"
end
puts `/openc3/bin/pipinstall #{pip_args}`
end
needs_dependencies = true
end
Expand Down
7 changes: 6 additions & 1 deletion openc3/lib/openc3/models/python_package_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ def self.install(name_or_path, scope:)
end
end
Logger.info "Installing python package: #{name_or_path}"
result = OpenC3::ProcessManager.instance.spawn(["/openc3/bin/pipinstall", "--no-warn-script-location", "-i", pypi_url, package_file_path], "package_install", package_filename, Time.now + 3600.0, scope: scope)
if ENV['PIP_ENABLE_TRUSTED_HOST'].nil?
pip_args = ["--no-warn-script-location", "-i", pypi_url, package_file_path]
else
pip_args = ["--no-warn-script-location", "-i", pypi_url, "--trusted-host", URI.parse(pypi_url).host, package_file_path]
end
result = OpenC3::ProcessManager.instance.spawn(["/openc3/bin/pipinstall"] + pip_args, "package_install", package_filename, Time.now + 3600.0, scope: scope)
return result.name
end

Expand Down
4 changes: 2 additions & 2 deletions openc3/lib/openc3/models/scope_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ def seed_database
setting = SettingModel.get(name: 'source_url')
SettingModel.set({ name: 'source_url', data: 'https://github.com/OpenC3/cosmos' }, scope: @scope) unless setting
setting = SettingModel.get(name: 'rubygems_url')
SettingModel.set({ name: 'rubygems_url', data: 'https://rubygems.org' }, scope: @scope) unless setting
SettingModel.set({ name: 'rubygems_url', data: ENV['RUBYGEMS_URL'] || 'https://rubygems.org' }, scope: @scope) unless setting
setting = SettingModel.get(name: 'pypi_url')
SettingModel.set({ name: 'pypi_url', data: 'https://pypi.org' }, scope: @scope) unless setting
SettingModel.set({ name: 'pypi_url', data: ENV['PYPI_URL'] || 'https://pypi.org' }, scope: @scope) unless setting
end
end
end

0 comments on commit 76a49b6

Please sign in to comment.