Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the spack package manager #2905

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 85 additions & 0 deletions app/models/package_manager/spack.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# frozen_string_literal: true

module PackageManager
class Spack < Base
HAS_VERSIONS = true
HAS_DEPENDENCIES = true
HAS_OWNERS = true

# spack generates a spec.json for each package installed
BIBLIOTHECARY_PLANNED = true
URL = "https://spack.io"
COLOR = "#0d3d7e"

def self.formatted_name
'spack'
end

def self.package_link(db_project, version = nil)
"https://spack.github.io/packages/package.html?name=#{db_project.name}"
end

def self.project_names
get_json("https://spack.github.io/packages/data/packages.json")
rescue StandardError
{}
end

def self.documentation_url(name, version = nil)
"https://spack.github.io/packages/package.html?name=#{db_project.name}"
end

def self.project(name)
get_json("https://spack.github.io/packages/data/packages/#{name}.json")
rescue StandardError
{}
end

def self.mapping(raw_project)
{
name: raw_project["name"],
description: raw_project["description"],
homepage: raw_project["homepage"],
licenses: [],
repository_url: raw_project["homepage"],
}
end

def self.versions(raw_project, _name)
json = get_json("https://spack.github.io/packages/data/packages/#{name}.json")
json.map do |v|
{
number: v["name"],
# We have a sha256 if that is needed.
# We don't have this information easily, it's in git
published_at: Time.now.strftime("%d-%m-%Y %H:%M")
}
end
rescue StandardError
[]
end

def self.dependencies(name, version, _mapped_project)
json = get_json("https://spack.github.io/packages/data/packages/#{name}.json")
return [] unless json['dependencies']
deps = json["dependencies"]
deps.map do |dep|
{
project_name: dep["name"],

# This is determined by the solver at install
requirements: '*',

# We have this information but not exposed via API
kind: 'runtime',
platform: self.name.demodulize
}
rescue StandardError
[]
end

def self.install_instructions(db_project, version = nil)
"spack install #{db_project.name}" + (version ? "@#{version}" : "")
end
end
end
5 changes: 5 additions & 0 deletions lib/tasks/download.rake
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ namespace :download do
PackageManager::SwiftPM.import
end

desc 'Download all Spack packages asynchronously'
task spack_all: :environment do
PackageManager::Spack.import_async
end

desc "Download all Rubygems packages asynchronously"
task rubygems_all: :environment do
PackageManager::Rubygems.import_async
Expand Down