How does Dropbox use Python on Windows and OS X?


In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).

My guess is they are using a common library they have written then just have to use different hooks for the different platforms.

What method of development is this? It clearly isn’t IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me.

Asked By: robotshapes



Python25.dll is probably not their application code, it is a dll containing a copy of the python interpreter which can be called from within a windows application. Those pyc files are probably there in some form on windows, but they might be in an archive or obfuscated.

Python is included in OS/X, so it would be possible for them to execute those pyc file without shipping a python, but would not be surprised if they have there own python version lurking in the app bundle.

I don’t know how dropbox builds there distributions, but there are several tools to bundle python apps into executable packages. Take a look at py2exe, py2app, and or cx_freeze.

Answered By: mikerobi

Indeed they do bundle their own Python 2.5.4 interpreter found at /Applications/ Poking around in /Applications/ it looks to be bundled by PyObjC.

I’m no authority on this, but it seems it is exactly as you suggest in the OP:

My guess is they are using a common
library they have written then just
have to use different hooks for the
different platforms

Answered By: jathanism

Dropbox uses a combination of wxPython and PyObjC on the Mac (less wxPython in the 0.8 series). It looks like they’ve built a bit of a UI abstraction layer but nothing overwhelming—i.e., they’re doing their cross-platform app the right way.

They include their own Python mainly because the versions of Python included on the Mac vary by OS version (and Dropbox supports back to 10.4 IIRC); also, they’ve customized the Python interpreter a bit to improve threading and I/O behavior.

(I do not work for Dropbox or have any inside knowledge; all I did was read their forums and examine the filenames in in the Dropbox app bundle.)

Answered By: Nicholas Riley

For WINDOWS, Dropbox have employed a module similar to py2exe to package all their .py scripts, required libraries, resources etc into the distribution that you have mentioned above (.exe,, MS C runtime library and python25.dll) so that they can be run without requiring Python installation. Here’s a sample code of how you can achieve this with py2exe.

from distutils.core import setup
import py2exe

options = {'py2exe': {
           'bundle_files': 2,
           'dll_excludes': ['w9xpopen.exe']

Please see the tutorial here for more explanation.

PS: the number of files in the distribution can be controlled using the options parameter as shown in the above example.

Answered By: Philar

Recently I published an article on reversing the dropbox client on windows. It is available on slideshare.

In short,

On Windows dropbox uses py2exe. py2exe embeds the python dll as a resource within the executable. The compiled python source files aka pyc files are stored as a zip archive appended to the end of the executable (which is called an overlay).

Extracting the zip archive will give you the pyc files, but that is not the end of the story.
The pyc files are encrypted and not decompilable. They are decrypted only when they are loaded by the embedded python interpreter.

However there is a way to not bother too much about the encryption algorithm used. We can
directly grab decrypted code objects from memory letting dropbox do the decryption for us.

Answered By: Extreme Coders
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.