-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[WIP] Fix crashes when using other commands than 'apk' #1809
Conversation
@Jonast This PR works but now there's a new error" Namespace object has no attribute private |
@nitanmarcel can you give me either the backtrace or the source code line in which that error occurs? it's likely also something broken by the |
@Jonast in the line 202 at build_recipes(... |
did you use a non-sdl bootstrap by any chance? service or webview or something? |
Nope. Honestly I don't have any ideas what I'm doing 😆 I'm using buildozer in a env with pyenv |
@Jonast The command buildoizer is trying to execute and fails:
|
This little one liner fixed it for me 🍰
|
@nitanmarcel yeah I just tried something similar 👍 still testing whether it blows up the non-buildozer build, could you give the updated pull request a retry in buildozer? |
@Jonast yes, it didn't raised any exceptions so far so the latest fix worked |
Wasn't better to add the following arguments to the non APK ones? Or that would completely break p4a? @Jonast |
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.
Everything working on installation using other commands than apk
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.
Thanks for the quick fix @Jonast, just one minor issue I'd prefer to do a different way.
pythonforandroid/build.py
Outdated
@@ -694,7 +697,8 @@ def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False): | |||
_env=copy.copy(env)) | |||
|
|||
# Afterwards, run setup.py if present: | |||
if project_has_setup_py(project_dir) and not ignore_setup_py: | |||
if project_dir is not None and \ |
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 would prefer using () instead of \ for line breaks.
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.
oops yea that's reasonable, changed it!
@@ -583,7 +586,7 @@ def add_parser(subparsers, *args, **kwargs): | |||
logger.setLevel(logging.DEBUG) | |||
|
|||
self.ctx = Context() | |||
self.ctx.use_setup_py = args.use_setup_py | |||
self.ctx.use_setup_py = getattr(args, "use_setup_py", True) |
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 think it would be neater to move the --use-setup-py etc. arguments to generic_parser so that they're always in the args object, instead of using getattr in different places. It isn't a great api to have to stick non-generic stuff in generic_parser like this, but I think it's a failure of the way the abstraction is set up rather than something specific to this particular argument. There are plenty of other things in generic_parser for the same reason.
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 disagree, I think it shouldn't be in the generic_parser if it's not for the other commands. I'd rather have the special case/getattr handling that is admittedly ugly, but still allows me to understand to which commands the arguments belong, BOTH as a coder and a user. (generated parser help texts would list all options even for other commands, right?) Therefore, moving it into generic_parser seems like a cheap hack to me
However, as usual if you really think that's how it should be I will change it accordingly, so your call 👍
Merging to get this fixed as it's a major issue, but I really dislike having hasattr/getattr spread around like this, I think it is a real code smell (arising from the argumentparser structure and how the arguments are used, not your mistake). |
@inclement I agree some other solution might be nicer. but I think just putting many things into |
Ok, another idea: what if all our parsers derive from a custom class instead of ArgumentParser which will somehow globally collect all the args, and which overwrites |
Well, that would be a neat but complex solution! I was thinking that the simplest option, which I'd still consider an improvement, would be to have an explicit step in between I guess there are various other options using a more sophisticated ArgumentParser subclass, including what you've suggested. |
@inclement I am willing to give that ArgumentParser subclass a shot if you think that might be worth the complexity. I would definitely personally prefer it over hardcoding args in some make-sure-they're-around function (that's essentially what you're proposing, right?) |
Right, but it's not what I'm proposing, it's what we already have since I never fixed this since originally implementing it :p
I don't think it's worth actively focusing on unless you particularly want to, but I'd welcome a good rethink of p4a's argument parsing structure if it made the whole thing less smelly. Your proposal could be nice, but I don't have a strong vision of what it would end up looking like. |
@inclement I was bored (and curious) and gave it a try: #1812 |
I broke things with the
setup.py
pull request 😂 commands other thanp4a apk
appear to be broken, from my test this fix makes it work again, sorry 😬