-
Notifications
You must be signed in to change notification settings - Fork 247
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
CIBW_ENVIRONMENT #21
CIBW_ENVIRONMENT #21
Conversation
Currently only linux is working. I'm splitting the environment variables into keyvalue pairs and storing them in a dictionary at startup, then injecting them into the build environment inside the Docker. |
I've come across a problem with the escaping rules - for Possible solutions-
I'm thinking the latter will also pave the way to nice macOS and windows solutions, since in those scenarios we'll be merging two dictionaries to form the environment that's passed to the subprocesses. Maybe I'm overthinking - anyone see an easier way to accomplish this? |
Cool, nice job! A few comments (cfr. what I encountered in #19):
|
Thanks for your feedback @YannickJadoul !
Gah, this is a fair point. I suppose I'm trying to shield users from the crazy world of shell syntax. The Python way of having environment just be a dict is so much simpler than the crazy shell world. Also, part of me is thinking about how this might look in a cibuildwheel.yml file...
Maybe the solution is to let the shell handle it on Linux. But on Mac and Windows...
Tricky. To be honest, ideally, this would be in Python. Maybe I'll just write a parser for these strings. How hard can it be :D |
What about replacing $VAR and %VAR% (Windows) by just having {VAR} in the input? Then you could do something like The one thing I'm still 'afraid' of is that by quoting these environment variables and losing backtick-tricks, the environment variables would be completely static. For example, if you set a path that contains a certain version number, you cannot figure out that version dynamically and have to adapt it in multiple places. Then again, maybe I'm over-thinking that part and maybe it would already be good to have this basic example working.
I do like the idea of being able to use a single yaml/json file instead of only the CIBW environment variables!
Eeeeeerm, rather you than me, in that case ;-) |
I'd be opposed to this, at least in this stage of the game..users already need to have separate appveyor and travis files. I don't see the value in having variables in a separate file unless cibuildwheel really starts becoming more feature rich (and therefore complex). As for CIBW_ENVIRONMENT in general...is there actually any advantage to having this option for Mac or Windows? Isn't this feature only really needed for Linux where Docker is being used? |
So, I should explain a little more. My idea with the config file is to reduce the travis.yml and appveyor.yml files (and circle.yml... ) to simple copy+paste, and move the configuration into our file. This has a few advantages
- configuration is by default shared across the platforms (user doesn't have to keeps those files in sync)
- configuration is much more easily shared between projects (have a project that uses imagemagick? This config is a good place to start)
- in the 'happy path', users don't have to know how other platforms work (the Docker considerations, windows cmd syntax), since cibuildwheel abstracts over that stuff
So it's really about making that painful first setup a little easier, by giving the user more direct and familiar controls over the build process.
I know the root of git repos is getting cluttered though! I've got an idea that we should start a campaign to move the stuff into root/etc ... but that's a separate topic :)
… On 15 Aug 2017, at 19:17, tomas garcia ***@***.***> wrote:
Also, part of me is thinking about how this might look in a cibuildwheel.yml file...
I do like the idea of being able to use a single yaml/json file instead of only the CIBW environment variables!
I'd be opposed to this, at least in this stage of the game..users already need to have separate appveyor and travis files. I don't see the value in having variables in a separate file unless cibuildwheel really starts becoming more feature rich (and therefore complex).
As for CIBW_ENVIRONMENT in general...is there actually any advantage to having this option for Mac or Windows? Isn't this feature only really needed for Linux where Docker is being used?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I get where you're coming from. My trepidation is that if cibuildwheel gets intertwined with appveyor/circle/travis configuration then we have to start 'keeping up' with their changes, features, and issues. Thinking along these lines I was also skeptical of doing things like #24 which in my view is fixing an issue that is due to the continuous integration service build environment (IOW any person using appveyor with python will have this issue - not just cibuildwheel users); maybe in a month this issue is not even present in appveyor! Anyway, I guess my two cents is that trying to abstract CI services and OSes for users seems like the wrong way to go - at least for a relatively small project like this one. If you have a rough sketch of what you're thinking on the single configuration file idea, I'd be interested to see it though. Back to the point at hand...I'm not sure what the best solution for this issue is. I'd be tempted to add a CIBW_DOCKER_ENVIRONMENT since that's the only platform for which this feature is really needed but I don't want to just end up getting rid of it soon after that for something better... |
Thanks for your thoughts on this @tgarc!
You are giving me pause here... I think there's a lot to be said for keeping things simple, maybe another way of saying your point is that cibuildwheel will always be a leaky abstraction, so why try to paper over how it works.
But when I think about CIBW_DOCKER_ENVIRONMENT, I'm thinking:
So I'm coming back to the current approach, even without the single config file idea. |
p.s. the single config file might look like: cibuildwheel.yml environment:
- $PATH:/usr/local/bin
before_build: "pip install ."
test_requires:
- pytest
test_command: "pytest {project}/tests" (but it probably needs more thought... e.g. platform-specific options) |
So... this should be ready to merge now (CI pending)! I found a really handy module called bashlex which has really helped with the environment string parsing. If you have time @tgarc @YannickJadoul would you mind giving a quick review? |
Sounds pretty good! I'll make some time for having a look at this tomorrow. |
@joerick Wow, this is the closest we've come to having something that's acutally working! :-D I was surprised by how many lines you've needed to add to make this work (even using that For the rest, it seems as if the escaping will sometimes be hell, as your example Finally, I'd just like to bring up the consideration if this should be executed once, or if we would allow the user to execute it for every Python executable (possibly doing something with the value of |
By the way, I cannot say I've looked at every single detail, but I cannot find any concrete things to remark in a code review! I'll try putting this PR to use tomorrow, if I find the time to set up wheel building for manylinux1 for my project, using this. |
On the AppVeyor error: >>> x = json.load(open('environment.json', 'r'))
>>> x["CIBW_ENVIRONMENT_WINDOWS"]
u'CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo \'test string 3\')" PATH="$PATH;/opt/cibw_test_path"'
>>> list(bashlex.split(x["CIBW_ENVIRONMENT_WINDOWS"]))
[u'CIBW_TEST_VAR="a b c"', u'CIBW_TEST_VAR_2=1', u"CIBW_TEST_VAR_3=$(echo 'test string 3')", u'PATH=$PATH;/opt/cibw_test_path' Isn't this weird/wrong, that |
Yes it's pretty strange. I've got an idea how to resolve it though, using bashlex.parse instead |
If we're sure this is wrong, we could of course also log an issue on the bashlex project? Two more things, btw:
|
Perfect, let's see what that brings :-)
Done. Is there a way to make a PR on a PR? :-D I could just attach the 2 changed files here, too, if that's better? |
Just push to this branch, I'll review it as part of this 👍 |
Well, my git complains I don't have write access, but I've just pushed it to my 'environment' branch: YannickJadoul@a7c7a58 |
Accept the invite I just sent you and try again ;) |
That also works, of course :-) |
bin/run_tests.py
Outdated
@@ -4,7 +4,7 @@ | |||
import os, sys, subprocess, shutil, json | |||
from glob import glob | |||
|
|||
from . import run_test | |||
import run_test |
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.
I don't know if there is a better way of doing this 'import from the same folder'?
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.
No, there isn't. Also since these are utility scripts I'd prefer using the shell interface instead, something like subprocess.check_call([sys.executable, 'bin/run_test.py', arg1, arg2])
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.
There you go, then. I'd chosen for this such that the whole argument parsing (and extra output 'Project built successfully.') was not executed every time.
Have a look, maybe the if __name__ == '__main__':
construction was also unnecessary, then.
…vironment * 'environment' of github.com:joerick/cibuildwheel: Making call from run_tests to run_test subprocess.check_call Fixing 'ValueError: Attempted relative import in non-package' Reducing code duplication in bin/run_test.py and bin/run_tests.py
Great, thanks Yannick. I've put the fix for the string splits in so this should be working now. I'm gonna write some documentation. |
Brilliant, seems this is almost done! (Whenever Travis CI is starts running OS X jobs, but it seems they are having troubles today.) Minor suggestion, maybe: what about a quick list (+ maybe short description) of all environment variables, before going over them in all detail? That way, the potential user can get an overview of what options there are, before reading the exact implementation of them. |
🎉Merged! Your list sounds useful @YannickJadoul, but I'm not sure what would go in it... are there some common environment variables that are useful for building wheels? |
Awesome!
I actually just mean listing I was just thinking of something like this, at the start of the options:
(but maybe I'm overthinking stuff, but I know that I'm failing to get the overview of all options, especially when I'm just trying to remember the exact name, instead of the whole explanation ;-) ) |
That's a good idea! I'm kinda blind to it since I've seen those options grow over time but I can definitely see that would be useful to a newcomer. |
Once I've fixed my own Windows build, I can have a look, if you want. If you aren't doing it yourself, now, ofc... |
Yes, please do, that would be great. |
Seems my build is now successfully using One minor thing I've encountered: I need to misuse the evaluation in assignments to execute code. Specific case: I want to compile a recent version of ccache (the old in the manylinux1 image is not good enough). Normally this would be a thing for Just thinking out loud: would it be interesting to be able to have some commands that would be executed once, before |
hmmm! In your case, maybe could could set CC and CXX in CIBW_ENVIRONMENT, and then have I'm also wondering if there's a need for a |
Hmmmm, nice idea, with the The |
By the way: because Maybe that kind of construction is an extra argument for |
|
but yes, |
This is a PR to track a branch I've been working on regarding #16.