# Dropbox Python 3 Migration: One Million Lines | gen2.dev

> Dropbox moved its desktop client, over a million lines of Python, from Python 2 to 3 without stopping releases. How it was staged, and what it took.

Source: https://gen2.dev/cases/dropbox-python-3/

---

Case file 33

# Dropbox to Python 3: a million lines moved while the client kept shipping

The Dropbox desktop client held more than a million lines of Python 2. Two Hack Week attempts at Python 3 showed the size of the job. The funded project that followed kept one codebase running on both versions, put Python 3 in front of employees first, and removed Python 2 only after seven months of real use.

![Slide: the Dropbox desktop client on Python 2.7 at over a million lines, running on both interpreters for employees, beta and stable users, and Python 3 only once Python 2 was removed.](https://gen2.dev/img/case-dropbox-python-3.png)

[Python 2 to 3](https://gen2.dev/cases/python-2-to-3/) is the story of a language that broke compatibility and waited eleven years for its users. This is the same event seen from one of those users: a company with a large Python 2 program on other people's computers and a product that could not stop.

## Gen 1

Dropbox's engineers describe the desktop client as "one of the most popular desktop applications in the world," and say that much of it is written in Python. By their count the application contains "over 1 million Python LOCs" and has had "hundreds of millions of installs." For years it ran on Python 2, most recently Python 2.7.

Nothing about Python 2 was failing users. The cost was in what surrounded it.

-   **The toolchain was frozen in time.** On Windows, Python 2 still required Visual Studio 2008, a compiler that Microsoft no longer supported and that was not compatible with the Windows 10 SDK.
-   **The packaging was borrowed.** The client was bundled with "freezer" scripts: py2exe for Windows, py2app for macOS and bbfreeze for Linux. The 2018 post notes that bbfreeze and pywin32 lacked Python 3 support at that stage.
-   **The language had moved on.** The team wanted Python 3's type annotations, which its type checker, Mypy, could use directly, and the newer syntax for concurrent code.

## The decision

The first two attempts were not funded projects. They were Hack Week experiments.

In 2015 a Hack Week team built a version of the client that, in Cary Yang's later account, "could sign in and sync some files." Many features were broken by the upgrade, and "much of the work was eventually thrown away."

In 2016 a second Hack Week team tried again, this time with Mypy, a static type checker that Dropbox had adopted in the year between. That team ported Dropbox's custom fork of Python to version 3.5 and added automated jobs that ran the unit tests and the type checks under Python 3.

The argument that won was about dependencies and not about elegance. Yang writes: "By early 2017, it had become clear that upgrading Python versions was in the critical path for several toolchain upgrades." The project was then officially staffed.

The decision that shaped everything else was how to do it. There would be no Python 3 branch. All application logic would be written in a hybrid syntax that ran on both versions, which in Yang's words allowed Dropbox "to continue shipping Python 2 builds to the majority of our users while we were testing Python 3 internally."

## What happened

The work came in two steps, and the first one changed no Python version at all.

**Step one: own the packaging.** Starting in 2016, Dropbox replaced the freezer scripts with its own design, which embedded the Python runtime inside a native application. Internally it was called "Anti-freeze." On Windows the build moved from Visual Studio 2008 to Visual Studio 2013. This removed the tools that had no Python 3 future before the language itself was touched.

**Step two: ship both.** A step the team called Hydra let the client be built with either interpreter and choose at launch which one to run. With that in place the migration became a rollout:

-   **Tests first.** Every unit test started out disabled under Python 3 and was re-enabled as its code was fixed.
-   **Types second.** Files that failed the Python 3 type check went on a list that the team worked down. Type coverage of the codebase rose from 35% to 63% during the project.
-   **Then people.** Teams that owned each part of the client held "bug bashes" on the Python 3 build.
-   **Then users, in rings.** Clients were opted in "through a remote feature gate." The 2018 post gives the order: "We first rolled out the change to Dropboxers," then to a fraction of the Beta population, then to the Stable channel.

One rule governed the pace. All bugs identified as migration-related had to "be fully investigated and corrected before expanding" to more users.

The result is stated in one sentence: "Within 7 months, all Dropbox installs were running Python 3." Only then was the old interpreter taken out. "As of version 52, this process is complete," the 2018 post says, and Python 2 was removed from the client altogether. Yang's post marks the same moment: "This marked the end of our Python version migration!"

## What was hard

Yang's post is specific about where the bugs came from, and it is the same place the language itself had its trouble: text. "String encoding in Python is hard" is one of his three lessons. Python 2 lets a program treat bytes and text as the same thing, and Python 3 does not. Most of the issues found in the migration came from that difference, in the places where the client reads and writes data.

The team also decided against one tempting shortcut. Adding the import that makes every string literal Unicode across the whole codebase was not possible in one step, and applying it to some files and not others would have confused the people working in them.

## What made it work

-   **One codebase, two interpreters.** Feature work continued because every change ran on both versions. Yang: "Because we preserved Python 2 compatibility throughout this project, we could continue to allow feature development." This is [running two systems](https://gen2.dev/guide/running-two-systems/) at the smallest possible cost, because only the interpreter was doubled.
-   **The switch was a setting.** A remote gate decided which interpreter a client ran. A bad result could be answered by moving users back, with no new release.
-   **The blockers were removed first.** Replacing the packaging tools was a project of its own, finished before the risky part started.
-   **Checks produced the work list.** The disabled tests and the list of files failing type checks turned "port a million lines" into a countable queue. The first lesson in Yang's post is "Unit tests and typing are invaluable."
-   **Gen 1 was removed.** The hybrid state was a means. After the stabilization period, Python 2 came out of the binary.
-   **The team told the story in public.** The two engineers who led the rollout presented it at PyCon US in May 2019. The talk's abstract says Python 2.7 powered the application "until recently" and that a growing lack of features and outdated toolchains "made migrating to Python 3 a necessity."

## The verdict

It worked. Every install moved, releases did not stop, and the old interpreter was deleted.

The limits are these. Both sources are Dropbox's own engineering posts, written after the project succeeded. Neither gives a team size or a cost. And the success took three tries over about three years: the 2015 attempt was mostly thrown away, and it was the 2016 groundwork and the 2017 funding that made the third attempt the last.

## What to take from it

-   **Treat a language upgrade as a rollout.** The question is not when the port is done. It is which users are on the new runtime today, and how they are doing.
-   **Make the old and new versions run the same source.** A long-lived branch has to chase every feature. A hybrid codebase does not.
-   **Clear the dependencies before the migration.** Tools with no future on the new platform are a separate project and should finish first.
-   **Let tests and types find the work.** Dropbox's third lesson is its summary: "Incrementally migrate to Python 3 for great profit."
-   **Schedule the removal.** The migration ended when Python 2 left the binary, not when Python 3 first ran. That is the step [killing Gen 1](https://gen2.dev/guide/killing-gen-1/) is about.

## Sources

1.  [Max Belanger and Damien DeVille - How we rolled out one of the largest Python 3 migrations ever (Dropbox Tech blog, September 25, 2018)](https://dropbox.tech/application/how-we-rolled-out-one-of-the-largest-python-3-migrations-ever) - Dropbox's own account of the reasons, the packaging work that came first, the rollout stages and the version that removed Python 2
2.  [Cary Yang - Incrementally migrating over one million lines of code from Python 2 to Python 3 (Dropbox Tech blog, February 6, 2019)](https://dropbox.tech/application/incrementally-migrating-over-one-million-lines-of-code-from-python-2-to-python-3) - the two Hack Week attempts, when the project was staffed, the tests and type checks, the string problems and the three lessons
3.  [Max Belanger and Damien DeVille - Going from 2 to 3 on Windows, macOS and Linux (PyCon US 2019 talk listing, May 3, 2019)](https://pycon-archive.python.org/2019/schedule/presentation/236) - the conference abstract: Python 2.7 powered the application until recently, and why the move became a necessity
4.  [Going from 2 to 3 on Windows, macOS and Linux (PyVideo recording page, PyCon US 2019)](https://pyvideo.org/pycon-us-2019/going-from-2-to-3-on-windows-macos-and-linux.html) - the recording of the same talk

Last updated November 28, 2026.

## Scorecard

Worked

Gen 1

The Dropbox desktop client on Python 2.7: over a million lines of Python, packaged for Windows, macOS and Linux with third-party freezer scripts

Gen 2

The same client on a Dropbox-customized Python 3.5, with the Python runtime embedded in a native application

Approach

Keep one codebase that runs on both versions, switch the interpreter per user behind a remote feature gate, and remove Python 2 last

How long

First attempt in 2015, staffed in 2017, reported complete in September 2018; the rollout itself took seven months

Verdict

A language migration done as a staged rollout and not as a port. It worked because the same code ran on both interpreters for months, so the switch could be made, and unmade, one group of users at a time.

## More case files

-   [Netscape 6](https://gen2.dev/cases/netscape-6/)
-   [Python 2 to 3](https://gen2.dev/cases/python-2-to-3/)
-   [Firefox Quantum](https://gen2.dev/cases/firefox-quantum/)
-   [Perl 6 and Raku](https://gen2.dev/cases/perl-6-raku/)
-   [AngularJS to Angular](https://gen2.dev/cases/angularjs-to-angular/)
-   [Windows Longhorn](https://gen2.dev/cases/windows-longhorn/)
-   [Digg v4](https://gen2.dev/cases/digg-v4/)
-   [Twitter to the JVM](https://gen2.dev/cases/twitter-jvm/)
-   [Basecamp](https://gen2.dev/cases/basecamp/)
-   [IPv4 to IPv6](https://gen2.dev/cases/ipv6/)
-   [VB6 to VB.NET](https://gen2.dev/cases/vb6-to-vb-net/)
-   [HTTP/2 and HTTP/3](https://gen2.dev/cases/http-2-and-3/)
-   [K-12 browser rewrite](https://gen2.dev/cases/k12-browser-rewrite/)
-   [Mac OS X](https://gen2.dev/cases/mac-os-x/)
-   [Microsoft Edge](https://gen2.dev/cases/edge-chromium/)
-   [Winamp3](https://gen2.dev/cases/winamp3/)
-   [Slack desktop](https://gen2.dev/cases/slack-desktop/)
-   [Evernote 10](https://gen2.dev/cases/evernote/)
-   [Uber rider app](https://gen2.dev/cases/uber-rider-app/)
-   [HealthCare.gov](https://gen2.dev/cases/healthcare-gov/)
-   [Thunderbird Supernova](https://gen2.dev/cases/thunderbird-supernova/)
-   [Skype](https://gen2.dev/cases/skype-cloud/)
-   [Sonos app (2024)](https://gen2.dev/cases/sonos-app-2024/)
-   [FBI Virtual Case File](https://gen2.dev/cases/fbi-virtual-case-file/)
-   [LinkedIn Inversion](https://gen2.dev/cases/linkedin-project-inversion/)
-   [Netflix to AWS](https://gen2.dev/cases/netflix-cloud-migration/)
-   [TSB migration](https://gen2.dev/cases/tsb-migration/)
-   [Phoenix pay system](https://gen2.dev/cases/phoenix-pay/)
-   [Universal Credit](https://gen2.dev/cases/universal-credit/)
-   [Queensland Health payroll](https://gen2.dev/cases/queensland-health-payroll/)
-   [Facebook for iOS](https://gen2.dev/cases/facebook-native-ios/)
-   [New Microsoft Teams](https://gen2.dev/cases/microsoft-teams-2/)
-   [Instagram to Python 3](https://gen2.dev/cases/instagram-python-3/)
-   [Discord Go to Rust](https://gen2.dev/cases/discord-go-to-rust/)
-   [Reddit Redesign](https://gen2.dev/cases/reddit-redesign/)
-   [GetPranks](https://gen2.dev/cases/getpranks/)
-   [All case files](https://gen2.dev/cases/)
