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 explicit exports of host environment variables #730
Comments
A quick test for this shows that |
For that specific one, there's also a potential problem with the way the built-in expandvars works. I don't want it to be set if An alternative solution would be as mentioned in #117, there could be a list of exported variables, like: [tool.cibuildwheel]
export-host = ["SETUPTOOLS_SCM_PRETEND_VERSION"] I think the above solution is more elegant and less to remember/teach, but pointing out options. |
Actually, "Or, can we import all the host variables, except ones that are already defined in the container, like PATH." sounds really simple and easy to teach (linux would behave much like windows/macOS already does), and wouldn't require adding anything - then CIBW_ENVIRONMENT/tool.cibuildwheel.environment would be additive (the latter would be especially useful). Is there anything wrong with making a list of variables not allowed, writing any variables present and not in that list to a file, and then using |
So to my eyes there are two options here:
Then, maybe the right approach would be to have an option, but by default, pass through everything that's not defined in the container. So, something like |
Ideas for names: CIBW_ENVIRONMENT_PASS, CIBW_PASSENV, CIBW_PASS_ENVIRONMENT, CIBW_EXPOSE, CIBW_ENVIRONMENT_EXPOSE. Sadly, there's no good way to disable this completely, CIBW_ENVIRONMENT_PASS="" would need to be the "auto" default. But you can just do 2.0 seems like a good time to do this, since it changes the default (to something less surprising to new users). |
For completeness, there is another way to do this, without adding an extra option, that's the HOST_ prefix idea from #117. That is, expose all the host environment variables with a HOST_ prefix. So to pass though a variable you'd do Worth considering too, as it would be more explicit, and wouldn't require a new option. |
Looking at it again, this is a dupe of #117, I think? |
That's not very discoverable, though. And I think trying to match the macOS/Windows behavior by default seems like a good change. I would hope that for 95% of the users, they would not need the new option, and would just not have to use CIBW_ENVIRONMENT as often (just for adding a variable, which is handy). Yes, this didn't start that way, but now it's a dupe. |
How about |
Thinking about this more. I'm not sure that passing host environment variables through by default is a good idea, to be honest. We don't control what the CI sets and there's no way to know how those might impact users' builds. For example, this is what Github sets:
Sooo many paths that would break inside the container. And we'd also have to check all the other CIs to find what they set, too. I'm currently preferring the Another thing I was thinking was that if a user did want to use a path from their host, they could do so by doing Or conversely, if we did the PASSENV approach and the user wanted to use, I don't know... |
How about Most of those variables will not be used - But, yeah, just setting |
I could see variables like Or we could just pass everything as |
Are there any updates with regard to exporting host environment variables? Now with the toml override syntax, this becomes even more important. Using Github Actions the only way to do this was something like: env:
CIBW_ENVIRONMENT: "GITHUB_REF=${{ env.GITHUB_REF }}" But now if someone wants to use the new toml configuration and specifically overrides (because this isn't supported outside of toml), you can't access the host environment variables. If I specify In #799 (reply in thread) it sounds like @henryiii might be open to the possibility of allowing environment variables to get merged into a single set. That would solve this issue as you could still forward environment variables as I describe above. What I'd really like to see is the ability to merge environment variables (especially important for the override syntax as without it you're copying potentially many environment variables between all your overrides) with the ability to pass through host environment variables. |
This was implemented in #914. |
One thing I immediately needed when adding config support to boost-histogram is the ability to export an environment variable. Specifically, I would like to do this:
Would that be something we could support for exporting an environment variable? The function to do this in Python seems to be called
os.path.expandvars
, though I don't think it has anything special to do with paths.Related to #117
The text was updated successfully, but these errors were encountered: