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

Allow offline mode via environment variable #363

Closed
theCapypara opened this issue Sep 30, 2023 · 7 comments
Closed

Allow offline mode via environment variable #363

theCapypara opened this issue Sep 30, 2023 · 7 comments

Comments

@theCapypara
Copy link

theCapypara commented Sep 30, 2023

Hello! I'm trying to publish an app using Flatpak. Flatpak works with completely offline builds where all artifacts are pre-fetched and no internet connection is available in the build environment,

At the moment (as far as I can tell) setuptools_rust requires the --offline flag for Cargo to be placed in the setup.py of the project that uses it. As such I'm currently forced to write and include patches to all packages using Setuptools Rust.

It would be great if offline mode could be enforced using an environment variable, ideally one shared with Maturin, see this issue:
PyO3/maturin#1784

@theCapypara
Copy link
Author

Maturin uses config-settings, setuptools-rust could probably do the same.

@davidhewitt
Copy link
Member

The most portable way seems to be to send a PR to cargo to support CARGO_OFFLINE directly, if you're open to that?

@davidhewitt
Copy link
Member

Alternatively maybe something like #327 (comment) using the config settings.

@theCapypara
Copy link
Author

If CARGO_OFFLINE would be OK I'd be interested in giving implementing this a try.

I think this sounds like the easiest and also most expected solution. It's also really easy to implement in any CI pipeline (such as Flatpak manifests) without needing to reach into the requirements of the package that uses setuptools-rust (given that pip doesn't strip environment variables... not sure if it does with build isolation).

@davidhewitt
Copy link
Member

Actually now that I look at this again I realise what you want is already present - setting CARGO_NET_OFFLINE=true should set offline mode.

See https://doc.rust-lang.org/cargo/reference/config.html#netoffline

@theCapypara
Copy link
Author

Oh, really?
I looked for an option like this. Now it's been a short while, but I wonder how I missed this, or if I tried and it didn't work. I'll try again and update.

@theCapypara
Copy link
Author

This does indeed work, thank you!

If anybody needs a reference: flathub/org.skytemple.Randomizer@2b3d4ce#diff-3e722fa1f0525d390439912146aef963826ca681721f98919ae5d98910855071R197-R240

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

No branches or pull requests

2 participants