Skip to content

Alternate approach to enhancing Python 3 support #2918

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

Closed
wants to merge 49 commits into from

Conversation

gthank
Copy link
Contributor

@gthank gthank commented May 30, 2017

The same basic work, but ordered differently and tested more incrementally.

@agjohnson agjohnson added PR: work in progress Pull request is not ready for full review and removed PR: ready for review labels May 31, 2017
.travis.yml Outdated
@@ -1,9 +1,11 @@
language: python
python:
- 2.7
- 3.6
Copy link
Member

Choose a reason for hiding this comment

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

I believe TOX handles the Python env, so having this both places means we run all of the tests 2x. I think we can remove this.

Copy link
Member

Choose a reason for hiding this comment

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

Or, we can remove the 2.7, and run them all in 3.6 -- I see travis fails with "no 3.6 found" when running under 2.7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I added 3.6 to get around the weird error in 2.7, but that exploded the build matrix, so I tried to add the tox-travis plugin to make the integration smarter, but never got it properly configured. If 2.7 is working under 3.6, I think the right play is to pull out the tox-travis plugin and just tell travis to use 3.6

@ericholscher
Copy link
Member

ericholscher commented Jun 2, 2017

Any thoughts on the lint error? I'm guessing it's a version mismatch between prospector and one of the other linting tools. We've run into that before.

Otherwise, this is amazing! I'll try and take a look and get it merged next week. ❤️

@gthank
Copy link
Contributor Author

gthank commented Jun 5, 2017

RE: the lint error -> It looks like pydocstyle added an option to check_source a few months back and prospector isn't passing it yet.

@agjohnson
Copy link
Contributor

Dropping prospector back a minor release fixes this problem

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Added mostly code cleanup feedback. I think to get this merged before it rots, lets mark the tests failing in py3 as expected failure for py3 environments and open a ticket to address resolving those issues. We'll stick with defaulting to py2 for now for tests/etc. Does this sound reasonable?

@@ -1,9 +1,10 @@
language: python
python:
- 2.7
- 3.6
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps default to 2.7 for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, Travis fails and says it can't find the Python 3.6 interpreter when we do it on 2.7. The 2.7 tests seem to work fine when we tell Travis to use 3.6. Apparently just some quirk with the Travis and tox interactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, strange. Perhaps this is another motivator for switching to our newer standard tox.ini/travis.yml config, like: https://github.com/rtfd/sphinx_rtd_theme

If this is working as expected, probably no strong reason to switch just yet though

@@ -8,6 +9,7 @@

from readthedocs.constants import pattern_opts
from readthedocs.core.views import serve
from functools import reduce
Copy link
Contributor

Choose a reason for hiding this comment

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

import order is wrong here. should be pep8 standard of: builtins, third party, then local imports

from operator import add

from django.conf.urls import url, patterns
from django.conf import settings
from django.conf.urls.static import static

from readthedocs.constants import pattern_opts
from functools import reduce
Copy link
Contributor

Choose a reason for hiding this comment

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

import order off here too

from readthedocs_build.config import (ConfigError, BuildConfig, InvalidConfig,
load as load_config)


from .constants import BUILD_IMAGES, DOCKER_IMAGE
from six.moves import filter
Copy link
Contributor

Choose a reason for hiding this comment

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

import order off here as well

@@ -16,8 +22,10 @@
)
from readthedocs.projects.models import Project
from readthedocs.projects.constants import PROGRAMMING_LANGUAGES
import six
Copy link
Contributor

Choose a reason for hiding this comment

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

import order here as well

from io import StringIO
else:
from StringIO import StringIO
from io import StringIO
Copy link
Contributor

Choose a reason for hiding this comment

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

import order here

@@ -113,10 +114,13 @@ def parse_tags(self, data):
hash as identifier.
"""
# parse the lines into a list of tuples (commit-hash, tag ref name)
# StringIO below is expecting Unicode data, so ensure that it gets it.
if not isinstance(data, str):
data = str(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

str -> six.text_type again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See notes about svn.py.

@@ -147,9 +151,12 @@ def parse_branches(self, data):
origin/release/2.1.0
"""
clean_branches = []
# StringIO below is expecting Unicode data, so ensure that it gets it.
if not isinstance(data, str):
data = str(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

str -> six.text_type here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See notes about svn.py.


# StringIO below is expecting Unicode data, so ensure that it gets it.
if not isinstance(data, str):
data = str(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

str -> six.text_type here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+from future import standard_library
 +standard_library.install_aliases()

basically makes str on Python 2 act like unicode and adds bytes as the equivalent to the original str.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha, missed that. These all make sense then.

packaging==16.8

# Commenting stuff
git+https://github.com/zestedesavoir/django-cors-middleware.git@def9dc2f5e81eed53831bcda79ad1c127ecb3fe2
django-cors-middleware==1.3.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why this one was pinned to a commit. @ericholscher any background here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I recall, that commit was merging in a change from Eric that added some Django signals support, and now it's included in a public release.

Copy link
Member

Choose a reason for hiding this comment

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

@ericholscher
Copy link
Member

ericholscher commented Jun 8, 2017

@gthank If you pull in this patch to fix linting (#2932, or just rebase it) and mark the failures as expected in py3, I'll merge this, so that it doesn't rot, and we don't have any regressions. Then we can work forward from there.

@agjohnson
Copy link
Contributor

@ericholscher Could you first drop in on #2918 (comment), it's not clear why code was removed there, and that is also blocking review.

@ericholscher
Copy link
Member

So close :)

@ericholscher
Copy link
Member

Since this is only failing at linting, I'll do some local testing to confirm nothing is horribly broken, and it looks close! 🎆

@agjohnson
Copy link
Contributor

agjohnson commented Jun 9, 2017

@ericholscher sounds like this is close, we are discussing on IRC. probably no need to jump in. The plan for now is to get python3 tests working, which involve upgrading some of the lint/testing deps. I'm addressing that in #2863 and the merge will be cherrypicked here, so conflicts will be low. I'm less worried about rot as that PR and the restapi PR will be the only two conflicting commits and we can probably merge this all in early next week.

@ericholscher
Copy link
Member

I think there will be manual testing required before we deploy these changes to prod, which is what I'm referring to. I'm happy to do it after we merge it.

@ericholscher
Copy link
Member

Ugh @ restapi conflicts :( @agjohnson

@agjohnson
Copy link
Contributor

Yup, this was discussed already and we anticipated having to rebase some work for this and fixing testing.

@agjohnson
Copy link
Contributor

Okay, wrapped up #2863. I'm going to try to rebase this on a separate branch and see what happens.

@agjohnson
Copy link
Contributor

Okay, we're all set here. I merged everything together in another PR, so I'll just close this PR and merge that branch into master.

I'm super excited to get going with python 3. Thanks a ton for putting in the work on this one, @gthank!

@agjohnson agjohnson closed this Jun 14, 2017
@agjohnson agjohnson removed the PR: work in progress Pull request is not ready for full review label Jun 14, 2017
@gthank
Copy link
Contributor Author

gthank commented Jun 14, 2017

I'm excited, too! Thanks for letting me chip in, everybody.

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.

3 participants