-
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
Code refactor suggestions #281
Comments
Thanks @Czaki, these are good suggestions. I think I agree with all the points above, except the last one because I like the readability of having the commands right there in the script. |
From one side I agree with you (and this is why I put optional). Form other side I still think how to reduce chance of inconsistency between. systems. Maybe add something in unit test which will mock When #256 will be finished I can prepare PR with my proposition of this changes. |
Sounds good. Yes I'd rather have a unit test that enforces consistency. |
I agree the build options need to be refactored, yes. I've actually been trying out the type annotations and mypy, as suggested in #258, and this dictionary is one of the things that just doesn't seem to work with typing (I'll make a PR soon, just to be able to judge how things look, and to be able to further decide on it). Apart from that, I'm not entirely convinced the other suggestions are that urgent? After taking out the |
repair_command_default_dict: typing.Dict[str, str] = {
"linux": 'auditwheel repair -w {dest_dir} {wheel}',
"macos": 'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}'
} problem with |
Yeah, no, that I know, but the problem is that the types of the keys of
Yes, I know, but that's mostly because it's shared (and important to see, because a few lines down it's added it to |
So there could be function
Build options should be abandoned. There should be some object instead of this. |
@joerick This open question if the idea to write one code for all systems. This may reduce code repetition, but it is possible to reduce code readability. What do you think about this? |
It might be possible to unify, but whether it would be an improvement is an open question! The transition of the linux script to the mac/windows 'call' style would be the first step. From there, it might be clearer how to proceed. FWIW I'd be more inclined towards a single function with platform-specific support libraries, over a class-based override system. Class-based overrides are super-DRY, but you end up having to understand the whole hierarchy, how the methods are called, and what the base class implementation does, and how to override (call super or not?)... it ends up being much harder to read and understand. At that point you'd be at a single function, with platform-specific implementations of 'install_python', 'call/shell', 'copy_file'... which might be an improvement, but I can still foresee lots of e.g. All told, I reckon that if the individual platform build scripts were consistently styled/written, that might be the best solution. But I'm happy if somebody wants to explore this! |
So maybe pass to function object which implement platform specific functions. Something like: class System:
def call(...):
pass
def virtualenv_path(...):
pass
def install_python(...):
pass |
This is something I've been thinking about as well. But I also agree that it will decrease our flexibility in adapting stuff. I'd wait a bit until the current rush of PRs is cooled down a bit more (with e.g., #239) and maybe then we can start with some simpler stuff (arguments to I've also been playing with types, as suggested in #258, btw, just to see what comes out. There's a few things that need to be fixed, but afterwards I can open a PR for discussion. (Still really not convinced it's worth it, but it might a) give some insight into similarities, and b) provide a way to refactor with some static checks.) |
Also, let's keep in mind to not change too many things that are not broken or that will not give clear advantages, I'd say. I like the refactoring idea of this single function, as a design in itself, but I'm not sure the current situation is problematic or much worse; to me, the main strength of cibuildwheel is not the code/architecture but about all the platform-specific worries we solve and hopefully save other people from having? |
Note, #256 (comment) |
During contribution to cibuildwheel I found that some functions are to long and have many lines inside which are not connected with main task of this function.
My suggestions are:
Pack
build
arguments in some namedtuple (class based with typing) or namespace.manylinux_images
can be keep as separated arguementextract everything connected with setup python to install_python. It should:
get_pip.py
is always called)something like:
repair_command_default
can be changed toand usage:
pip wheel ...
are same on every system maybe it is a good idea to put it in separat module and import?The text was updated successfully, but these errors were encountered: