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

Rework common bootstrap area based on kollivier's work #1496

Merged
merged 1 commit into from Nov 30, 2018
Merged

Rework common bootstrap area based on kollivier's work #1496

merged 1 commit into from Nov 30, 2018

Conversation

ghost
Copy link

@ghost ghost commented Nov 29, 2018

This is a rework of a common shared bootstrap area based on @kollivier 's work started here: #991

Ignore comments below about errors, got it to work! 😄

@ghost
Copy link
Author

ghost commented Nov 29, 2018

Edit: no longer relevant / solved

2 similar comments
@ghost
Copy link
Author

ghost commented Nov 29, 2018

Edit: no longer relevant / solved

@ghost
Copy link
Author

ghost commented Nov 29, 2018

Edit: no longer relevant / solved

@ghost ghost changed the title [WIP] Rework common bootstrap area based on kollivier's work Rework common bootstrap area based on kollivier's work Nov 30, 2018
@ghost
Copy link
Author

ghost commented Nov 30, 2018

Okay, got it to work, and especially sdl2 bootstrap still works! The webview, service_only and pygame should still work (I adjusted paths where necessary), but I haven't verified it because all of those seem to be hardcoded to Python 2, and I just don't have any Python 2 app source code anywhere.

Can someone help me test a little? Or if nobody uses these bootstraps anyway, I suggest this is merged soon because it's quite likely to lead to conflicts with further bootstrap changes since things are moved around quite a bit

@@ -11,6 +13,26 @@
from pythonforandroid.recipe import Recipe


def copy_files(src_root, dest_root, override=True):
Copy link
Member

Choose a reason for hiding this comment

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

any reason not to use shutil.copytree ?

Copy link
Author

Choose a reason for hiding this comment

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

shutil.copytree can't override I think, or at least I am not aware of it. Also, according to Stack Overflow, it can't skip existing files either which is really needed here, and which is what the function does with override=False. So I don't want to rule out that this could be done with shutil functions somehow, but this seemed to be a good way to do it. I didn't write this code by the way, this is 99% @kollivier 's part - but I would have done something similar

Copy link
Member

Choose a reason for hiding this comment

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

ah right, it should work in python3 with a copy_function that ignore existing files, but that option is not present in python2, there is the ignore argument, probably with set intersection to ignore, but not sure how much simpler that would be. Nothing wrong with having a specific function anyway.

@ghost
Copy link
Author

ghost commented Nov 30, 2018

Sorry, still had a small mistake: the wrong start.c was in the common area, I fixed that now. Somehow managed to only fix that on my custom testing branch (which merges a couple of other unmerged pull requests to get my app to build). Travis build should hopefully be happy with that change.

Edit: did another rebase on top of this current version and it builds my app fine. Also, travis is happy now, yay! 👍

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

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

It looks good overall, but I'd like to test it with at least sdl2 and service_only before merging.
If I can't do it tonight I hope another dev can pick it up since I'm not available over the weekend and this is very likely to conflict if master moves.

@AndreMiras AndreMiras self-assigned this Nov 30, 2018
@@ -141,6 +141,9 @@ def wrapper_func(self, args):
user_ndk_ver=self.ndk_version,
user_ndk_api=self.ndk_api)
dist = self._dist
bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
# recipes rarely change, but during dev, bootstraps can change from
# build to build, so run prepare_bootstrap even if needs_build is false
Copy link
Member

Choose a reason for hiding this comment

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

The comment says we run prepare_bootstrap() but I don't see that we do 😕
Also why are we calling Bootstrap.get_bootstrap() for?

Copy link
Author

Choose a reason for hiding this comment

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

Interesting! Might be an oversight by @kollivier and maybe it was supposed to have a ctx.prepare_bootstrap(bs) right after? That would explain why bs is unused and there's the confusing comment there. I don't reuse any of the build layout for subsequent builds, so I assume that's why I didn't run into a situation in my tests where this was relevant

Copy link
Contributor

@kollivier kollivier Nov 30, 2018

Choose a reason for hiding this comment

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

The code wasn't used in the original PR, either, so whatever I was intending to do, I never actually made it happen. I think it can just be removed.

From the comment, I suspect that during some tests I found a case where switching the bootstrap didn't trigger a rebuild. Even if that was still true, it's likely not a common case (I was triggering it no doubt because I was testing with different bootstraps!) and can be fixed with a clean rebuild.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, thanks for cleaning this up and getting it running against the latest code! :)

Copy link
Author

Choose a reason for hiding this comment

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

@kollivier you're welcome, and this would have been infinitely more work without your foundation, so thanks again for starting this!

for filename in filenames:
subdir = root.replace(src_root, "")
if subdir.startswith(sep):
subdir = subdir[1:]
Copy link
Member

Choose a reason for hiding this comment

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

Minor suggestion/question:
I wonder if it's not cleaner to use something like os.path.normpath()?

>>> dest_root = '/foo/'
>>> subdir = 'bar/'
>>> os.path.join(os.path.normpath(dest_root), os.path.normpath(subdir))
'/foo/bar'

Which also covers he case were subdir by chance ends with two slashes.
So basically we could replace the three lines above by one:

subdir = os.path.normpath(root.replace(src_root, ""))

Copy link
Author

Choose a reason for hiding this comment

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

normpath won't remove a leading(!) slash, only a trailing one. It could still be used in addition, but I'm pretty certain the point of this code is to make sure subdir becomes a relative path, and normpath alone wouldn't achieve that

Copy link
Member

Choose a reason for hiding this comment

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

oh yes I misread as endwiths() 😅 so forget about it

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

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

I gave it a try and it works.
However as discussed on Discord, this doesn't kill the DRY we have all over the place like start.c.
We agree that start.c files diverge slightly across bootstraps, but that's more likely because we added fixes and features to some places and didn't also copied over to the other.
So at the end we still need to investigate and address it.

@ghost
Copy link
Author

ghost commented Nov 30, 2018

I suggest that the missing ctx.prepare_bootstrap(bs) should still be added though. I'm currently testing a build with that change

@AndreMiras AndreMiras merged commit 1636748 into kivy:master Nov 30, 2018
@ghost
Copy link
Author

ghost commented Nov 30, 2018

(I suppose it could also still be added in a minor merge request afterwards)

@ghost ghost deleted the bootstrap_refactor branch November 30, 2018 20:17
@ghost
Copy link
Author

ghost commented Nov 30, 2018

Follow-up pull request for outstanding possible issues & fixes with the common area handling code itself is here: #1499

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.

3 participants