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

Lib should work with python3 #165

Closed
benson-basis opened this issue May 2, 2015 · 29 comments
Closed

Lib should work with python3 #165

benson-basis opened this issue May 2, 2015 · 29 comments

Comments

@benson-basis
Copy link
Contributor

Why not? I've supplied a PR for this.

@rhoerbe
Copy link

rhoerbe commented Oct 2, 2015

I implemented a python 3 project on the mac, and realized - late at deployment time - that py3 is not supported on linux.
I am willing to set out a 500$ bounty if this can be resolved by Oct. 17th. (Would have to go with upwork, bountysource cannot specify 2 weeks expiration)

@bimargulies
Copy link
Contributor

the support in in the pull request.

@bimargulies
Copy link
Contributor

I thought I did linux, I'll have a look.

@rhoerbe
Copy link

rhoerbe commented Oct 2, 2015

If it is available in a fork, my time constraints would be a bit relaxed. But finally I would need it in the upstream/main

@bimargulies
Copy link
Contributor

Then it's hopeless. The upstream people haven't responded since May to my offer to work with them to get this merged in.

@rhoerbe
Copy link

rhoerbe commented Oct 2, 2015

Maybe they would react on a bounty?

@inclement
Copy link
Member

@rhoerbe For what it's worth, you don't actually need it in the master branch, you could for instance maintain your own branch with the fixes.

However, these fixes should clearly be merged into our master. Sorry for the delay with doing this. I don't know much about pyjnius myself, but I'll try to bug the other devs about it.

@rhoerbe
Copy link

rhoerbe commented Oct 2, 2015

If a sensible PR won't be merged in the master branch on the long term, then my customer would not like to see the lib good enough to be used in the product. I would have to revert to subprocess, py2.7 is not an option because of unicode requirements.

@rhoerbe
Copy link

rhoerbe commented Oct 2, 2015

But thank you for nudging the other devs!

@dessant
Copy link
Contributor

dessant commented Oct 2, 2015

@rhoerbe, you could help the merge process by trying out the branch and posting a feedback.

@rhoerbe
Copy link

rhoerbe commented Oct 2, 2015

Sure. Which branch?

@dessant
Copy link
Contributor

dessant commented Oct 2, 2015

@bimargulies
Copy link
Contributor

As specified, you need to take my several PR's in order.

On Fri, Oct 2, 2015 at 4:48 PM, dessant notifications@github.com wrote:

@rhoerbe https://github.com/rhoerbe
#164 #164
https://github.com/benson-basis/pyjnius/tree/python-34


Reply to this email directly or view it on GitHub
#165 (comment).

@bimargulies
Copy link
Contributor

Rainer, clearly the kivy people are not treating this as an active
'product'. Any of us could make a fork, merge this stuff in. But I'm not
going to accept money and responsibility for making it into a reliable
product -- at least, I'm not going to accept bounded money for unbounded
obligations.

On Fri, Oct 2, 2015 at 3:58 PM, Rainer Hörbe notifications@github.com
wrote:

But thank you for nudging the other devs!


Reply to this email directly or view it on GitHub
#165 (comment).

@rhoerbe
Copy link

rhoerbe commented Oct 4, 2015

I used the python-34 branch in the benson-basis/pyjnius fork and was able to install, but failed to import:

Python 3.4.3 (default, Jun 19 2015, 05:46:30) 
>>> import jnius
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.4/site-packages/jnius-1.1.dev0-py3.4-linux-x86_64.egg/jnius/__init__.py", line 13, in <module>
    from .reflect import *
  File "/usr/lib64/python3.4/site-packages/jnius-1.1.dev0-py3.4-linux-x86_64.egg/jnius/reflect.py", line 16, in <module>
    class Class(with_metaclass(MetaJavaClass, JavaClass)):
  File "/usr/lib/python3.4/site-packages/future/utils/__init__.py", line 137, in __new__
    return meta(name, bases, d)
  File "jnius/jnius_export_class.pxi", line 43, in jnius.MetaJavaClass.__new__ (jnius/jnius.c:16835)
  File "jnius/jnius_export_class.pxi", line 65, in jnius.MetaJavaClass.resolve_class (jnius/jnius.c:17231)
  File "jnius/jnius_env.pxi", line 11, in jnius.get_jnienv (jnius/jnius.c:3316)
  File "jnius/jnius_jvm_dlopen.pxi", line 87, in jnius.get_platform_jnienv (jnius/jnius.c:3244)
  File "jnius/jnius_jvm_dlopen.pxi", line 52, in jnius.create_jnienv (jnius/jnius.c:2728)
  File "/usr/lib64/python3.4/posixpath.py", line 89, in join "components") from None
TypeError: Can't mix strings and bytes in path components

In addition: setup does not automatically install future.

To replicate this behavior I created a docker container that should make it fairly quick to reproduce my findings:
https://github.com/rhoerbe/docker-test-jnius-centos/

@rhoerbe
Copy link

rhoerbe commented Oct 6, 2015

Nicolas, please can you help me please to find to spot Cython version 0.24.0a0, and guide me to what patch has to be applied where?

Am 06.10.2015 um 09:43 schrieb Nicolas notifications@github.com:

I think it works with small change in branch benson-basis/pyjnius and cython-git Cython version 0.24.0a0
because http://trac.cython.org/attachment/ticket/566/trac_566-no-py3-getslice.patch http://trac.cython.org/attachment/ticket/566/trac_566-no-py3-getslice.patch in jnius/jnius.c:440124

