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

Python 2 updated to version 2.7.9 #678

Closed
wants to merge 15 commits into from
Closed

Python 2 updated to version 2.7.9 #678

wants to merge 15 commits into from

Conversation

opacam
Copy link
Member

@opacam opacam commented Mar 7, 2016

This is my first contribution to github... so be gentle with me if I do something wrong (I hope not)

This recipe has been tested with my android application, in fact, this is a migrated version from the python-for-android old toolchain, so... this works for me (it has been tested, with the new toolchain, as a local recipe and installed on a device running android version 4.0.4)

Notes:

  • Works with pygame and sdl2 (bootstraps), using the Android's NDK version r10e-rc4 and Api 14 (other configurations must be tested)
  • The new python2 recipe supports optional dependencies: sqlite3 (unless we use pygame bootstrap, because if that is the case, sqlite3 will be automatically included), openssl and libffi
  • Some recipes has been modified to adapt to the new python's version, specially I would like to mention the openssl recipe. The resulting openssl libraries will be renamed to libsslx.so and libcryptox.so, in order to avoid conflicts with the distributed android libs, so...all the recipes that depend on openssl shared libraries must be linked differently (Instead of seting ldflags to "-lcrypto -lssl" we must use "-lcryptox -lsslx")
  • The libtorrent recipe has been modified to adapt to new openssl build (as described above)
  • The sdl recipe has been modified to avoid error not finding python (patch applied at build time)
  • The sqlite3's recipe is from user brussee, with a little modification, so all credits must go to him
  • It is recommended to run command "python-for-android clean_all" before changing python2's optional dependencies (sqlite3, openssl or libffi)...otherwise it is most likely to fail, because the patches are applied at python's build time
  • Apologies for my english

@inclement
Copy link
Member

Thanks for the contribution! I will be away for a few days, and this is a big PR, so we may not have time to look at it for a little while. At a quick glance it looks good though, and we'll take a full look as soon as possible.

@brussee
Copy link
Contributor

brussee commented Mar 14, 2016

The new python2 recipe supports optional dependencies: sqlite3

Great work! I haven't got this to work #672.

The resulting openssl libraries will be renamed to libsslx.so and libcryptox.so, in order to avoid conflicts with the distributed android libs.

I found this to be not necessary if using p4a (tested here https://github.com/brussee/SkeletonApp/tree/test2-torrent).
I guess p4a figures this out during loading?

The sqlite3's recipe is from user brussee, with a little modification, so all credits must go to him.

Thanks! I'd like to share the credits with everyone who helped me :)

@brussee
Copy link
Contributor

brussee commented Mar 15, 2016

I tested this PR for my app (arm, API16, sdl2) and noticed #688 and #689 no longer occur (#690 is still there). You can find it here: https://github.com/brussee/python-for-android/tree/master-PR

However, similar to #668, I had to add this to the (python) recipes: numpy, pil, pyasn1, six, zope, android, netifaces, pyjnius, kivy, libtribler, zope_interface.

    call_hostpython_via_targetpython = False

    def get_recipe_env(self, arch=None):
        env = super(NetifacesRecipe, self).get_recipe_env(arch)
        env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
        env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
        # Set linker to use the correct gcc
        env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
        env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
                          ' -lpython2.7'
        return env

Otherwise an ELF32 error or Python.h not found occur.

@kived
Copy link
Contributor

kived commented Mar 15, 2016

Some recipes has been modified to adapt to the new python's version, specially I would like to mention the openssl recipe. The resulting openssl libraries will be renamed to libsslx.so and libcryptox.so, in order to avoid conflicts with the distributed android libs, so...all the recipes that depend on openssl shared libraries must be linked differently (Instead of seting ldflags to "-lcrypto -lssl" we must use "-lcryptox -lsslx")

This isn't a good idea. It makes it harder to use anything which depends on these libs, as everything must now be patched, and it doesn't solve any real problem. The app's libs will be used before system libs.

@brussee
Copy link
Contributor

brussee commented Mar 15, 2016

@opacam feel free to checkout this commit to undo the changes @kived is talking about brussee@72afe0f

Also feel free to checkout that branch to see what I was talking about regarding the recipes.

version = '2.7.2'
url = 'http://python.org/ftp/python/{version}/Python-{version}.tar.bz2'
version = '2.7.9'
url = 'http://python.org/ftp/python/{version}/Python-{version}.tgz' # tar.bz2'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changed to .tgz? Are the bzip2 archives not distributed anymore? bzip2 should be preferred as it is a smaller download at the expense of slower extraction - but people are far more likely to have download caps than execution caps.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the package no longer exist in *.bz2 compression for this version of python, only exist in *.tgz format...

@dessant
Copy link
Contributor

dessant commented Mar 16, 2016

Why not go for 2.7.11 directly?

@opacam
Copy link
Member Author

opacam commented Mar 16, 2016

Oooo...that's a point!!! but I made this recipe a long time ago (with the old toolchain) and I recently migrated to the new toolchain...going to the new python 2.7.11 will require more work to do and that is not an easy task (despite I think it must be done at some point) but for now this version is enough to solve some security issues related with the requests module that can not be solved with the old python version (at least I cannot solve) and this recipe is working (it's building and running fine)

Also notice that the current python version (2.7.2) distributed with the python-for android is running since I can remember (at least 2 years...or more) and it is really outdated, and I know that some user tried to update the python version for the old toolchain without success (sorry...I don't remember who), so... I think that this is a first step into the future.

@opacam
Copy link
Member Author

opacam commented Mar 16, 2016

Ei @kived and @brussee ...many thanks to take your time to review my code and help me to improve it. I will try to make a build with all the changes when I will have enough time...maybe tonight or tomorrow.

@opacam
Copy link
Member Author

opacam commented Mar 17, 2016

Successfully build with last changes applied and with command:

python-for-android create --dist_name=test_sdl2 --bootstrap=sdl2 --requirements=hostpython2,libffi,openssl,sqlite3,python2,pil,kivy

Notice that hostpython, and python must be build with the right order when using sdl2 bootstrap and using sqlite3 recipe, otherwise it will fail to build because the build order is not correct (this is not happening when using the pygame bootstrap)...Maybe is a bug when checking optional dependencies?

@opacam
Copy link
Member Author

opacam commented Mar 17, 2016

Ok... now we are on the road...I think that all the proposed changes are been done

Note: Tested with sdl2 bootstrap

@opacam
Copy link
Member Author

opacam commented Mar 19, 2016

Now I'm doing some test with the last python version (2.7.11) ... and it's working...so this will be closed and I will make a new Pull Request with the new version when I have all in order.

Thanks to all who take his time to see this pull request...hope I see you soon when i make the new pull request for the last version of python

@opacam opacam closed this Mar 19, 2016
@opacam opacam deleted the master branch March 19, 2016 15:21
@opacam opacam restored the master branch March 19, 2016 15:33
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.

5 participants