[python-uk] Using WSL for one month

Jonathan Hartley tartley at tartley.com
Thu Mar 23 10:18:12 EDT 2017

About a month ago I asked this list for advice on developing 
Python/Linux web services on a team which had been entirely C#/Windows. 
I was very grateful for the replies. I thought I'd let you know how it's 
panning out, especially with using Windows Subsystem for Linux (WSL.)

I stuck to my guns, and deploy the Python service on Linux. Despite 
that, I use Windows 10 on my laptop (against my personal inclination), 
so that I can install Visual Studio and get a version of everyone else's 
C# services running locally. Conversely, if anyone else needs to run my 
Python services, they just replicate my setup (described below.) So we 
only have one kind of development environment across the whole team.

My intention was to do development on a Linux VM. But I started out 
using WSL instead, as much to investigate what it is as anything. I 
didn't expect this would last long, but it's been 6 weeks now, and will 
probably stay for the foreseeable future. WSL is a new component in 
Windows that re-implements Posix system calls within the NT kernel, and 
links ELF binaries against them, so it can run compiled native Linux 
executables. WSL provides a full Ubuntu filesystem, complete with 
permissions, symlinks, fifos and everything, you'd expect. This 
filesystem has a /mnt/c for accessing your C drive.

So I'm able to do all my development on that. Enable WSL, sudo apt 
install ansible, and then you can run my ansible commands to create a 
working dev environment, deploy to localhost or elsewhere. Pip installs 
that require compilation work fine, and my service runs under uwsgi 
quite happily. No VMs required.

There are wrinkles with using WSL though:

* It's console apps only, no X. (Although apparently it's easy to get X 
to run, and some simple graphical applications work)

* I had problems using Upstart (We're on Ubuntu 14.04, for other 
reasons), and suspect Systemd would suffer similarly. Because there 
isn't really a 'boot process'. So for now, in local envs, I just 
start/restart my service manually on deploy, using 
"/sbin/start-stop-daemon", which is new to me, but has performed 

* Probably because of the Upstart/Systemd issues, there isn't a 
logrotate process running. Instead of getting one running, for now I'm 
cheating and simply not rotating logs in local envs.

* PostgreSQL doesn't run. Some system calls aren't implemented that it 
needs related to shared memory. So as a workaround, I installed the 
Windows version of PostgreSQL. Requires zero config and my Linux client 
connects to it on localhost just fine.

* Containers don't work. Lots of system calls they need are not 
implemented, and I don't know where this is on Redmond's priorities.

* The built-in Windows terminal is almost as bloody awful as you 
remember. At first I tried the popular and very flexible 3rd party 
terminal 'con-emu', but it has problems with WSL, and despite much 
wrangling, I couldn't get it to work reliably with all three of {WSL, 
256 colours, special keys like cursors}. So I fell back to wsl-terminal, 
a new terminal project written specifically to work with WSL. It's 
limited, but not in ways that bother me, and everything works out of the 
box. I installed my dotfiles repo, and fired up NeoVim, in solarized 
colors, with all my plugins, and everything works great.

* Having said that, syncing the Windows clipboard to the X one is 
problematic, not least because X is not running! Apparently this is 
fixable, because it's easy to get X running, but I've been too lazy, and 
have been working around it by occasionally *dragging* selected text 
between Windows/Linux applications, instead of using the clipboard.

I hope this is useful or interesting if you find yourself in a similar 

Best regards,

     Jonathan Hartley

Jonathan Hartley
tartley at tartley.com
+1 507-513-1101

More information about the python-uk mailing list