Skip to content

Instantly share code, notes, and snippets.

@sharmaeklavya2
Last active March 15, 2017 09:54
Show Gist options
  • Save sharmaeklavya2/be637216ede685d2135a to your computer and use it in GitHub Desktop.
Save sharmaeklavya2/be637216ede685d2135a to your computer and use it in GitHub Desktop.
GSoC 2016 proposal

GSoC Project Proposal

In this project I will add Python 3 support to Zulip, without breaking Python 2 compatibility. I will also add type annotation (see PEP 483 and PEP 484) to all code. If time is left, I will also add support for platforms other than Ubuntu 14.04.

Experience

I am pretty comfortable programming in Python (both Python 2 and 3, but mainly 3). I especially like exploring advanced features of Python. My primary software development experience is with Django. I have used Django in many of my projects. You can view a list of my projects (and more about my skills) at https://sharmaeklavya2.github.io. My projects mainly include an online judge for competitive programming, an exam platform and online quiz games.

I have been making small contributions to Zulip for the last few weeks. Most of them are related to adding Python 3 support to Zulip (see #256).

I also know shell scripting and one of my first contributions (#506) involved improving a shell script. I have a good understanding of the fundamentals of Object Oriented Programming. I have also done a course on it (using Java) in my university.

What I am hoping to get out of my summer project

Zulip is the best project in Django that I have come across and I'm excited to work on it. I want to work for Zulip in GSoC because I want to learn more about how things go on in big open source projects. I have never before worked for one and this will be a good opportunity for me. I will not just learn new technologies, I will also learn how to do disciplined, professional software engineering. Having a mentor to guide me will further help me in learning these important skills.

My project and why I'm excited about it

Python 2's support will end in 2020. All new development in Python goes to Python 3. It is therefore important to add Python 3 support to Zulip.

Python 2 is still quite used even when Python 3 is the latest version recommended by PSF mainly because a lot of existing Python code is in Python 2. We need to break this vicious cycle. By taking up this project, I will learn how to port code from Python 2 to 3 and I will be able to give back to the Python community in the future.

I think static type checking is a nice feature to have in Zulip. It can help detect bugs at compile time. I plan to add type hints to all the Python code in Zulip (around 30K lines). This would make Zulip one of the largest open source type-annotated Python projects.

Currently Zulip only supports Ubuntu 14.04 for production use. This also limits how widely it can be deployed. If there is time left in the end, I will try to add support for other Linux platforms, like Fedora and CentOS.

Implementation Details

To get an idea of how to port Zulip to Python 3, I have already started making small contributions in that direction. Some of my work has even been included in Zulip's master branch. I have used futurize and modernize to auto-convert most of the code to Python 3 compatible syntax. The approach which I will follow (as suggested here by a mentor) is to run tests, see where they fail, and fix errors to make them pass.

Because of the nature of this approach, it is difficult to predict how much time this process will take and what are the problems which will arise. However, this process will most likely not take more than 6 weeks and some of the major issues we are likely to face have already been identified by running a few tests using Python 3 (this will not reveal all errors because code stops running after an exception is raised).

The main problem is the difference in the way Python 2 and 3 handle textual and binary data and support unicode. Zulip's code, since it is written in Python 2, freely mixes str and unicode. This project aims to cleanly separate the two types. Apart from making the code compatible with Python 3, this will also make it clearer when to use which type.

The next major problem is dependencies which do not support Python 3. Currently all dependencies have some support for Python 3 in their latest versions. There are some packages which are no longer supported by their authors, and hence they might not completely support Python 3 (like gcm-client, apns-client). One option is to look for alternatives and port our code to use them instead. The other option is to clone those packages, fix them ourselves and use those customized packages in Zulip.

Apart from these issues I'm expecting to find a few small bugs related to Python 3 compatibility (like cmp kwarg in sorted). LDAP might also cause some problems (setting it up can also take time).

I will also incorporate Python 3 compatibility checks (using futurize and/or modernize) and static type checking (using mypy) in Zulip's continuous integration system, Travis. Currently there is support for Python 3 checking but it is not complete (i.e. it is only applied on .py files, not on Python executable scripts). I have made changes to the CI script to test all Python files but it has to be made faster and more robust for incorporation into Travis.

Finally if I get time, I will add support for other Linux platforms.

Timeline

Adding Python 3 support is more like a bug hunt and less like adding a feature. I cannot know all things which have to be done in advance, so a fairly accurate timeline is not possible. Here is a rough timeline which I will try to follow.

Before coding phase starts:

  • Get more familiar with the Zulip's code by fixing small bugs.
  • Learn more about technologies used in Zulip (like LDAP, argparse/optparse, google-apis, S3, etc) by using them in my own tiny projects/programs.

Week 1-5: Add support for Python 3. I'll first add Python 3 support to core backend code and then to helper scripts (like linters, minifiers, etc).

Week 6-10: Type annotate Zulip's code.

Week 11-12: Winding up and adding support for other Linux platforms.

I do not have any exams during the coding phase. I have exams just before the coding phase (from May 3 to May 14). My summer vacations begin on May 19 and end on July 17.

About Me

I'm a 2nd year Computer Science student at Birla Institute of Technology and Science, Pilani (BITS Pilani). I live in Rajasthan, India. My timezone is +05:30.

Apart from development in Django, I like competitive programming and I often solve competitive programming problems in Python. I was also shortlisted for ICPC regionals this year. I am also a Linux fan and I enjoy writing scripts in Bash and Python to automate stuff.

Contact details:

@sharmaeklavya2
Copy link
Author

Revision 3 - This proposal is almost complete now. I might have to add more details about type annotations and other platform support.

@sharmaeklavya2
Copy link
Author

Revision 4 - I have ported Zulip to use the latest version of django-pipeline (#545), so I removed that task from my timeline.

@sharmaeklavya2
Copy link
Author

Revision 6 - Refactored list of contributions to Zulip in the Experience section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment