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

feat: support passenv #914

Merged
merged 10 commits into from Nov 21, 2021
Merged

feat: support passenv #914

merged 10 commits into from Nov 21, 2021

Conversation

henryiii
Copy link
Contributor

This is an initial implementation of what passenv would look like. Some thought into escaping quotes is likely needed?

@henryiii
Copy link
Contributor Author

Buggy Travis Windows. Anyway, how does this approach look?

Copy link
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

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

This approach seems good to me, yes.

In terms of names, how would you feel about environment_pass/CIBW_ENVIRONMENT_PASS? I'm just thinking to spiritually nest it within the environment option.

cibuildwheel/environment.py Outdated Show resolved Hide resolved
cibuildwheel/options.py Outdated Show resolved Hide resolved
@henryiii henryiii marked this pull request as draft November 13, 2021 16:55
@henryiii
Copy link
Contributor Author

I've implemented the Docker passthrough version, feel free to take a look. It can drive a new docker launch if you use an override to set it differently, but that should be rare. I like avoiding trying to escape these, and leaving it up to docker.

It seemed to me passenv might be a bit of convention, possibly? I'm not sure if it is. Otherwise I don't have a strong option on it. I would be more inclined toward nesting if we'd made the nesting real (build.all instead of build-all, etc).

@joerick
Copy link
Contributor

joerick commented Nov 14, 2021

I've implemented the Docker passthrough version, feel free to take a look. It can drive a new docker launch if you use an override to set it differently, but that should be rare. I like avoiding trying to escape these, and leaving it up to docker.

Hmm. I'm not so sure this is better - a new Docker launch would be quite a surprise to anyone using this in an override, slowing down the build, and probably quite hard to figure out what was causing it. I think we can get the escaping right, I doubt that's a problem. I'm 99% sure that shlex.quote is the right thing, we already use it for this purpose elsewhere, e.g.

env_assignments = (
" ".join(f"{shlex.quote(k)}={shlex.quote(v)}" for k, v in env.items())
if env is not None
else ""
)
command = " ".join(shlex.quote(str(a)) for a in args)

It seemed to me passenv might be a bit of convention, possibly? I'm not sure if it is. Otherwise I don't have a strong option on it. I would be more inclined toward nesting if we'd made the nesting real (build.all instead of build-all, etc).

I had thought so too, but I can only find two references - the mod_env module of the Apache webserver, and tox. PassEnvironment actually seems more common. We haven't used 'env' anywhere yet in our options, so it would be better to be internally consistent, so CIBW_ENVIRONMENT_PASS or CIBW_PASS_ENVIRONMENT seem good. My preference would be slightly towards CIBW_ENVIRONMENT_PASS so it would sit next to CIBW_ENVIRONMENT neatly.

@henryiii
Copy link
Contributor Author

environement_pass reads a little oddly, but is fine, then. I'll use that + the manual addition, but would like some help adding a good test for escaping. :)

@henryiii
Copy link
Contributor Author

Only thing left would be one more test.

@henryiii henryiii marked this pull request as ready for review November 18, 2021 20:47
@joerick
Copy link
Contributor

joerick commented Nov 19, 2021

I'm 99% sure that shlex.quote is the right thing

Famous last words. Turns out shlex.quote -> bashlex doesn't work for everything. Actually I think the problem is in bashlex, but either way, I've implemented a different EnvironmentAssignment that passes straight through without bashlex for these passthrough variables.

cibuildwheel/environment.py Outdated Show resolved Hide resolved
cibuildwheel/options.py Outdated Show resolved Hide resolved
unit_test/options_test.py Outdated Show resolved Hide resolved
@henryiii
Copy link
Contributor Author

Good to go?

@joerick
Copy link
Contributor

joerick commented Nov 21, 2021

Yep!

@henryiii henryiii merged commit f45de3f into pypa:main Nov 21, 2021
@henryiii henryiii deleted the henryiii/feat/passenv branch November 21, 2021 20:19
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

Successfully merging this pull request may close these issues.

None yet

2 participants