One more thing to do after upgrading python

This is mainly a note-to-self to remind me for my next upgrade – but hope it helps you too. TL;DR – install python-dev tools, export old installs into a requirements file, import into new python site-packages.

I upgraded the python on my laptop from 3.6 to 3.7 so I could use dataclasses for a little project. Then I got on a plane to Zurich and planned to get some work done on the 9 hour flight. Unfortunately I spent most of that time wrangling my python install – little cli tools I like to use like black, glances, sphinx, cookiecutter, etc – none of them worked!

When you do a python pip install of a library, it puts the library in a directory called site-packages under lib/python3.<your-version>/site-packages/<your-package-name>. If the library has defined command line entry-points, you will find it has also installed a file under bin/<your-package-name>. If bin is in your PATH, it means you can just type something like cookiecutter and it will call a function in the library to do stuff for you! Here’s what one of those files looks like:

➜  ~ bat ~/.local/bin/cookiecutter
───────┬───────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /home/matt/.local/bin/cookiecutter
───────┼───────────────────────────────────────────────────────────────────────────────────────────────
   1   │ #!/usr/bin/python3
   2   │
   3   │ # -*- coding: utf-8 -*-
   4   │ import re
   5   │ import sys
   6   │
   7   │ from cookiecutter.__main__ import main
   8   │
   9   │ if __name__ == "__main__":
  10   │     sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
  11   │     sys.exit(main())
───────┴───────────────────────────────────────────────────────────────────────────────────────────────
➜  ~

It tells the shell to execute it using /usr/bin/python3 – that’s a link to the latest version of python3 – in this case it’s now python3.7, while the library was installed under python3.6. So the command line now fails! Python3.7 doesn’t know about libs installed for 3.6 at all.

On the flight I realized I could either copy from the python3.6 site-lib to the python3.7 one or just switch python3 to point back to python3.6 to make things work. But once you have internet access, here’s the magic to get it all working.

First, install the python3.7 dev stuff so you can compile anything that needs compilation.

➜  ~ sudo apt-get install python3.7-dev

Then let’s export everything we used to use under 3.6 and then reinstall it under 3.7.

➜  ~ python3.6 -m pip freeze > old_requirements.txt
➜  ~ python3.7 -m pip install --user -r old_requirements.txt 

Blackfish City – urban ecopocalypse seasteading heist

Just finished Sam Miller’s beautiful book in the wee dark hours and it is a GEM. Qaanaaq is a place – I can see it and feel it’s culture, smell the noodles and the brine, feel the bitter cold. It’s like a long Geoff Manaugh article come to life. The nano-bonded orca-amazon that opens the book is one of the least weird things in it.

This book is start to finish what Robin Sloan calls gold coins, fascinating little surprises. Beyond the end actually – in the acknowledgments I discovered Bradley Silver’s modern tattoo work at white rabbit studio.

I enjoyed this as much as The Fifth Season, which is to say: immensely. Ended up checking it out twice from the NYPL on my Kobo just to savor through it.

Welding

Did a little welding class last night. I got to practice Oxy-Acetylene welding one on one because no one else wanted to weld on a hot summer night in the Brooklyn Navy Yard.

Since it was just me I got to do more with the instructor and we did both brazing and actual steel welding. Tons of fun. My final project was a little Z-Z tea light holder!

Obstacle Racing

I did my second obstacle race last weekend and it was glorious. This time, instead of just being alone, I had a crew. I saw them at the beginning and the end, but it was good to have a posse! I got all the obstacles except three that I gave up (too early) on.

Group photo of my running team

Mike, the guy in the sling, had his arm broken by someone’s knee in the race and KEPT RUNNING!

This is mostly an excuse to share some cool pictures.

I did great on time but next race I’m going for strict completion of everything. I should be able to do it!

Week 3048

Code

I had a comment from someone about my previous enthusiasm for Ditz, a distributed issue tracker. I still love Ditz, but it didn’t have enough of a community to keep it going. However, that got me to look at what’s current in distributed issue tracking and I’m really liking git-bug, which is very robust and good.

Not only does the command line work, but there’s a really nice terminal ui.

There’s a decent web view as well, but it seems to be view only.

Distributed issue tracking is great for people like me who sometimes write code without a network connection. You have your code and your issues to work on all in the same place! It’s probably terrible for project that have lots of non-technical commandline using folks working on them.