-
Notifications
You must be signed in to change notification settings - Fork 35
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
Python2 3 #81
Python2 3 #81
Conversation
Fix a print statement, importerrors, raising exceptions, and printing of a bytestring. Only covers the files that are necessary for example 1. Works under pythn 2.7 and python 3.6.
Makes basic example 2 run under python 2 and 3.
Works in python2 and python3. Make basic examples 1..5 run.
The files might need some clean up and refactoring.
First quick response: very welcome PR @borrob (and @sebastic for first starting this).! (Was actually thinking about this, this week, as all my current projects are in Python3). I expected indeed problems around 'factory' methods and imports. Maybe there is some way to get rid of the 'stetl=False' config requirement (maybe the same as in other imports with The current Travis failure is mainly some minor |
Thanks for the quick feedback. A good one about I feel there should be an better way to deal with the All my work is also in python3, so that is why I started to work on getting Stetl there as well. I think we can improve on clarity and coding style when we can concentrate on either python 2 or 3, but I guess we want python3 support and we're not yet ready to drop python2. |
Think we should aim for Python3-only. Python2 EOL clock is literally ticking. This project is too small (in terms of number of developers) and specialized to maintain both Py2 and Py3 forever. Like with Django (only Python 3 since Django 2) we/I can bring out a last Stetl version (1.3) that supports Python2, maybe a 1.4 that supports both, and move to Python3 starting with Stetl v2.0. This is an aim, there may be practical issues in particular specific Stetl Components (Plugins) written (like I do) for Python2. What helps is that the preferred way to run Stetl is via Docker (the Dockerfile needs modification there as well.). I am trying to test your changes in two virtualenvs. Will let you know of progress. Think we both have other work as well, so don't feel rushed! Hopefully some feedback from another main Stetl dev @fsteggink here... |
+1 |
The code is a bit ugly, but that is to enable both Py2 and Py3. The sooner we can drop Py2, the sooner we can clean it up, but that is for the project board/maintainer to decide ;). I hope we can fix this in time, so NLExtract can benefit from the work. |
Rethinking and seeking feedback: I think we should first bring out a last Python 2 version 1.3, make a branch of it for quickfix/maintenance, and then move to Python3 in Stetl v2.0 and not bother with any version supporting both Py2 and Py3. So that would mean your PR just needs to focus on Py3. Would that make the PR easier? Thoughts? |
Moving to Python3-only certainly makes life easier, no need to deal with six for Python 2 compatibility. With Python 2 going EOL in 2020, having a Stetl branch for Python 2 in maintenance mode makes sense. You still need to be careful/conservative with the Python 3 features you require, targeting compatibility with Python 3.3 (perhaps 3.5) or newer should be a good baseline. CentOS/RHEL:
Debian:
Ubuntu:
|
@sebastic good point! Was testing @borrob 's branch with Python 3.7.2 in a venv, so yes we need to pick a baseline. 3.3, 3.5? open for suggestions. @borrob I see most of the PR code dealing with handling imports of Stetl packages. e.g. in a sub-package like
and within same package relative imports:
Also here for discussion. |
The python version list sorted differently: 3.2.3 wheezy So 3.4.2 would be a good starting point (just leaving out wheezy and trusty). If you would start using stetl on a new project and thereby picking a 'new' machine, you would get either stretch or RHEL7 and thus allowing us to start with 3.5. I'm not sure if this thought train is valid though.
+1 for the idea of keeping a maintenance branch around for python 2 and focus new work on python 3. My personal preference is to stick to 'full' import, but I'm happy to follow other guidelines if there are other preferences. With respect to the config files: perhaps change it to specify the full path (from [input_geojson_file]
class = stetl.inputs.fileinput.JsonFileInput
file_path = input/cities.geojson Users can then still specify there own classes (that don't start with @justb4 : the changes are mainly about the importing, but there are some changes on catching exceptions, a couple of things with iterators, and off course the change in the config file with |
@sebastic and @borrob thanks for all investigations! My votes go for:
For the latter: we then can do away with the
Celery: uses full imports all over, and within a package relative 'dot' style, like in this random file:
Django: quick walkthrough, similar style as Celery, like in this random file. Update: tried 'Celery/Django' import styles above on @borrob 's python23 branch in 3.4.2. venv,
So i.s.o.
this:
|
Great! I think we have a plan. |
Perhaps it's best to close this MR? I'll start work on setting up a new branch with docker and convert to python3 (thereby dropping support for python2). |
Whatever you like: you can also do additional commits on this PR because of the interesting discussions, and then squash them together in a single commit. This makes it easier to review full changes. In any case we need some coordinated actions:
|
I already started working on a new branch to solely support py3 (3.4.2). All the basic examples are working, all nose tests pass, and all flake8 checks validate too. I still want to see if there is more clean-up work, prepare the |
@borrob good to hear! I have some time this week to work on this. I can start with the v1.3 release work. You can merge (mainly text, version info, no code changes) that into your branch as starting point ok? I can clone your branch and test, possibly make PRs for your branch then. ok? |
Ok, Stetl 1.3 released: PyPi and DockerHub plus 1.3 Tag+Branch made! |
…fix 10_jinja2 ex, docker-run examples script
Tip: to verify a Stetl source branch, in top/root-dir, I do:
And with Docker (see later):
Will add this to |
geopython#23 geopython#81 Dockerfile building/working, path fix 10_jinja2 ex, docker-run examples script
@justb4 : can you open a 'project board' on github for this conversion-work? That might make it easier to track all the tasks and todos. |
Done: see Project 1, though this is the first time I work with Cards (usually worked with issue-only Projects). Tried to add what is dangling/done. Ok? I think most of the work has already been done, but we should be aware of the last (often nasty) 10%... |
Great. I think this is a helpful tool to keep track of these last, nasty 10%. |
@borrob Good. You should have access to the repo/project. |
@borrob did you work on https://github.com/geopython/stetl/projects/1#card-19171400 ? Looks like |
Working on it right now. Yesterday I just did a quick update to get my master branch in line with the upstream stetl. |
I merged |
@borrob yes, let's move ahead! I've just tested |
Wonderful, many thanks ❤️ |
With the official support for python2 ending within a year (https://www.python.org/dev/peps/pep-0373/#id4), I totally agree with @sebastic: it's time to add python3 compatibility - see issue #23 .
I prepared a merge request for Stetl to work with both python2 and python3. All of the nosetests and all of the basic examples are working under both versions. Is there more to check?
A very unfortunate change I had to make is the use of 'custom' filters that are not included in the stetl library. For instance in basic example 12: I added
stetl=False
in theetl.cfg
file. This was necessary for chaining the steps together instetl/factory.py
, line 23. Not ideal at all since it migth break other tools using stetl.Please: any suggestions, comments or ideas are welcome. I assume there will be some discussion and changes before it will be merged.