-
-
Notifications
You must be signed in to change notification settings - Fork 231
[MRG] Working towards python3 compatible codebase #442
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
[MRG] Working towards python3 compatible codebase #442
Conversation
__author__ = "Aleksandr Slepchenkov" __email__ = "[email protected]"
…icit bytes to BytesIO
@mr-c @anton-khodak: this PR is almost ready to merge now. I will do minor annotation improvements by tomorrow. Please review. branch is on my fork, but edits from maintainers are allowed :) |
@@ -15,6 +18,11 @@ | |||
from .stdfsaccess import StdFsAccess | |||
from .utils import aslist | |||
|
|||
# if six.PY3: | |||
# AvroSchemaFromJSONData = avro.schema.SchemaFromJSONData | |||
# else: |
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.
?
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.
commented out python3 lines until futher resolution of avro issue.
cwltool/__init__.py
Outdated
@@ -1 +1,3 @@ | |||
# -*- coding: utf-8 -*- |
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.
Is this necessary? Should be a local config option, yes?
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 added this when I included unicode_literals
import. I can delete this if we do not plan to use any unicode chars in our source code.
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.
Lets keep it out for now
Issues created for PR to make avro-python2 compatible with Python 3: apache/avro#234 Update: I've updated the description of the issue on JIRA to better express our interests. |
Update But the changes we need to make to avro-python2 try:
- from setuptools import setup
+ from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
from sys import version_info
@@ -27,10 +27,10 @@ if version_info[:2] <= (2, 5):
setup(
name = 'avro',
- version = '@AVRO_VERSION@',
- packages = ['avro',],
- package_dir = {'avro': 'src/avro'},
- scripts = ["./scripts/avro"],
+ version = '1.0',
+ package_dir = find_packages(),
+ use_2to3=True,
#include_package_data=True,
package_data={'avro': ['LICENSE', 'NOTICE']},
cc: @mr-c @anton-khodak |
@manu-chroma Can you try out http://python-future.org/translation.html ? |
@mr-c This looks like a great alternative. I've tested it locally and it works. Just one problem here, it fails to convert this particular line https://github.com/apache/avro/blob/master/lang/py/src/avro/schema.py#L778. So I had to change it in avro source before it worked for me. It passed both Possible solutions:
|
More info on the error: http://python-future.org/compatible_idioms.html#raising-exceptions |
4ad297c
to
79a3ec6
Compare
79a3ec6
to
aec5bb5
Compare
_logger.warn is deprecated in py3
@manu-chroma 👍 to a PR against their repo. Shall I merge what you've done so far? |
@mr-c Yes please 😄 |
Woohoo! Getting closer! |
I'm trying to make a PR which they would convincingly accept. The problem is this code when run in python3: from past import autotranslate
autotranslate(['avro'])
import avro.schema outputs Traceback (most recent call last):
File "late.py", line 4, in <module>
import avro.schema
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/home/manu/Desktop/test/venv3/lib/python3.5/site-packages/past/translation/__init__.py", line 402, in load_module
code = compile(source, self.pathname, 'exec')
File "/home/manu/Desktop/test/venv3/lib/python3.5/site-packages/avro/schema.py", line 782
% (json_string, e)), None, sys.exc_info()[2]
^
SyntaxError: invalid syntax The way raise SchemaParseException('Error parsing JSON: %s, error = %s'
% (json_string, e)), None, sys.exc_info()[2] to make this line work in cross-compatible way, we need to use Still trying to figure out how to change it in such a way that gets accepted upstream. |
@manu-chroma I'd implement it as separate py2 and py3 paths as documented in http://python-future.org/compatible_idioms.html#raising-exceptions with an |
Yes, I had the same idea @mr-c but I was doubtful they would accept such a patch. Though it's definitely worth a shot. |
Builds on top of #412
Branched out when I used
from __future__ import unicode_literals
in allcwltool
codebase to enforce unicode strings.Updates
unicode_literals
due to mypy errors. [MRG] Working towards python3 compatible codebase #442 (comment)avro-python3
. for more on this: [MRG] Working towards python3 compatible codebase #442 (comment)Possible solutions for this problem:
cwltool
andschema_salad
(locally tested)2to3
automated tool: [MRG] Working towards python3 compatible codebase #442 (comment)autotransalte
fromfuture
package. [MRG] Working towards python3 compatible codebase #442 (comment)