-
Notifications
You must be signed in to change notification settings - Fork 85
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
Improves check for Rust #182
base: main
Are you sure you want to change the base?
Conversation
7d20f91
to
4364bf8
Compare
I agree this is true in most of the cases, but maybe there's a little chance that |
Co-authored-by: Lluís Revilla <[email protected]>
@yutannihilation I suppose - I've also had it pointed out to me that if somebody really wanted to then they could write Rust code directly inside the Makevars file and build it in there. currently thinking if there's anything more reliable? |
Another check that can be added as mentioned by @JosiahParry is to check that SystemRequirements include these elements: "Cargo (Rust's package manager), rustc", as according to CRAN's rust policy they are required. I don't know how often of if possible but maintainers might mention them in different order or after other system dependencies. Also note that this would need to be done conditionally as other repositories, Bioconductor or others, might not be so specific. |
@llrs I don't know whether that's "good enough": the original check contains this comment
so the original author already considered SystemRequirements to not be robust enough |
Yes @alexhroom I'm aware of that comment, but CRAN policy specifically says:
Emphasis mine. Even if it is not robust, if there aren't those two requirements, maintainers are not complying with CRAN's policy, so they might want to detect that. It might be easier to convince CRAN to check for something they themselves have decided than to try to come up with other ways to detect rust. |
@llrs oh I misunderstood you: i thought you meant 'check' as in 'check that the package is compiling Rust code', not 'check for package CRAN compilance'! got it. |
Note that this is happening after the package is compiled and installed in the temporary library. There may be an even smaller chance that the build process cleans up after itself and removes Of course a package could |
@aitap you can also pass |
Ah, then, you are right, sorry. I just didn't know well about the build process. Another counter example I just came up with is to use an unusual name of manifest file with (IMHO, if the R core wants accuracy, they should either make the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition with this last commit.
- Maybe a comment explaining why these checks are added might help future readers.
- Apologies for only raising this later than my initial comment: I haven't checked, if
check_rust()
is always run whenR CMD check
is used or only activated in a special check/branch/condition. I am not sure this is the right place to check for this, because maybe it would be run on Bioconductor or in other repositories checks and this could be against their policy.
For example, I don't know how Bioconductor handles rust, I haven't seen any mention on their mailing list or slack. This could be well or break some packages there (and the repository systems would need to be updated/changed)
##message("InstLog = ", InstLog) | ||
lines <- readLines(InstLog, warn = FALSE) | ||
l1 <- grep("(cargo build| Compiling )", lines) | ||
l1 <- grep(r"(cargo\N+build| Compiling )", lines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
l1 <- grep(r"(cargo\N+build| Compiling )", lines) | |
l1 <- grep(r"(cargo\s+build| Compiling )", lines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no: wanted to also capture configuration and toolchain use if CRAN lets that happen in future.
all the following are valid calls:
cargo build
cargo build
cargo +1.71 build
(builds with specifically Rust version 1.71)
cargo +stable build
(builds with current stable version)
cargo cargo --config profile.dev.package.image.opt-level=3 build
(overrides a global config setting)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the submission of the patch or in a comment I would mention this change allows to catch more cases of packages building rust. I am not sure R Core team or Brian Ripely is aware of this possibility.
But I was checking regex, and I only found that \N is:
The backreference ‘\N’, where ‘N = 1 ... 9’, matches the substring previously matched by the Nth parenthesized subexpression of the regular expression. (This is an extension for extended regular expressions: POSIX defines them only for basic ones.)
And as this backreference is inside the parenthesis I am not sure how it will work. That's why I proposed a change. When I want to match arbitrary characters between two known sets I usually use .+ because according to the documentation "The period ‘.’ matches any single character.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's intended to mean the anything but a newline signifier in PCRE2. It will need perl = TRUE
to work.
Co-authored-by: Lluís Revilla <[email protected]>
yesterday a check for packages which compile Rust was added: 6114d41
This check claims that "It is impossible to tell definiitively if a package compiles rust code". This is not true. Rust code can be compiled if
and only ifthere is aCargo.toml
metadata file. This PR changes thecheck_rust
check to quit if the package does not contain aCargo.toml
anywhere under thesrc
directory.