Python 3.4.3+ (default, Jul 28 2015, 13:17:50)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.

import jnius
from jnius import autoclass
autoclass('java.lang.System').out.println('Hello world')
Hello world
Stack = autoclass('java.util.Stack')
stack = Stack()
stack.push('hello')
cjtp:r java/lang/String definition java/lang/String
'hello'


Reply to this email directly or view it on GitHub #165 (comment).

@haricot
Copy link

haricot commented Oct 7, 2015

I just test the manipulation with the normal current version cython it works

After I modified the variables java_home jdk_home jre_home in the file setup.py benson-basis / python-branch pyjnius 34 .I can compile with the "make" command and it seems to work .With distutils buitd_ext there are error.

@rhoerbe
Copy link

rhoerbe commented Oct 7, 2015

Yes, installation was good, but "import jnius" failed. Did you succeed with the import? Would you have the possibility to fire up the docker container that I built?

@haricot
Copy link

haricot commented Oct 9, 2015

Good news ! Jnius succeed with the import !
The first time I could import only has over a local folder and other problem, but now it work everywhere.

I changed the file setup.py and jnius_jvm_dlopen.pxi. It is on still a little monkey patch, but everything built with build_ext on python3.
I think in the beginning of the week I could provide a branch.

@haricot
Copy link

haricot commented Oct 13, 2015

@rhoerbe Rainer,
Could you give me your return on import jnius, it should work
git clone -b python-34 https://github.com/haricot/pyjnius/

https://travis-ci.org/haricot/pyjnius/jobs/85107305
Build Status

@rhoerbe
Copy link

rhoerbe commented Oct 14, 2015

Thanks, now import is working and using the classes as well.
It would be great to see this in the master branch

@haricot
Copy link

haricot commented Oct 16, 2015

to integrate quickly we must make a recipe to style :
pythonforandroid/recipes/pyjnius/init.py

from pythonforandroid.toolchain import PythonRecipe, shprint, ArchAndroid, current_directory, info
import sh
import glob
from os.path import join, exists

class PyjniusRecipe(CythonRecipe):

    #url = 'https://github.com/kivy/pyjnius/archive/{version}.zip'                                                                                                                      
    url = 'https://github.com/haricot/pyjnius/archive/python-34.zip'

    name = 'pyjnius'
    depends = ['python3', ('sdl2', 'sdl')]
    site_packages_name = 'jnius'
    def prebuild_arch(self, arch):
        super(PyjniusRecipe, self).prebuild_arch(arch)
        if 'sdl2' in self.ctx.recipe_build_order:
            build_dir = self.get_build_dir(arch.arch)
            if exists(join(build_dir, '.patched')):
                print('pyjniussdl2 already pathed, skipping')
                return
            self.apply_patch('sdl2_jnienv_getter.patch')
            shprint(sh.touch, join(build_dir, '.patched'))

    def postbuild_arch(self, arch):
        super(PyjniusRecipe, self).postbuild_arch(arch)
        info('Copying pyjnius java class to classes build dir')
        with current_directory(self.get_build_dir(arch.arch)):
            shprint(sh.cp, '-a', join('jnius', 'src', 'org'), self.ctx.javaclass_dir)

recipe = PyjniusRecipe()

@rhoerbe
Copy link

rhoerbe commented Oct 18, 2015

I am not familiar with the android environment, I can help only with Linux.

@dessant
Copy link
Contributor

dessant commented Nov 3, 2015

Fixed in #164.

@dessant dessant closed this as completed Nov 3, 2015
@rhoerbe
Copy link

rhoerbe commented Nov 4, 2015

It does not pass the test that I set up in https://github.com/rhoerbe/docker-test-jnius-centos

Step 15 : RUN cd pyjnius && python3.4 setup.py install
 ---> Running in 6c75cee24079
Traceback (most recent call last):
  File "setup.py", line 74, in <module>
    jdk_home = getenv('JDK_HOME')
  File "setup.py", line 11, in getenv
    return val.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

@benson-basis
Copy link
Contributor Author

Really? Latest commit? I thought I fixed that item, but I could have missed
one. I can fix it tonight.

On Wed, Nov 4, 2015 at 2:39 PM, Rainer Hörbe notifications@github.com
wrote:

It does not pass the test that I set up in
https://github.com/rhoerbe/docker-test-jnius-centos

Step 15 : RUN cd pyjnius && python3.4 setup.py install
---> Running in 6c75cee24079
Traceback (most recent call last):
File "setup.py", line 74, in
jdk_home = getenv('JDK_HOME')
File "setup.py", line 11, in getenv
return val.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'


Reply to this email directly or view it on GitHub
#165 (comment).

@haricot
Copy link

haricot commented Nov 4, 2015

@rhoerbe I think you need to change your docker-test-jnius-centos/Dockerfile
-RUN git clone -b python-34 https://github.com/haricot/pyjnius.git
+RUN git clone https://github.com/kivy/pyjnius

@rhoerbe
Copy link

rhoerbe commented Nov 5, 2015

That is not the reason. The branch was fine the last time I tested. I did run the test against the master with a local change, waiting with the push until the problem is fixed.

@benson-basis
Copy link
Contributor Author

The latest merge include a code change that that fixes the stray decode. It was merged yesterday. All the tests pass with 2.7 and 3.4.

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

No branches or pull requests

6 participants