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

How to handle Rust/cargo packages (or how to add a cargo easyblock) #2899

Closed
Micket opened this issue Feb 28, 2023 · 1 comment · Fixed by #2902
Closed

How to handle Rust/cargo packages (or how to add a cargo easyblock) #2899

Micket opened this issue Feb 28, 2023 · 1 comment · Fixed by #2902
Milestone

Comments

@Micket
Copy link
Contributor

Micket commented Feb 28, 2023

I think it would be nice to make some type of easyblock for Rust/cargo packages. They are a bit of a special animal. Typically lots and lots of dependencies in cargo making it completely infeasible to make easyconfigs for each one.

We already have some easyconfigs that use cargo, and they are downloading all their dependencies at build time.
Another neat thing is that almost all Rust apps just link down to a single binary, no dynamic linking, so they can typically live at SYSTEM level at runtime.

So, ignoring the downloading of all those cargo deps at runtime, a typical easyconfig for a Rust software today could look like ripgrep-13.0.0.eb

easyblock = 'Binary'

name = 'ripgrep'
version = '13.0.0'

homepage = 'https://github.com/BurntSushi/ripgrep'
description = """ripgrep is a line-oriented search tool that recursively searches the current directory for a regex
pattern."""

toolchain = SYSTEM

github_account = 'BurntSushi'
source_urls = [GITHUB_SOURCE]
sources = ['%(version)s.tar.gz']
checksums = ['0fb17aaf285b3eee8ddab17b833af1e190d73de317ff9648751ab0660d763ed2']

builddependencies = [
    ('Rust', '1.65.0', '', ('GCCcore', '12.2.0')),
]

extract_sources = True

install_cmd = "cargo install --root %(installdir)s --path ."

sanity_check_paths = {
    'files': ['bin/rg'],
    'dirs': [],
}

sanity_check_commands = ["rg --help"]

moduleclass = 'tool'

but we can clean up some of those steps with a custom easyblock for the install command and the source extraction.
Downloading of sources would also be nice without having to rely on github for the base package. I mean, if we are download 99% of the code at build time anyway, we might as well just have it download the sources for the top level package as well.

If we want to, we could probably cache some sources and tell cargo to pick them up from the sources dir.
https://doc.rust-lang.org/cargo/reference/registries.html
https://users.rust-lang.org/t/using-crates-in-offline-environment/72970/22

@boegel boegel added this to the 4.x milestone Mar 1, 2023
@boegel
Copy link
Member

boegel commented Mar 1, 2023

see also vscentrum/vsc-software-stack#83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants