-
Notifications
You must be signed in to change notification settings - Fork 100
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
Support adding custom env vars #504
base: main
Are you sure you want to change the base?
Conversation
f1d788f
to
0c7bebc
Compare
The mingw CI failures are also on main |
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.
Thanks! Implementation looks fine, though I slightly worry about the complexity.
I tried to look for prior art, as far as I can tell Cython / setup tools doesn't have a supported option and just leaves you to modify os.environ
as part of setup.py
. Is there a reason why that's not good enough for this use case here?
(Mingw failures I've just resolved in #501. PyPy 3.10 is just flat out broken as far as I can tell until the next PyPy version is released.) |
Thanks I'll rebase. |
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.
os.environ
is global state and i'd prefer to isolate those values, as far as that's possible for environment variables. In my experience that helps with debugging.
I agree with this, though I am also willing to be a bit more lax for simplicity's sake in these "build system" components especially when it's sort of ok (IMO) to treat setup.py
as an entrypoint setting up build configuration.
I guess the main cost of the isolation (as we see in this PR) is that we have to be careful to pass the env dict to all downstream processes; forgetting to do so once is probably easy to miss in review and will create bugs. Can we use ruff
to forbid use of subprocess outside our own private wrapper which requires an Env
? (Maybe this setting?)
Is there any place outside of subprocesses where these variables might matter? I think it seems clear enough from docs that we only intend for this to affect rustc / cargo. The only other subprocesses we call (as far as I see from a quick scan) are strip
and lipo
(on various platforms), but I think there is little need for those to be affected by this option.
I think as long as we have ways to avoid this getting out of sync later with some tests or lints, this gets 👍 from me.
0c7bebc
to
d00026c
Compare
Rebase to fix the tests and fixed the review comment |
Any ideas what we can do to mitigate this concern? Does my suggestion to use |
That's a though problem, i can't figure out a good solution: The subprocess module has a number of functions that create a subprocess, and we don't want to ban using them, we only want to ensure that |
As an independent use-case for this feature: I just needed this feature today: I am building two |
Currently, maturin and setuptools-rust are not self-contained: You need to install rust on the machine in order to build a package. We can improve this by downloading a matching rustup, using it to install cargo and rustc into a temporary directory and using this rust for the build. As long as the platform is supported by rustup, we get a self-contained build that doesn't mess with the host system. You can for example use
pip install ...
in a freshpython3-slim
docker container and any rust dependency with a missing wheel will build and install without additional setup.To inject this cache installation, we need to set
PATH
,RUST_HOME
andCARGO_HOME
whenever we callcargo
orrustc
.With these changes, we can make bootstrapping maturin self-contained: