-
Notifications
You must be signed in to change notification settings - Fork 249
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
Setup python extracted from build function #307
Conversation
cibuildwheel/macos.py
Outdated
env['ARCHFLAGS'] = '-arch x86_64' | ||
if 'MACOSX_DEPLOYMENT_TARGET' not in env: | ||
env['MACOSX_DEPLOYMENT_TARGET'] = '10.9' | ||
env, dependency_constraint_flags = setup_python(config, dependency_constraints, environment) |
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 like the multiple return here, the env
makes a lot of sense, but the dependency_constraint_flags seems too trivial. Could that go elsewhere? I think a method DependencyConstraints.pip_flags(python_version)
would neaten this up.
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.
Isn't it even better to resolve dependency_constraints.get_for_python_version(python_configuration.version)
before setup_python
, and pass it as an argument?
Now, dependency_constraints
is passed, and dependency_constraint_flags
is returned, but that's just a remnant of cutting and pasting the code from before. There's no semantic reason why setup_python
would "produce" dependency_constraint_flags
.
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 move dependecy_constrains_flags
outside python_setup
function.
cibuildwheel/windows.py
Outdated
@@ -19,7 +19,7 @@ | |||
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows' | |||
|
|||
|
|||
def shell(args, env=None, cwd=None): | |||
def call(args, env=None, cwd=None): |
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.
call()
on macOS doesn't use a shell by default, here Windows always does. I think that's why the names are different. If we're changing it, I'd recommend using a shell only where necessary - when running user commands.
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.
It might actually be nice to keep the distinction, then?
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.
it is not possible because of this bug https://bugs.python.org/issue8557 (with shell=False
environment variable PATH passed with env=env
is ignored).
Change name allow to use same build function for both systems.
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.
Ah, that is a problem. Probably that means we should stick with shell
on Windows.
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.
Ok. I revert this change.
To be fair, personally, I don't really see the advantage of moving that one piece of code to its own function. We're not calling it multiple times, anyway, so it seems to only clutter up stuff more, as demonstrated by the multiple return values, no? |
I don't really understand how this is going to be easier, either? |
5fbb703
to
7c4f345
Compare
This changes are connected with my propositions from #281.
For me first reason is that function build is to long. So I suggest to extract from it thinks not connected with build.
def custom_main():
from cibuildwheel import windows
windows.setup_python = custom_setup
from cibuildwheel.__main__ import main
main() For example someone have installed python version and would like to setup python create virtualenv instead of install new python versions on machine. |
I know, but I wasn't really convinced before, either. Anyway, just voicing my opinion; it's up to @joerick to decide
I don't see how it's too long, because for me needing to go up and down might be more annoying than just seeing the series of commands. But that's just taste, I guess; I'm not saying this is horrible, either :-)
Pffff, we don't have a public API, so let's not count on this! If we want to allow these kinds of things, lots of other things need to happen on the level of architecture and design. For now, if anyone wants a custom cibuildwheel, it'll have to be a fork anyway, I suspect. |
22f18af
to
a276abb
Compare
For me, the neatness of having a |
a276abb
to
a4602c3
Compare
But I see other option for optimalization. Wrote code which will check environment and avoid obsolete |
|
Extract to separate function should simplify of profiling. We could test how many times it consume in next steps. |
Good point - it's a subprocess, so the cache would be thrown away each time. Plus, there is tons of global state - the python installs themselves, and the whole filesystem, which could be modified by CIBW_ENVIRONMENT. Erm, so yeah, not my finest idea 😳!
It could be |
For windows and macos extract python setup to separate function and rename
windows.shell
towindows.call
to unifybuild
function between systems.Main advantage of this PR is separate build wheel logic from python setup logic. Build function is shorter and easier to analyse.
This also allow to simplify user porting on CI which are not possible to test from github like gitlab (#158)