Python packages on Azure Web Apps Platform

If You're using Python, You're probably using pip tool inside Your virtual environment (or globally for entire OS) to install Python packages and probably requirements.txt files to automate deployment (resolve dependencies). It is pretty easy in Linux environment because it is Linux environment :) and because it is well documented in the internet.

So why do I need Azure Web Apps for my Python apps?

The answer is very simple: Because it's PaaS solution and it's cheap (or free). You don't have to administer next server and You can get it for free if free Azure Web Apps plan is enough for You. If You need some example just imagine a simple web app used for starting or stopping VM or monitoring GitHub repositories (with GitHub web hooks). You don't have to start new VM, pay for it and administrate it (update, upgrade, patch etc.) - just push Your app's code to GitHub or private repository on Azure and it will be automatically deployed inside venv on platform You don't have to monitor and administer. Azure Web Apps is also very scalable and You can scale-up in seconds without implementing multi-tenancy in Your app.

How about Python packages on Azure Web Apps?

As You know, some of Python packages needs to build some non-Python stuff - for example, package hashlib - very popular, important and in many cases a must-have package. pip (and other Python tools) uses GCC to compile this kind of stuff but unfortunately Python is not distributed with GCC and, what's more important, there is no GCC in Azure platform (surprised?) - You can only use Visual C++ Compiler.
Of course You can precompile packages or contact with Your package-of-choice mainatiner to to make wheels available for the package.

"Wheel is a built-package format, and offers the advantage of not recompiling your software during every install."

Microsoft is helping devs with solving this inconvenience:

"With the recent availability of Microsoft Visual C++ Compiler for Python 2.7. It will open in a new window. (...) it is now easier to build packages that have native code for Python 2.7."

Fortunately Azure Platform (Web Apps) have packages library for both Python 2.7 and Python 3.4 which is automatically inherited by venv (venv is automatically created by Web Apps Platform during Python project deployment).
It means that You don't need to build in example hashlib by Your own and include it in Your project. Of course You must remeber which of the packages is inherited from Azure Platform and also You need to remember not to include this package in requirements.txt file.
Of course #2 remembering such a list is not possible or very hard for any developer, so we need to have a list of this packages.

How to extract Python packages list from Azure Web Apps?

It is possible to extract this list from Azure Platform using Web Apps console, which You can find in management portal (portal.azure.com) in Your Web App management blade under Tools.
You just need to list D:\Python27\Lib directory using... unix-like command (surprised?):

ls D:\Python27\Lib

I have extracted Python 2.7 and Python 3.4 packages lists for You, so You can check it quickly but You need to remeber that those lists can be changed by Microsoft. So if You didn't find the package You've been looking for on those lists, just check it manually via Azure Web App Console just to be sure.

comments powered by Disqus