Skip to content

[ci] [R-package] use a Windows-specific download link for SWIG, stop using '<<-' in R code - #7364

Merged
jameslamb merged 5 commits into
mainfrom
fix/swig-windows
Jul 18, 2026
Merged

jameslamb merged 5 commits into
mainfrom
fix/swig-windows

Conversation

@jameslamb

Copy link
Copy Markdown
Member

Fixes #7363

That 12 hours of CI working was glorious, wasn't it? πŸ˜“

Looks like SWIG's /latest/download link now serves a .tar.gz of the source code, not a .zip of binaries. That broke SWIG CI jobs on Windows.

This switches that CI job to a Windows-specific URL.

@jameslamb jameslamb added blocking CI will be unsuccessful until this is resolved. maintenance labels Jul 15, 2026
@jameslamb jameslamb changed the title WIP: [ci] use a Windows-specific download link for SWIG [ci] use a Windows-specific download link for SWIG Jul 15, 2026
@jameslamb
jameslamb marked this pull request as ready for review July 15, 2026 15:58
@maxzw

maxzw commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@jameslamb If you'd like to avoid updating the version string manually on each SWIG release, SourceForge exposes a best_release.json API that returns per-platform download info:

$releaseInfo = Invoke-RestMethod "https://sourceforge.net/projects/swig/best_release.json"
$swigFilename = $releaseInfo.platform_releases.windows.filename
# e.g. "/swigwin/swigwin-4.4.1/swigwin-4.4.1.zip"
$params = @{
    Uri = "https://sourceforge.net/projects/swig/files$swigFilename/download"
    OutFile = "$env:BUILD_SOURCESDIRECTORY/swig/swigwin.zip"
    UserAgent = "curl"
}

Works on my forked repo! πŸ˜„

@jameslamb

Copy link
Copy Markdown
Member Author

oooooo that'd be great, thanks for the suggestion @maxzw ! lemme try that

@jameslamb

Copy link
Copy Markdown
Member Author

good news: that change worked for the SWIG builds, yay!

bad news: in the time this has been open we have another CI failure (#7365) πŸ˜‚

I'll push changes for that too.

@jameslamb jameslamb changed the title [ci] use a Windows-specific download link for SWIG [ci] [R-package] use a Windows-specific download link for SWIG, stop using '<<-' in R code Jul 17, 2026
Comment thread R-package/R/callback.R
best_score <- NULL
best_msg <- NULL
eval_len <- NULL
cb_state <- new.env()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set of changes to the R code is a fix for #7365 .

We got an exception (maybe a manual override?) early on from CRAN for use of <<- in the package and maybe that'd last forever, but that is a risk of rejected submissions so I think it's worth just fixing this now and forever.

I'm confident that these changes are well-covered by existing tests.

Comment thread .ci/lint-r-code.R

# skip R files fromthird-party dependencies
FILES_TO_LINT <- FILES_TO_LINT[
!grepl("external_libs/|site-packages/", FILES_TO_LINT, fixed = TRUE)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nanoarrow was added as a git submodule in #7275, and it has some R code in it.

We didn't catch that in CI because we skip populating submodules for the linting job:

But I have them populated locally and get a bunch of linting errors for that R code when I run like

Rscript .ci/lint-r-code.R $(pwd)

The site-packages/ addition here is because I had a root-level venv and... scipy has R code in it!

https://github.com/scipy/scipy/blob/826ccec78f7310c43aebfef69f28832ef2eda103/scipy/stats/tests/test_generation/generate_fisher_exact_results_from_r.R#L4

, label = train$label
, params = params
, nrounds = 2L
, num_threads = .LGB_MAX_THREADS

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suppresses this warning:

if (requireNamespace("RhpcBLASctl", quietly = TRUE)) { # nolint: undesirable_function.
return(RhpcBLASctl::get_num_cores())
} else {
msg <- "Optional package 'RhpcBLASctl' not found."
cores <- 0L
if (Sys.info()["sysname"] != "Linux") {
cores <- parallel::detectCores(logical = FALSE)
if (is.na(cores) || cores < 0L) {
cores <- 0L
}
}
if (cores == 0L) {
msg <- paste(msg, "Will use default number of OpenMP threads.", sep = " ")
} else {
msg <- paste(msg, "Detection of CPU cores might not be accurate.", sep = " ")
}

I noticed this while testing locally... I think it could be a problem when we go to release to CRAN. These tests fail if {RhpcBLASctl} is not installed, because that causes a warning to be raised and they run expect_silent().

I don't think these tests have gone through a CRAN check yet.

opened an issue about testing that in CI: #7367 (can be done in a follow-up at some point)

@jameslamb

Copy link
Copy Markdown
Member Author

I think this is ready and will unblock CI. Maybe @mayer79 you'd have some time to look, since it touches the R package?Or @jmoralez ?

@jameslamb

Copy link
Copy Markdown
Member Author

Thanks @shiyu1994 !

@jameslamb
jameslamb merged commit 0704724 into main Jul 18, 2026
60 checks passed
@jameslamb
jameslamb deleted the fix/swig-windows branch July 18, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocking CI will be unsuccessful until this is resolved. maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ci] SWIG Windows jobs failing: "End of Central Directory record could not be found"

3 participants