-
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
Adapt reportlab recipe for python3crystax [WIP] [DONT MERGE!] #1357
Conversation
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.
Hi @Jonast thank you for the contribution again.
I'm curious why is this toolchain_include_path
needed, could you elaborated a bit more?
Edit:
Travis build not happy on Python3:
- https://travis-ci.org/kivy/python-for-android/jobs/425362933
- https://travis-ci.org/kivy/python-for-android/jobs/425362934
error: [Errno 2] No such file or directory: '/opt/android/crystax-ndk-10.3.2/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi'
pythonforandroid/archs.py
Outdated
@@ -112,6 +112,7 @@ def get_env(self, with_flags_in_cc=True): | |||
env['AR'] = '{}-ar'.format(command_prefix) | |||
env['RANLIB'] = '{}-ranlib'.format(command_prefix) | |||
env['LD'] = '{}-ld'.format(command_prefix) | |||
env['LDSHARED'] = env['CC'] + " -shared " |
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.
Why don't you put that in the recipe itself to be sure it doesn't mess up with other ones?
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.
Because it seemed to me like a fundamental issue with the build environment. The problem appeared in python setup.py build_ext
, to be more specific, in distutils/unixccompiler.py
in function def link
when it accesses self.linker_so
- that one simply points to the wrong compiler/linker without LDSHARED being set. Of course I could hack around the problem in the recipe, but since the linker is simply set wrong, I felt like this should be solved in the core. I'd be happy to make a separate pull request for it if that's better
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 didn't investigate it that much, but my fear is that it could conflict with eventually other recipes options e.g. -static
. I usually don't dare to touch the core that much unless I see myself having to add every time the same option to a wide range of recipes.
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.
Well it's LDSHARED
, why would that ever be used for a static link? (sorry if that question is naive, I'm only medium familiar with intricate linker options) It's literally called through link_shared_object
in distutils/ccompiler.py
, I know that since I debugged around in distutils to track this down. I can see why this change would need some more testing though - but I'm all for fixing it properly, even if that will delay inclusion a little
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.
Oh yes sorry I overlooked, I thought it was env['CC'] += ' -shared'
. Then yes it may make total sense, thanks.
But I still wonder if it doesn't it's PR on its own, so we also clean all the other -shared
added around per recipes. We have a ton of them.
In fact it's been a while that I'm thinking about unit testing it at functional level. Not actually building the recipes, but checking the return of get_recipe_env()
across recipes and cleaning it up. I'm not sure how feasible it is.
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.
Maybe for doing that, an integration test might be a good idea. How about setting up a test script that will do p4a ... --requirements=python3crystax,<packagename>
for each package independently that has a recipe? Of course that would take a really long time to run, but one could still let it run overnight to get a basic overview over which recipes are currently broken or not
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.
Yes I also believe an integration test is safer, even though it doesn't cover everything. But as you stated it would run for ages. We are doing some continuous integration testing for only few critical recipes and that already takes ages. Not to mention flaky tests #1306
If you take a look at the current CI on Travis, we're running quite some builds in parallel and it still take ages. We're still very early in p4a CI so I'm sure there's room for improvement and help is more than welcome.
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 so should I do a separate LDSHARED
pull request? Or just add env["LDSHARED"] = env["CC"] + " -shared "
to the recipe? Or keep things like they are? I'm open for anything, but in any case, a proper value of LDSHARED
does seem to be a vital prerequisite for reportlab's setup.py to run through
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 be tempted to say I'm fine either ways. But since I honestly don't know where it should really fit (recipe.py
could also be a candidate right?) I would say let's address it later in a dedicated issue, I've just created here #1360
Until then you can pull that get_recipe_env()
quick fix I've mentioned in the ticket.
It's just that I think it requires some dedicated attention, it's a long standing technical debt that we should definitely tackle. What do you think?
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 arch.py
is the perfect place because that's where env["CC"]
and all other things are set up as well. And I don't see how anything else outside of recipes would require a broken env["LDSHARED"]
value, so it seems like the proper place to add this. recipe.py
would be a recipes-specific fix (as in for all recipes, but not anything else) which doesn't seem right to me
pythonforandroid/build.py
Outdated
self.toolchain_prefix = toolchain_prefix | ||
self.toolchain_version = toolchain_version | ||
self.toolchain_path = (self.ndk_dir + "/toolchains/" + |
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.
Could you elaborated why is this needed?
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.
See comment below for lengthier explanation. Essentially, stdarg.h
is missing somehow from the regular includes provided by CrystaX and hidden away in this toolchain-specific gcc include folder. I don't know why, or why this issue doesn't appear for other recipes that use -nostdinc
and include stdio.h
- if you have an idea what to investigate, I'll happily look into it. For now, this seemed like the cleanest solution to avoid this issue and also allow other recipes to use this path if necessary
@AndreMiras ok so basically, the recipe uses Why exactly this happens, and doesn't happen with the Edit: to be more specific, remove this CFLAGS addition from the recipe to test: " -I" + os.path.join(self.ctx.toolchain_include_path) In the end, this seemed like the best solution to add this without major hacks in only the recipe, while potentially offering this path for use in other recipes as well, should ever the same issue pop up in them. But honestly, I still have no idea why it's necessary in the first place, or why that file would be missing |
Regarding the travis build error: that path exists for me in my copy of crystax. Is it possible that the extraction script used in the travis build environment deletes it? It's that toolchain path which includes the missing |
Thanks for explaining!
Yesn't, it's not deleted, it's just not extracted, because it seemed not used for p4a. In fact it's probably because you're compiling on for different target archs, could it be? I would then suggest you to give your recipe a try on the "default" |
I'm just compiling for I actually ran this on a real armv7a phone to test, so I'm quite sure I successfully compiled for that architecture since PDF export ran through just fine 😄 |
Ouch OK then, thanks for the update, it helps. |
Well if you have any things to try, let me know. Basically my line of thinking was just: 1. I got an error saying That's pretty much all I know, and I have no clue why it is that way or why the other recipes don't run into this. So I'm open for ideas to find out more about this. |
Then I would be tempted to work in small safe increments. |
I literally just added an additional attribute As for the LDSHARED issue, I'm preparing a separate pull request right now: #1361 |
To begin with I'm also just a contributor, but I wouldn't say we're unimportant, otherwise the open source would not be "a thing".
Again I don't have the same insight as some other contributors or core devs, so perhaps you could give it a try to discuss on IRC. |
Oh, I forgot. Don't merge anyway, since LDSHARED is now a separate request. I'll mark it WIP, sec - Edit: okay, done. Right, I forgot about that assert. But if I remove it, the build would still only be failing with this recipe in it - there is no difference to whether I add this in the recipe itself or not regarding that, other than it's ugly to have this just in the recipe (and will require future recipes to hard-code this path as well which seems like a bad idea). Just my two cents I'm always open for things to try though. I agree that it seems odd this is necessary in the first place, but I'm really out of ideas about what could be the reason |
For what it's worth, I just updated the pull request such that This means 1. this pull request now depends on #1361 being merged, 2. only the I propose the following steps:
|
Ok I tested the new variant based on current master with #1361 merged, and it works fine for me! I exported a larger PDF including images and all with no problems. The travis build appears to fail since So I would propose that 1. someone tells me whether putting After that, someone who uses python 2 could give it a try, and other than that it seems done at least as far as I'm concerned! |
I actually could compile reportlab (c088826211ca) after fixing only minor things in freetype and harfbuzz recipes. |
So you basically want to revise it further? Not sure what exactly you're speaking of now, but by all means, knock yourself out! I'm not in a huge hurry to get it merged. The only reason I keep pushing it a little is because I tend to forget about side efforts I'm participating in, and things eventually become stale. I would also be happy to test the result with Python 3 if you point me to what fork/branch archive I should install from to test it! Or if there's anything else I could help try or change about the recipe, let me know |
Yes sorry, I have to say I feel embarrassed 😕 |
Oh I think I may have misread, you were basically saying you want to test it, right? Okay, looking forward to that 👍 somehow I read into it that you want to change things in it after freetype & harfbuzz for some other tech debt cleanup - too much going on, I'm getting confused 😆 |
In fact it seems to work out of the box when I try with buildozer (I didn't need freetype & harfbuzz fixes). I've created a throw away repo and demo video: By the way I'm on |
Nice! Yeah, I'm actually using this pull request in my app right now and it's just this pull request on p4a master, no other recipes or other things changed, and that works fine. But I just tested it for Python 3, not Python 2 (since I don't have any code lying around for that and I barely use it, I have mostly 3.5+ only code). Is that also what you tested, or did you use a more extensive pull request combination? |
I'm actually using master bare with no changes so not even your PR and it's working perfect even run time. |
Ah! Very interesting. Will do, hang on |
Weird, now I'm a bit confused it works for you. This is the build error I'm getting:
This really is what I expect, since in Python 3, opening files in binary mode will always give a bytes-like object, which cannot be combined with unicode strings in any of the So why does that not crash for you? Does that part not run, are you building some different version of it somehow? |
Oh wait I see, I'm running python2 on host. So buildozer runs from Python2. However I compile for Python3.
Install it for python2:
And try again 🤞 |
Okay, worked with Python 2 as build host. But maybe it'd be worth to do at least the following change to the recipe in master:
... since that is obviously needed for a Python 3 build host while not affecting Python 2, and it'd allow us to investigate potential other issues with the Python 3 build host! Other than that, this merge request is probably unnecessary now 👍 so that's nice, working reportlab 🎉 Edit: I'm mostly interested in getting the Python 3 host to work because Python 2 is ancient old fart stuff that is worth not depending upon even for build, IMHO. But obviously, this isn't super time-critical |
Good news! Yes I agree this should be tackled. |
I'll make a separate one, just in case the env change part turns out to be still interesting to look at for something. (Even though I assume at this point it is completely unnecessary, but who knows) |
Yes makes total sense. I'm closing that one nonetheless and wait for the other one. |
Hi @Jonast I was a bit busy working on #1380 but I could eventually reproduce the |
DON'T MERGE, OUTDATED. MOST NECESSARY CHANGES ARE ALREADY IN MASTER!
I adopted the reportlab recipe for python3crystax.
Note: I had to change the p4a core to set LDSHARED which for some reason wasn't set. This worked fine with no side effects on everything else I tested (
Pillow
,pysdl2
recipes for Android) but it could have an effect on some other recipes or platforms which I'm not aware ofNote 2: this shouldn't have any impact on the python 2 use, but I haven't actually tested this
WIP: needs to be adapted to work with #1361